Skip to content

Commit

Permalink
[youtube] Fix chapters extraction (closes ytdl-org#26005)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Nov 16, 2020
1 parent b92e95a commit 7d509c6
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,21 +1465,11 @@ def extract_id(cls, url):
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']
Expand Down

0 comments on commit 7d509c6

Please sign in to comment.