diff options
author | James Taylor <user234683@users.noreply.github.com> | 2020-10-19 13:53:57 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2020-10-19 13:53:57 -0700 |
commit | c9d0f685a43d95d653db56a00efe520e3a04d0d2 (patch) | |
tree | edbed96a759abe84a4f62b34a5d3fcb5eeb25553 /youtube/yt_data_extract/watch_extraction.py | |
parent | b35afb7cf6c7640380c650ca60c8150bb743eb4b (diff) | |
download | yt-local-c9d0f685a43d95d653db56a00efe520e3a04d0d2.tar.lz yt-local-c9d0f685a43d95d653db56a00efe520e3a04d0d2.tar.xz yt-local-c9d0f685a43d95d653db56a00efe520e3a04d0d2.zip |
Use get_video_info to get video urls if player response missing
Fixes failure mode 1 in #22
Diffstat (limited to 'youtube/yt_data_extract/watch_extraction.py')
-rw-r--r-- | youtube/yt_data_extract/watch_extraction.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py index 340a367..f89cec1 100644 --- a/youtube/yt_data_extract/watch_extraction.py +++ b/youtube/yt_data_extract/watch_extraction.py @@ -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) |