diff options
author | Sergey M․ <dstftw@gmail.com> | 2020-11-17 04:28:35 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2020-11-17 04:28:35 +0700 |
commit | 7d509c613ba66492ede723188d4254bb1427f4a2 (patch) | |
tree | bd2254cee1451cfcacd8b5c27068cc097e3d5f90 /youtube_dl/extractor/youtube.py | |
parent | b92e95aa0159f114f1066fbbefed128d8c850c60 (diff) | |
download | youtube-dl-7d509c613ba66492ede723188d4254bb1427f4a2.tar.xz |
[youtube] Fix chapters extraction (closes #26005)
Diffstat (limited to 'youtube_dl/extractor/youtube.py')
-rw-r--r-- | youtube_dl/extractor/youtube.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 22af03832..1a395b6e1 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1465,21 +1465,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor): def _extract_chapters_from_json(self, webpage, video_id, duration): if not webpage: return - player = self._parse_json( - self._search_regex( - r'RELATED_PLAYER_ARGS["\']\s*:\s*({.+})\s*,?\s*\n', webpage, - 'player args', default='{}'), - video_id, fatal=False) - if not player or not isinstance(player, 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): + data = self._extract_yt_initial_data(video_id, webpage) + if not data or not isinstance(data, dict): return chapters_list = try_get( - response, + data, lambda x: x['playerOverlays'] ['playerOverlayRenderer'] ['decoratedPlayerBarRenderer'] |