From 85572c94de77f4a51d5b64e44c6b50cbe200c946 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Fri, 23 Aug 2019 14:48:00 -0700 Subject: Layout: refactor item system to be more maintainable, add vertical item type --- youtube/watch.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'youtube/watch.py') diff --git a/youtube/watch.py b/youtube/watch.py index 5487dd4..8a08832 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -36,7 +36,6 @@ def watch_page_related_video_info(item): except KeyError: result['views'] = '' result['thumbnail'] = util.get_thumbnail_url(item['id']) - result['item_size'] = 'small' result['type'] = 'video' return result @@ -47,7 +46,6 @@ def watch_page_related_playlist_info(item): 'id': item['list'], 'first_video_id': item['video_id'], 'thumbnail': util.get_thumbnail_url(item['video_id']), - 'item_size': 'small', 'type': 'playlist', } -- cgit v1.2.3 From fa2fa7fe16eabd0f62b6fe5bd3953b60715bbabb Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 24 Aug 2019 12:43:58 -0700 Subject: Layout: Add theater mode --- youtube/watch.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'youtube/watch.py') diff --git a/youtube/watch.py b/youtube/watch.py index 8a08832..d9b3cff 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -207,6 +207,8 @@ def get_watch_page(): music_attributes = get_ordered_music_list_attributes(info['music_list']), comments_info = comments_info, + theater_mode = settings.theater_mode, + title = info['title'], uploader = info['uploader'], description = info['description'], -- cgit v1.2.3 From d9fbf82bb23b848726eace7354444f16e17a36f8 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 24 Aug 2019 13:35:11 -0700 Subject: Layout: Add option to use 720p resolution --- youtube/watch.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'youtube/watch.py') 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'], -- cgit v1.2.3 From cb5f36581d74c22b6a0705dedf6acf40b6e052db Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 24 Aug 2019 16:45:01 -0700 Subject: Layout: add option to hide comments/related vids by default but click to show using
--- youtube/watch.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'youtube/watch.py') diff --git a/youtube/watch.py b/youtube/watch.py index ea33d0f..0515dea 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -217,6 +217,9 @@ def get_watch_page(): comments_info = comments_info, theater_mode = settings.theater_mode, + related_videos_mode = settings.related_videos_mode, + comments_mode = settings.comments_mode, + video_height = video_height, title = info['title'], -- cgit v1.2.3 From 3d911e4987ef9768702729e60d51cb872700a716 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 24 Aug 2019 17:55:14 -0700 Subject: Layout: Theater layout: Expand video width across page only as necessary based on length of video --- youtube/watch.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'youtube/watch.py') diff --git a/youtube/watch.py b/youtube/watch.py index 0515dea..8f83e48 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -57,6 +57,7 @@ def get_video_sources(info): 'src': format['url'], 'type': 'video/' + format['ext'], 'height': format['height'], + 'width': format['width'], }) #### order the videos sources so the preferred resolution is first ### @@ -199,6 +200,8 @@ def get_watch_page(): video_sources = get_video_sources(info) video_height = video_sources[0]['height'] + # 1 second per pixel, or the actual video width + theater_video_target_width = max(640, info['duration'], video_sources[0]['width']) return flask.render_template('watch.html', header_playlist_names = local_playlist.get_playlist_names(), @@ -221,6 +224,7 @@ def get_watch_page(): comments_mode = settings.comments_mode, video_height = video_height, + theater_video_target_width = theater_video_target_width, title = info['title'], uploader = info['uploader'], -- cgit v1.2.3