- commit
- b6f9336f4a33bfd777a7f177ad2baedb0e4f238f
- parent
- 2e266b66973b10d3140314f88e21c31b24aa0b21
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2025-02-06 19:47
add file view provides a stable URL to get the video
Diffstat
M | dropout.py | 11 | +++++++++++ |
M | static/video.js | 2 | +- |
M | templates/base.html | 2 | +- |
M | templates/video.html | 6 | +++++- |
4 files changed, 18 insertions, 3 deletions
diff --git a/dropout.py b/dropout.py
@@ -225,6 +225,16 @@ async def video_view(request): 225 225 return render_response(request, 'video.html', **data, files=files, next=next) 226 226 227 227 -1 228 async def file_view(request): -1 229 id = request.match_info['id'] -1 230 quality = request.match_info['quality'] -1 231 files = await fetch(f'https://api.vhx.tv/videos/{id}/files') -1 232 for file in files: -1 233 if file['quality'] == quality: -1 234 raise web.HTTPSeeOther(location=file['_links']['source']['href']) -1 235 raise web.HTTPNotFound -1 236 -1 237 228 238 async def favicon(request): 229 239 raise web.HTTPSeeOther(location='/static/favicon.ico') 230 240 @@ -244,4 +254,5 @@ if __name__ == '__main__': 244 254 app.router.add_get(r'/movie/{id:\d+}/', collection_view) 245 255 app.router.add_get(r'/series/{id:\d+}/', series_view) 246 256 app.router.add_get(r'/video/{id:\d+}/', video_view) -1 257 app.router.add_get(r'/video/{id:\d+}-{quality:\d+p}.mp4', file_view) 247 258 web.run_app(app, host='localhost', port=args.port)
diff --git a/static/video.js b/static/video.js
@@ -33,7 +33,7 @@ var applyQuality = function(quality, lazy) { 33 33 }; 34 34 35 35 var createMenu = function() {36 -1 var sources = Array.from(video.querySelectorAll('source')).reverse();-1 36 var sources = Array.from(video.querySelectorAll('[data-quality]')).reverse(); 37 37 var ul = h('ul', {'class': 'quality'}, sources.map(source => h('li', {}, [ 38 38 h('button', {'type': 'button'}, [source.dataset.quality]), 39 39 ])));
diff --git a/templates/base.html b/templates/base.html
@@ -3,7 +3,7 @@ 3 3 <head> 4 4 <meta charset="utf-8" /> 5 5 <meta name="viewport" content="width=device-width">6 -1 <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' vhx.imgix.net cdn.vhx.tv; media-src https:">-1 6 <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' vhx.imgix.net cdn.vhx.tv; media-src 'self' https:"> 7 7 <title>{% block title %}Dropin{% endblock %}</title> 8 8 <link rel="stylesheet" href="/static/style.css"> 9 9 <link rel="shortcut icon" href="/static/favicon.svg" type="image/svg+xml">
diff --git a/templates/video.html b/templates/video.html
@@ -6,7 +6,11 @@ 6 6 <div class="relative"> 7 7 <video controls poster="{{ thumbnail.large }}" preload="none" crossorigin="anonymous"> 8 8 {% for file in files %}9 -1 <source type="{{ file.mime_type }}" src="{{ file._links.source.href }}" {% if file.quality != 'adaptive' %}media="(min-height: {{ file.quality }}x)"{% endif %} data-quality="{{ file.quality }}">-1 9 {% if file.quality == 'adaptive' %} -1 10 <source type="{{ file.mime_type }}" src="{{ file._links.source.href }}"> -1 11 {% else %} -1 12 <source type="{{ file.mime_type }}" src="/video/{{ id }}-{{ file.quality }}.mp4" media="(min-height: {{ file.quality }}x)" data-quality="{{ file.quality }}"> -1 13 {% endif %} 10 14 {% endfor %} 11 15 {% for track in tracks.subtitles %} 12 16 <track kind="{{ track.kind }}" label="{{ track.label }}" srclang="{{ track.srclang }}" src="{{ track._links.vtt.href }}">