From 1446351a3c03fc0653ee9065738e1873392234cc Mon Sep 17 00:00:00 2001 From: bashonly Date: Fri, 15 Aug 2025 17:14:18 -0500 Subject: [PATCH] better logic Authored by: bashonly --- yt_dlp/extractor/tiktok.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/yt_dlp/extractor/tiktok.py b/yt_dlp/extractor/tiktok.py index 98ec8efb47..9516a8d200 100644 --- a/yt_dlp/extractor/tiktok.py +++ b/yt_dlp/extractor/tiktok.py @@ -982,7 +982,6 @@ class TikTokUserIE(TikTokBaseIE): def _entries(self, sec_uid, user_name): display_id = user_name or sec_uid seen_ids = set() - last_batch = None cursor = int(time.time() * 1E3) for page in itertools.count(1): @@ -992,7 +991,7 @@ class TikTokUserIE(TikTokBaseIE): query=self._build_web_query(sec_uid, cursor)) current_batch = sorted(traverse_obj(response, ('itemList', ..., 'id', {str}))) - if current_batch and current_batch == last_batch: + if current_batch and current_batch == sorted(seen_ids): message = 'TikTok API keeps sending the same page' if self._KNOWN_DEVICE_ID: raise ExtractorError( @@ -1002,8 +1001,6 @@ class TikTokUserIE(TikTokBaseIE): retry.error = ExtractorError( f'{message}. Taking measures to avoid an infinite loop', expected=True) - last_batch = current_batch - for video in traverse_obj(response, ('itemList', lambda _, v: v['id'])): video_id = video['id'] if video_id in seen_ids: