set thumbnail on a video watch route

This commit is contained in:
deflax 2024-01-19 16:37:20 +02:00
parent 345935b7bb
commit 401e7495c7
2 changed files with 13 additions and 5 deletions

View file

@ -343,12 +343,18 @@ def video_download_route(file_name):
@app.route('/video/watch/<file_name_no_extension>', methods=['GET']) @app.route('/video/watch/<file_name_no_extension>', methods=['GET'])
def video_watch_route(file_name_no_extension): def video_watch_route(file_name_no_extension):
file_name = file_name_no_extension + '.mp4' video_file = f'{file_name_no_extension}.mp4'
reqfile = f'{rec_path}/vod/{file_name}' video_path = f'{rec_path}/vod/{video_file}'
if not os.path.exists(reqfile): thumb_path = f'{rec_path}/thumb/{file_name_no_extension}.png'
if not os.path.exists(video_path):
abort(404) abort(404)
video_url=f'https://{scheduler_hostname}/video/{file_name}' else:
return render_template('watch.html', video_url=video_url) video_url=f'https://{scheduler_hostname}/video/{video_file}'
if not os.path.exists(thumb_path):
thumb_url = ""
else:
thumb_url=f'https://{scheduler_hostname}/thumb/{}'
return render_template('watch.html', video_url=video_url, thumb_url=thumb_url)
# Gallery # Gallery
@app.route("/gallery", methods=['GET']) @app.route("/gallery", methods=['GET'])

View file

@ -4,6 +4,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:type" content=video.other>
<meta property="og:image" content={{ thumb_url }}>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/plyr/dist/plyr.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/plyr/dist/plyr.min.css">
<style> <style>
body { body {