1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-22 08:47:41 +00:00

Use itertools.islice

This commit is contained in:
pukkandan 2022-01-30 00:49:55 +05:30
parent ed99d68bdd
commit bfe72723d8
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -3455,17 +3455,10 @@ class YoutubeSearchIE(SearchInfoExtractor, YoutubeBaseInfoExtractor):
_SEARCH_PARAMS = 'EgIQAQ%3D%3D' # Videos only
_TESTS = []
def _entries(self, query, n):
total = 0
for entry in self._search_results(query, self._SEARCH_PARAMS):
yield entry
total += 1
if total >= n:
return
def _get_n_results(self, query, n):
"""Get a specified number of results for a query"""
return self.playlist_result(self._entries(query, n), query)
entries = itertools.islice(self._search_results(query, self._SEARCH_PARAMS), 0, None if n == float('inf') else n)
return self.playlist_result(entries, query, query)
class YoutubeSearchDateIE(YoutubeSearchIE):