]> jfr.im git - yt-dlp.git/commitdiff
manually set limit for youtubesearchurl
authorUnknown <redacted>
Tue, 10 Nov 2020 22:20:52 +0000 (23:20 +0100)
committerUnknown <redacted>
Tue, 10 Nov 2020 22:20:52 +0000 (23:20 +0100)
youtube_dlc/extractor/youtube.py

index 273d823c224148d1a2309e69110695aee3cdc4f0..0dbb3531c162a0b06cfe6ba3031f29c59661224c 100644 (file)
@@ -327,7 +327,7 @@ def _real_find(obj):
 
         return entries, try_get(c, lambda x: x["continuation"])
 
-    def _entries(self, page, playlist_id):
+    def _entries(self, page, playlist_id, n=1):
         seen = []
 
         yt_conf = {}
@@ -339,7 +339,8 @@ def _entries(self, page, playlist_id):
 
         data_json = self._parse_json(self._search_regex(self._INITIAL_DATA_RE, page, 'ytInitialData'), None)
 
-        for page_num in itertools.count(1):
+        # for page_num in itertools.count(1):
+        for page_num in range(n):
             entries, continuation = self._find_entries_in_json(data_json)
             processed = self._process_entries(entries, seen)
 
@@ -3447,8 +3448,8 @@ def _real_extract(self, url):
         mobj = re.match(self._VALID_URL, url)
         query = compat_urllib_parse_unquote_plus(mobj.group('query'))
         webpage = self._download_webpage(url, query)
-        data_json = self._process_initial_data(webpage)
-        return self.playlist_result(self._process_data(data_json), playlist_title=query)
+        data_json = self._process_initial_data(webpage)
+        return self.playlist_result(self._entries(webpage, query, n=5), playlist_title=query)
 
 
 class YoutubeShowIE(YoutubePlaylistsBaseInfoExtractor):