same but use url_for

This commit is contained in:
deflax 2024-01-19 16:44:50 +02:00
parent 401e7495c7
commit acbd8b9501
2 changed files with 6 additions and 13 deletions

View file

@ -343,18 +343,11 @@ 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):
video_file = f'{file_name_no_extension}.mp4' video_file = f'{rec_path}/vod/{file_name_no_extension}.mp4'
video_path = f'{rec_path}/vod/{video_file}' thumb_file = f'{rec_path}/thumb/{file_name_no_extension}.png'
thumb_path = f'{rec_path}/thumb/{file_name_no_extension}.png' if not os.path.exists(video_file):
if not os.path.exists(video_path):
abort(404) abort(404)
else: return render_template('watch.html', thumb_file=thumb_file, video_file=video_file)
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

@ -5,7 +5,7 @@
<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:type" content=video.other>
<meta property="og:image" content={{ thumb_url }}> <meta property="og:image" content={{ url_for('thumb_route', file_name=thumb_file) }}>
<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 {
@ -28,7 +28,7 @@
<div id="player-container"> <div id="player-container">
<video id="player" playsinline controls> <video id="player" playsinline controls>
<source src="{{ video_url }}" type="video/mp4"> <source src="{{ url_for('video_route', file_name=video_file) }}" type="video/mp4">
</video> </video>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/plyr/dist/plyr.min.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/plyr/dist/plyr.min.js" crossorigin="anonymous"></script>