Skip to content

Commit

Permalink
[ie/youtube:tab] Detect looping feeds (#6621)
Browse files Browse the repository at this point in the history
Closes #5555

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

Authored by: coletdjnz
  • Loading branch information
coletdjnz committed Jul 15, 2023
1 parent 1bcb9fe commit 1ba6fe9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion yt_dlp/extractor/youtube.py
Expand Up @@ -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(
Expand Down

0 comments on commit 1ba6fe9

Please sign in to comment.