]> git.gir.st - subscriptionfeed.git/blob - app/youtube/templates/watch.html.j2
harmonize layout; headerbar macro
[subscriptionfeed.git] / app / youtube / templates / watch.html.j2
1 <!DOCTYPE html>
2 <title>{{ title }} &mdash; {{ author }}</title>
3 <link rel="shortcut icon" href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300" fill="%23fff"><circle r="150" cx="150" cy="150" fill="%23f00"/><path d="m120 97v106l93-53"/></svg>'>
4 <link rel="stylesheet" href="/static/style.css">
5
6 {% import 'macros.imp.j2' as macros with context %}
7
8 {{ macros.headerbar() }}
9
10 {% include 'messages.inc.j2' %}
11
12 <article>
13 {% if video_url %}
14 <div class="aspect-ratio main-video" style="--aspect-ratio:{{ aspectr }}">
15 <video controls poster="{{ poster }}">
16 <source src="{{ video_url }}">
17 {% for cc in subtitles %}
18 <!-- TODO: CORS error
19 <track label="{{ cc.name }}" kind="subtitles" srclang="{{ cc.code }}" src="{{ cc.url }}" {{ 'default' if not loop.counter }}>
20 -->
21 {% endfor %}
22 </video>
23
24 <script>
25 "use strict";
26 //todo: should only be done after user is made aware of video id getting sent to 3rd party (wait for k-anon)
27 //window.addEventListener("load", () => load_sponsorblock("{{ video_id }}"));
28 document.addEventListener('DOMContentLoaded', ()=>{ let check = document.querySelector("#skip_sponsors");
29 check.addEventListener("change", () => {if (check.checked) load_sponsorblock("{{ video_id }}")});});
30 function load_sponsorblock(video_id){
31 fetch(`https://sponsor.ajay.app/api/skipSegments?videoID=${video_id}`)
32 .then(response => response.json())
33 .then(data => {
34 for (const segment of data) {
35 const [start, stop] = segment.segment;
36 if (segment.category != "sponsor") continue;
37 document.querySelector('.main-video video')
38 .addEventListener("timeupdate", function() {
39 if (document.querySelector("#skip_sponsors").checked &&
40 this.currentTime >= start && this.currentTime < stop-1) {
41 this.currentTime = stop;
42 }
43 });
44 }
45 });
46 }
47 </script>
48
49 </div>
50 {% else %}{#TODO: this'll break livestreams #}
51 <img src="{{ poster }}" style="width:100%;object-fit:cover;height:calc(100% / {{ aspectr }});">
52 {% endif %}
53
54 {% if video_error %}
55 <div class="video_error">
56 {{ errdetails }} Watch on <a href="{{ invidious_url }}">Invidious</a> or <a href="https://www.youtube.com/watch?v={{ video_id }}">Youtube</a>
57 </div>
58 {% endif %}
59
60 <h1>{{ title | e }}<br>
61 <small><a href="/channel/{{ channel_id }}">{{ author | e }}</a></small></h1>
62
63 <details><summary>Description</summary>
64 <p style="white-space:pre-wrap">{{ description | e }}
65 <hr></details>
66
67 <details><summary>Metadata</summary>
68 <dl>
69 <dt>Duration
70 {% set h = length // (60*60) %}
71 {% set m = length // 60 % 60 %}
72 {% set s = length % 60 %}
73 <dd>{{ h~':' if h }}{{ '%02d' % m }}:{{ '%02d' % s }}
74 <dt>Views
75 <dd>{{ '{0:,}'.format(views | int)|replace(",","&hairsp;") }}
76 <dt>Published
77 <dd>{{ published }}
78 <dt>Rating
79 <dd>{{ rating | round(1) }}/5
80 <dt>Visibility
81 <dd>{{ 'unlisted' if unlisted else 'public' }}
82 {% if blacklisted|length == 0 %}
83 <dt>Available in
84 <dd>All regions
85 {% elif blacklisted|length > countries|length %}
86 <dt>Available in
87 <dd>{{ countries | join(', ') }}
88 {% else %}
89 <dt>Blacklisted in
90 <dd>{{ blacklisted | join(', ') }}
91 {% endif %}
92 </dl>
93 <hr></details>
94
95 <details><summary>More Actions</summary>
96 <ul>
97 <li><label><input type=checkbox id=skip_sponsors>skip sponsors</label>
98 {# TODO: make checked by default (need to inform the user about potential privacy concerns) #}
99 <noscript><br>Note: requires javascript</noscript>
100 <li><a href="/watch?v={{ video_id }}&show=raw">show raw video</a>
101 <li><a href="/watch?v={{ video_id }}&show=json">view json metadata</a>
102 <li><a href="https://invidio.us/watch?v={{ video_id }}">watch on invidious</a>
103 <li><a href="https://youtu.be/{{ video_id }}">watch on youtube</a>
104 </ul>
105 <hr></details>
106
107 <!-- not implemented warning:--><div style="background:red">{%for x in (infocards+endcards)|selectattr('content.error')%}{{x.content.error}}{%endfor%}</div>
108 <details><summary>Info- and Endcards</summary>
109 {% for card in all_cards %}{#
110 #}{% set c = card.content %}{#
111 #}{% if card.type == 'VIDEO' %}{#
112 #}{% call macros.card(c.video_id, c.title, c.length) %}
113 <span class=channel>{{ c.author }}&nbsp;</span>
114 {% endcall %}{#
115 #}{% elif card.type == 'CHANNEL' and c.channel_id != channel_id %}{#
116 #}{% call macros.card_generic("/channel/"~c.channel_id, c.icons[250] if 'icons' in c else '', c.title) %}
117 <span class=channel>Channel</span>
118 <span class=advanced></span>
119 {% endcall %}{#
120 #}{% elif card.type == 'PLAYLIST' %}{#
121 #}{% call macros.card_generic("/playlist?list="~c.playlist_id, "https://i.ytimg.com/vi/"~c.video_id~"/mqdefault.jpg", c.title) %}
122 <span class=channel>{{ c.author }}</span>
123 <span class=advanced>{{ c.n_videos }} videos</span>
124 {% endcall %}{#
125 #}{% elif card.type == 'WEBSITE' %}{#
126 #}{% call macros.card_generic(c.url, c.icons[250] if 'icons' in c else '', c.title) %}
127 <span class=channel>{{ c.domain }}</span>
128 {% endcall %}{#
129 #}{% endif %}{#
130 #}{% endfor %}
131 <hr></details>
132 </article>
Imprint / Impressum