This commit is contained in:
George Schizas 2020-10-24 01:16:22 +09:00 committed by GitHub
commit b3bd11c68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 10 deletions

View File

@ -1677,21 +1677,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
def _extract_chapters_from_json(self, webpage, video_id, duration): def _extract_chapters_from_json(self, webpage, video_id, duration):
if not webpage: if not webpage:
return return
player = self._parse_json( initial_data = self._parse_json(
self._search_regex( self._search_regex(
r'RELATED_PLAYER_ARGS["\']\s*:\s*({.+})\s*,?\s*\n', webpage, r'window\["ytInitialData"\] = (.+);\n', webpage,
'player args', default='{}'), 'player args', default='{}'),
video_id, fatal=False) video_id, fatal=False)
if not player or not isinstance(player, dict): if not initial_data or not isinstance(initial_data, dict):
return
watch_next_response = player.get('watch_next_response')
if not isinstance(watch_next_response, compat_str):
return
response = self._parse_json(watch_next_response, video_id, fatal=False)
if not response or not isinstance(response, dict):
return return
chapters_list = try_get( chapters_list = try_get(
response, initial_data,
lambda x: x['playerOverlays'] lambda x: x['playerOverlays']
['playerOverlayRenderer'] ['playerOverlayRenderer']
['decoratedPlayerBarRenderer'] ['decoratedPlayerBarRenderer']