From a96c6d154a651d4387bc7edc5bde0546b29b01da Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 11 Feb 2021 17:10:38 +0530 Subject: [PATCH] [youtube] Fix search continuations --- youtube_dlc/extractor/youtube.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/youtube_dlc/extractor/youtube.py b/youtube_dlc/extractor/youtube.py index 15ff2905c..b973e5d81 100644 --- a/youtube_dlc/extractor/youtube.py +++ b/youtube_dlc/extractor/youtube.py @@ -3181,6 +3181,12 @@ class YoutubeSearchIE(SearchInfoExtractor, YoutubeBaseInfoExtractor): # So we search through all entries till we find them. continuation_token = None for slr_content in slr_contents: + if continuation_token is None: + continuation_token = try_get( + slr_content, + lambda x: x['continuationItemRenderer']['continuationEndpoint']['continuationCommand']['token'], + compat_str) + isr_contents = try_get( slr_content, lambda x: x['itemSectionRenderer']['contents'], @@ -3202,12 +3208,6 @@ class YoutubeSearchIE(SearchInfoExtractor, YoutubeBaseInfoExtractor): if total == n: return - if continuation_token is None: - continuation_token = try_get( - slr_content, - lambda x: x['continuationItemRenderer']['continuationEndpoint']['continuationCommand']['token'], - compat_str) - if not continuation_token: break data['continuation'] = continuation_token