mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-22 02:01:50 +00:00
[youtube] Fix chapters extraction (closes #26005)
This commit is contained in:
parent
b92e95aa01
commit
7d509c613b
1 changed files with 3 additions and 13 deletions
|
@ -1465,21 +1465,11 @@ 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(
|
data = self._extract_yt_initial_data(video_id, webpage)
|
||||||
self._search_regex(
|
if not data or not isinstance(data, dict):
|
||||||
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):
|
|
||||||
return
|
return
|
||||||
chapters_list = try_get(
|
chapters_list = try_get(
|
||||||
response,
|
data,
|
||||||
lambda x: x['playerOverlays']
|
lambda x: x['playerOverlays']
|
||||||
['playerOverlayRenderer']
|
['playerOverlayRenderer']
|
||||||
['decoratedPlayerBarRenderer']
|
['decoratedPlayerBarRenderer']
|
||||||
|
|
Loading…
Reference in a new issue