0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-23 02:25:11 +00:00

[soundcloud:search] PEP 8

This commit is contained in:
Sergey M․ 2015-11-21 20:04:35 +06:00
parent 328a22e175
commit 7e3472758b

View file

@ -510,10 +510,9 @@ def _get_collection(self, endpoint, collection_id, **query):
next_url = '{0}{1}?{2}'.format( next_url = '{0}{1}?{2}'.format(
self._API_V2_BASE, endpoint, data) self._API_V2_BASE, endpoint, data)
response = self._download_json(next_url, response = self._download_json(
video_id=collection_id, next_url, collection_id, 'Downloading page {0}'.format(i + 1),
note='Downloading page {0}'.format(i+1), 'Unable to download API page')
errnote='Unable to download API page')
total_results = int(response.get( total_results = int(response.get(
'total_results', total_results)) 'total_results', total_results))
@ -524,23 +523,19 @@ def _get_collection(self, endpoint, collection_id, **query):
for item in filter(bool, collection): for item in filter(bool, collection):
yield item yield item
if (total_results is not None and if (total_results is not None and collected_results >= total_results) or not collection:
collected_results >= total_results) or not collection:
break break
next_url = response.get('next_href', None) next_url = response.get('next_href')
def _get_n_results(self, query, n): def _get_n_results(self, query, n):
tracks = self._get_collection('/search/tracks', tracks = self._get_collection(
collection_id='Query "{0}"'.format(query), '/search/tracks', collection_id='Query "{0}"'.format(query), limit=n, q=query)
limit=n, q=query)
results = [self.url_result(url=track['uri']) results = [self.url_result(track['uri']) for track in itertools.islice(tracks, n)]
for track in itertools.islice(tracks, n)]
if not results: if not results:
raise ExtractorError( raise ExtractorError(
'Soundcloud said: No track results', expected=True) 'Soundcloud said: No track results', expected=True)
return self.playlist_result(results, playlist_title=query)
return self.playlist_result(results, playlist_title=query)