logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git
commit: bfe72723d8318f8bfcb35dee69a40758df5fa3c0
parent ed99d68bdddfba0440dc81c105d5c0ea7cee7d1c
Author: pukkandan <pukkandan.ytdlp@gmail.com>
Date:   Sun, 30 Jan 2022 00:49:55 +0530

Use `itertools.islice`

Diffstat:

Myoutube_dl/extractor/youtube.py11++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py @@ -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):