aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-09-24 18:50:54 -0700
committerJames Taylor <user234683@users.noreply.github.com>2020-09-24 18:50:54 -0700
commit20152a6316101c50459244930b8d9dad1ed822f5 (patch)
treef2dead9aea6fddd2f0f77a8593d850305a2012c4 /youtube/yt_data_extract
parent9f0d84ddb9e5ae67d1626bea94501ff0308efae5 (diff)
downloadyt-local-20152a6316101c50459244930b8d9dad1ed822f5.tar.lz
yt-local-20152a6316101c50459244930b8d9dad1ed822f5.tar.xz
yt-local-20152a6316101c50459244930b8d9dad1ed822f5.zip
Specify video height in html so page doesn't shift down after load
Use true video height extracted from youtube to handle videos shorter than their quality size. (e.g. widescreen videos)
Diffstat (limited to 'youtube/yt_data_extract')
-rw-r--r--youtube/yt_data_extract/watch_extraction.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py
index ca2da10..340a367 100644
--- a/youtube/yt_data_extract/watch_extraction.py
+++ b/youtube/yt_data_extract/watch_extraction.py
@@ -348,12 +348,14 @@ def _extract_formats(info, player_response):
streaming_data.get('dash_manifest_url'))
for yt_fmt in yt_formats:
+ itag = yt_fmt.get('itag')
+
fmt = {}
+ fmt['itag'] = itag
fmt['ext'] = None
fmt['audio_bitrate'] = None
fmt['acodec'] = None
fmt['vcodec'] = None
- fmt['itag'] = yt_fmt.get('itag')
fmt['width'] = yt_fmt.get('width')
fmt['height'] = yt_fmt.get('height')
fmt['file_size'] = yt_fmt.get('contentLength')
@@ -368,7 +370,12 @@ def _extract_formats(info, player_response):
fmt['url'] = yt_fmt.get('url')
fmt['s'] = cipher.get('s')
fmt['sp'] = cipher.get('sp')
- fmt.update(_formats.get(str(yt_fmt.get('itag')), {}))
+
+ # update with information from big table
+ hardcoded_itag_info = _formats.get(str(itag), {})
+ for key, value in hardcoded_itag_info.items():
+ conservative_update(fmt, key, value) # prefer info from Youtube
+ fmt['quality'] = hardcoded_itag_info.get('height')
info['formats'].append(fmt)