]> jfr.im git - yt-dlp.git/commitdiff
[ie/youtube:tab] Detect looping feeds (#6621)
authorcoletdjnz <redacted>
Sat, 15 Jul 2023 03:20:24 +0000 (15:20 +1200)
committerGitHub <redacted>
Sat, 15 Jul 2023 03:20:24 +0000 (03:20 +0000)
Closes https://github.com/yt-dlp/yt-dlp/issues/5555

Note: the first page may still be repeated, however this is better than nothing.

Authored by: coletdjnz

yt_dlp/extractor/youtube.py

index 73bfa662d2637a9f27d3ee1b9639b1031e8b4ee6..826bbb20e18fdcecd007f3c690a3242ce262e3d6 100644 (file)
@@ -4921,10 +4921,15 @@ def _entries(self, tab, item_id, ytcfg, account_syncid, visitor_data):
             or try_get(tab_content, lambda x: x['richGridRenderer'], dict) or {})
         yield from extract_entries(parent_renderer)
         continuation = continuation_list[0]
-
+        seen_continuations = set()
         for page_num in itertools.count(1):
             if not continuation:
                 break
+            continuation_token = continuation.get('continuation')
+            if continuation_token is not None and continuation_token in seen_continuations:
+                self.write_debug('Detected YouTube feed looping - assuming end of feed.')
+                break
+            seen_continuations.add(continuation_token)
             headers = self.generate_api_headers(
                 ytcfg=ytcfg, account_syncid=account_syncid, visitor_data=visitor_data)
             response = self._extract_response(