aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract/watch_extraction.py
diff options
context:
space:
mode:
authorJames Taylor <28744867+user234683@users.noreply.github.com>2020-10-21 18:53:12 -0700
committerGitHub <noreply@github.com>2020-10-21 18:53:12 -0700
commitaa52c7a42e9573105dfadb07981c7f5f1447ca9d (patch)
tree6bff6ae507db03e435bb04e3969ef08093f3f8d8 /youtube/yt_data_extract/watch_extraction.py
parent3b5df36b0310b751fc25f8c0b7167c659c8259de (diff)
parentf01ef36a37c9112eca3f85d49622c41d68000a69 (diff)
downloadyt-local-aa52c7a42e9573105dfadb07981c7f5f1447ca9d.tar.lz
yt-local-aa52c7a42e9573105dfadb07981c7f5f1447ca9d.tar.xz
yt-local-aa52c7a42e9573105dfadb07981c7f5f1447ca9d.zip
Merge branch 'master' into add_sponsorblock
Diffstat (limited to 'youtube/yt_data_extract/watch_extraction.py')
-rw-r--r--youtube/yt_data_extract/watch_extraction.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py
index 340a367..5e57c15 100644
--- a/youtube/yt_data_extract/watch_extraction.py
+++ b/youtube/yt_data_extract/watch_extraction.py
@@ -172,7 +172,7 @@ def _extract_watch_info_mobile(top_level):
else:
info['playlist'] = {}
info['playlist']['title'] = playlist.get('title')
- info['playlist']['author'] = extract_str(multi_get(playlist,
+ info['playlist']['author'] = extract_str(multi_get(playlist,
'ownerName', 'longBylineText', 'shortBylineText', 'ownerText'))
author_id = deep_get(playlist, 'longBylineText', 'runs', 0,
'navigationEndpoint', 'browseEndpoint', 'browseId')
@@ -447,7 +447,8 @@ def _extract_playability_error(info, player_response, error_prefix=''):
SUBTITLE_FORMATS = ('srv1', 'srv2', 'srv3', 'ttml', 'vtt')
def extract_watch_info(polymer_json):
- info = {'playability_error': None, 'error': None}
+ info = {'playability_error': None, 'error': None,
+ 'player_response_missing': None}
if isinstance(polymer_json, dict):
top_level = polymer_json
@@ -477,6 +478,10 @@ def extract_watch_info(polymer_json):
else:
embedded_player_response = {}
+ # see https://github.com/user234683/youtube-local/issues/22#issuecomment-706395160
+ info['player_response_missing'] = not (
+ player_response or embedded_player_response)
+
# captions
info['automatic_caption_languages'] = []
info['manual_caption_languages'] = []
@@ -580,7 +585,8 @@ def get_caption_url(info, language, format, automatic=False, translation_languag
return url
def update_with_age_restricted_info(info, video_info_page):
- ERROR_PREFIX = 'Error bypassing age-restriction: '
+ '''Inserts urls from 'player_response' in get_video_info page'''
+ ERROR_PREFIX = 'Error getting missing player or bypassing age-restriction: '
video_info = urllib.parse.parse_qs(video_info_page)
player_response = deep_get(video_info, 'player_response', 0)