aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-04-05 17:27:43 -0700
committerJames Taylor <user234683@users.noreply.github.com>2020-04-05 17:27:43 -0700
commit3e09193eafeb7072c46385b2c91e82fcd275cc25 (patch)
tree6b3cbf88426e890db9453d1b8f36062b071826ee
parentdd5c9a5d412321bed8e2620a148a1b6fc43fc734 (diff)
downloadyt-local-3e09193eafeb7072c46385b2c91e82fcd275cc25.tar.lz
yt-local-3e09193eafeb7072c46385b2c91e82fcd275cc25.tar.xz
yt-local-3e09193eafeb7072c46385b2c91e82fcd275cc25.zip
Fix exception due to missing 'playlist' key in extracted info
Happens when there's an error on the page and there was no visible stuff on the page. 'playlist' wasn't set to None in that case.
-rw-r--r--youtube/yt_data_extract/watch_extraction.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/youtube/yt_data_extract/watch_extraction.py b/youtube/yt_data_extract/watch_extraction.py
index 193b84b..8fb0af4 100644
--- a/youtube/yt_data_extract/watch_extraction.py
+++ b/youtube/yt_data_extract/watch_extraction.py
@@ -188,6 +188,8 @@ def _extract_watch_info_mobile(top_level):
info['playlist']['current_index'] = playlist.get('currentIndex')
info['playlist']['items'] = [
extract_item_info(i) for i in playlist.get('contents', ())]
+ else:
+ info['playlist'] = None
# Holds the visible video info. It is inside singleColumnWatchNextResults
# but use our convenience function instead
@@ -264,6 +266,7 @@ def _extract_watch_info_desktop(top_level):
'comments_disabled': None,
'allowed_countries': [],
'limited_state': None,
+ 'playlist': None,
}
video_info = {}