Patch-import-migrate: Add embed page for embeds on the web
Issue #36 From e51f0a78c778a2283887db7ffc22421a7c849296 Mon Sep 17 00:00:00 2001 From: James Taylor <user234683@users.noreply.github.com>
This commit is contained in:
35
youtube/templates/embed.html
Normal file
35
youtube/templates/embed.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline'; media-src 'self' https://*.googlevideo.com; {{ "img-src 'self' https://*.googleusercontent.com https://*.ggpht.com https://*.ytimg.com;" if not settings.proxy_images else "" }}"/>
|
||||
<title>{{ title }}</title>
|
||||
<link href="/youtube.com/static/favicon.ico" type="image/x-icon" rel="icon"/>
|
||||
<style>
|
||||
body {
|
||||
margin: 0rem;
|
||||
padding: 0rem;
|
||||
}
|
||||
video {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<video controls autofocus onmouseleave="{{ title }}"
|
||||
oncontextmenu="{{ title }}" onmouseenter="{{ title }}" title="{{ title }}">
|
||||
{% for video_source in video_sources %}
|
||||
<source src="{{ video_source['src'] }}" type="{{ video_source['type'] }}">
|
||||
{% endfor %}
|
||||
{% for source in subtitle_sources %}
|
||||
{% if source['on'] %}
|
||||
<track label="{{ source['label'] }}" src="{{ source['url'] }}" kind="subtitles" srclang="{{ source['srclang'] }}" default>
|
||||
{% else %}
|
||||
<track label="{{ source['label'] }}" src="{{ source['url'] }}" kind="subtitles" srclang="{{ source['srclang'] }}">
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</video>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +1,4 @@
|
||||
import youtube
|
||||
from youtube import yt_app
|
||||
from youtube import util, comments, local_playlist, yt_data_extract
|
||||
import settings
|
||||
@@ -367,11 +368,19 @@ def get_watch_page(video_id=None):
|
||||
playlist_id = request.args.get('list')
|
||||
index = request.args.get('index')
|
||||
use_invidious = bool(int(request.args.get('use_invidious', '1')))
|
||||
tasks = (
|
||||
gevent.spawn(comments.video_comments, video_id, int(settings.default_comment_sorting), lc=lc ),
|
||||
gevent.spawn(extract_info, video_id, use_invidious,
|
||||
playlist_id=playlist_id, index=index)
|
||||
)
|
||||
if request.path.startswith('/embed') and settings.embed_page_mode:
|
||||
tasks = (
|
||||
gevent.spawn((lambda: {})),
|
||||
gevent.spawn(extract_info, video_id, use_invidious,
|
||||
playlist_id=playlist_id, index=index),
|
||||
)
|
||||
else:
|
||||
tasks = (
|
||||
gevent.spawn(comments.video_comments, video_id,
|
||||
int(settings.default_comment_sorting), lc=lc),
|
||||
gevent.spawn(extract_info, video_id, use_invidious,
|
||||
playlist_id=playlist_id, index=index),
|
||||
)
|
||||
gevent.joinall(tasks)
|
||||
util.check_gevent_exceptions(tasks[1])
|
||||
comments_info, info = tasks[0].value, tasks[1].value
|
||||
@@ -471,7 +480,12 @@ def get_watch_page(video_id=None):
|
||||
'url': transcript_url
|
||||
})
|
||||
|
||||
return flask.render_template('watch.html',
|
||||
if request.path.startswith('/embed') and settings.embed_page_mode:
|
||||
template_name = 'embed.html'
|
||||
else:
|
||||
template_name = 'watch.html'
|
||||
return flask.render_template(
|
||||
template_name,
|
||||
header_playlist_names = local_playlist.get_playlist_names(),
|
||||
uploader_channel_url = ('/' + info['author_url']) if info['author_url'] else '',
|
||||
time_published = info['time_published'],
|
||||
@@ -514,7 +528,9 @@ def get_watch_page(video_id=None):
|
||||
|
||||
js_data = {
|
||||
'video_id': video_info['id'],
|
||||
}
|
||||
},
|
||||
# for embed page
|
||||
font_family=youtube.font_choices[settings.font],
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user