mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-16 01:25:06 +00:00
Rewrite as list comprehension.
This commit is contained in:
parent
b54b08c91b
commit
6ea7190a3e
1 changed files with 2 additions and 6 deletions
|
@ -526,16 +526,12 @@ def _get_collection(self, endpoint, collection_id, **query):
|
||||||
next_url = response.get('next_href', None)
|
next_url = response.get('next_href', None)
|
||||||
|
|
||||||
def _get_n_results(self, query, n):
|
def _get_n_results(self, query, n):
|
||||||
results = []
|
|
||||||
|
|
||||||
tracks = self._get_collection('/search/tracks',
|
tracks = self._get_collection('/search/tracks',
|
||||||
collection_id='Query "{0}"'.format(query),
|
collection_id='Query "{0}"'.format(query),
|
||||||
q=query.encode('utf-8'))
|
q=query.encode('utf-8'))
|
||||||
|
|
||||||
for track in itertools.islice(tracks, n):
|
results = [self.url_result(url=track['uri'])
|
||||||
uri = track['uri']
|
for track in itertools.islice(tracks, n)]
|
||||||
title = track['title']
|
|
||||||
results.append(self.url_result(url=uri))
|
|
||||||
|
|
||||||
if not results:
|
if not results:
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
|
|
Loading…
Reference in a new issue