Skip to content

Commit

Permalink
[youtube:tab] Improve grid continuation extraction (closes #28130)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Feb 10, 2021
1 parent 7f8b8bc commit a4c7ed6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2374,9 +2374,9 @@ def _extract_continuation(cls, renderer):
next_continuation = cls._extract_next_continuation_data(renderer)
if next_continuation:
return next_continuation
contents = renderer.get('contents')
if not isinstance(contents, list):
return
contents = []
for key in ('contents', 'items'):
contents.extend(try_get(renderer, lambda x: x[key], list) or [])
for content in contents:
if not isinstance(content, dict):
continue
Expand Down Expand Up @@ -2509,6 +2509,13 @@ def _entries(self, tab, identity_token):
continuation_item = continuation_items[0]
if not isinstance(continuation_item, dict):
continue
renderer = continuation_item.get('gridVideoRenderer')
if renderer:
grid_renderer = {'items': continuation_items}
for entry in self._grid_entries(grid_renderer):
yield entry
continuation = self._extract_continuation(grid_renderer)
continue
renderer = continuation_item.get('playlistVideoRenderer') or continuation_item.get('itemSectionRenderer')
if renderer:
video_list_renderer = {'contents': continuation_items}
Expand Down

0 comments on commit a4c7ed6

Please sign in to comment.