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.
This commit is contained in:
James Taylor 2020-04-05 17:27:43 -07:00
parent dd5c9a5d41
commit 3e09193eaf

View File

@ -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 = {}