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