From 8c2b81094ec277865f613aacfa6626bf271a4ab8 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Mon, 17 Feb 2020 20:15:59 -0800 Subject: yt_data_extract: fix missing variables in info for unavailable videos 'ip_address' was not set when no formats are available 'allowed_countries' was set to None rather than [] in extract_desktop_info which it turns out is the function that gets used in these cases --- youtube/yt_data_extract/watch_extraction.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py index 67cee35..bc02313 100644 --- a/youtube/yt_data_extract/watch_extraction.py +++ b/youtube/yt_data_extract/watch_extraction.py @@ -232,7 +232,7 @@ def _extract_watch_info_desktop(top_level): info = { 'comment_count': None, 'comments_disabled': None, - 'allowed_countries': None, + 'allowed_countries': [], 'limited_state': None, } @@ -323,7 +323,8 @@ def _extract_formats(info, player_response): query_string = info['formats'][0].get('url', '?').split('?')[1] info['ip_address'] = deep_get( urllib.parse.parse_qs(query_string), 'ip', 0) - + else: + info['ip_address'] = None def _extract_playability_error(info, player_response, error_prefix=''): -- cgit v1.2.3