about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2021-02-10 22:28:58 +0700
committerSergey M․ <dstftw@gmail.com>2021-02-10 22:28:58 +0700
commita4c7ed6b1e9100be8ef65c44e7e6e43b9314ff5c (patch)
tree65e4c2c0488be2ab0113e2c1ef0805429a646f16
parent7f8b8bc418b8831ea1c2ae8de64e3bf0e8b707f8 (diff)
downloadyoutube-dl-a4c7ed6b1e9100be8ef65c44e7e6e43b9314ff5c.tar.gz
youtube-dl-a4c7ed6b1e9100be8ef65c44e7e6e43b9314ff5c.tar.xz
youtube-dl-a4c7ed6b1e9100be8ef65c44e7e6e43b9314ff5c.zip
[youtube:tab] Improve grid continuation extraction (closes #28130)
-rw-r--r--youtube_dl/extractor/youtube.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 346311d9b..c78996629 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -2374,9 +2374,9 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
         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
@@ -2509,6 +2509,13 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
                 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}