aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-08-24 13:35:11 -0700
committerJames Taylor <user234683@users.noreply.github.com>2019-08-24 13:35:11 -0700
commitd9fbf82bb23b848726eace7354444f16e17a36f8 (patch)
tree5920fe132a0ec73a80b8df769ae98058d98988ed /youtube
parentfa2fa7fe16eabd0f62b6fe5bd3953b60715bbabb (diff)
downloadyt-local-d9fbf82bb23b848726eace7354444f16e17a36f8.tar.lz
yt-local-d9fbf82bb23b848726eace7354444f16e17a36f8.tar.xz
yt-local-d9fbf82bb23b848726eace7354444f16e17a36f8.zip
Layout: Add option to use 720p resolution
Diffstat (limited to 'youtube')
-rw-r--r--youtube/templates/watch.html2
-rw-r--r--youtube/watch.py14
2 files changed, 13 insertions, 3 deletions
diff --git a/youtube/templates/watch.html b/youtube/templates/watch.html
index 3421059..a555882 100644
--- a/youtube/templates/watch.html
+++ b/youtube/templates/watch.html
@@ -7,7 +7,7 @@
video{
grid-column: 1 / span 5;
width: 100%;
- max-height: 360px;
+ max-height: {{ video_height }}px;
}
#related{
margin-top: 10px;
diff --git a/youtube/watch.py b/youtube/watch.py
index d9b3cff..ea33d0f 100644
--- a/youtube/watch.py
+++ b/youtube/watch.py
@@ -52,12 +52,17 @@ def watch_page_related_playlist_info(item):
def get_video_sources(info):
video_sources = []
for format in info['formats']:
- if format['acodec'] != 'none' and format['vcodec'] != 'none':
+ if format['acodec'] != 'none' and format['vcodec'] != 'none' and format['height'] <= settings.default_resolution:
video_sources.append({
'src': format['url'],
'type': 'video/' + format['ext'],
+ 'height': format['height'],
})
+ #### order the videos sources so the preferred resolution is first ###
+
+ video_sources.sort(key=lambda source: source['height'], reverse=True)
+
return video_sources
def get_subtitle_sources(info):
@@ -191,6 +196,10 @@ def get_watch_page():
'note': yt_dl_downloader._format_note(format),
})
+ video_sources = get_video_sources(info)
+ video_height = video_sources[0]['height']
+
+
return flask.render_template('watch.html',
header_playlist_names = local_playlist.get_playlist_names(),
uploader_channel_url = '/' + info['uploader_url'],
@@ -200,7 +209,7 @@ def get_watch_page():
dislikes = (lambda x: '{:,}'.format(x) if x is not None else "")(info.get("dislike_count", None)),
download_formats = download_formats,
video_info = json.dumps(video_info),
- video_sources = get_video_sources(info),
+ video_sources = video_sources,
subtitle_sources = get_subtitle_sources(info),
related = related_videos,
music_list = info['music_list'],
@@ -208,6 +217,7 @@ def get_watch_page():
comments_info = comments_info,
theater_mode = settings.theater_mode,
+ video_height = video_height,
title = info['title'],
uploader = info['uploader'],