1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-05-20 20:19:33 +00:00

[youtube:tab] Improve grid continuation extraction (closes #28130)

This commit is contained in:
Sergey M․ 2021-02-10 22:28:58 +07:00
parent 7f8b8bc418
commit a4c7ed6b1e
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -2374,9 +2374,9 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
next_continuation = cls._extract_next_continuation_data(renderer) next_continuation = cls._extract_next_continuation_data(renderer)
if next_continuation: if next_continuation:
return next_continuation return next_continuation
contents = renderer.get('contents') contents = []
if not isinstance(contents, list): for key in ('contents', 'items'):
return contents.extend(try_get(renderer, lambda x: x[key], list) or [])
for content in contents: for content in contents:
if not isinstance(content, dict): if not isinstance(content, dict):
continue continue
@ -2509,6 +2509,13 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
continuation_item = continuation_items[0] continuation_item = continuation_items[0]
if not isinstance(continuation_item, dict): if not isinstance(continuation_item, dict):
continue 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') renderer = continuation_item.get('playlistVideoRenderer') or continuation_item.get('itemSectionRenderer')
if renderer: if renderer:
video_list_renderer = {'contents': continuation_items} video_list_renderer = {'contents': continuation_items}