mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-26 20:22:14 +00:00
Remove calls to _downloader.download in Youtube searchs
Instead, return the urls of the videos.
This commit is contained in:
parent
c72938240e
commit
8c416ad29a
1 changed files with 8 additions and 13 deletions
|
@ -1510,11 +1510,9 @@ class YoutubeSearchIE(InfoExtractor):
|
||||||
prefix = prefix[8:]
|
prefix = prefix[8:]
|
||||||
query = query.encode('utf-8')
|
query = query.encode('utf-8')
|
||||||
if prefix == '':
|
if prefix == '':
|
||||||
self._download_n_results(query, 1)
|
return self._get_n_results(query, 1)
|
||||||
return
|
|
||||||
elif prefix == 'all':
|
elif prefix == 'all':
|
||||||
self._download_n_results(query, self._max_youtube_results)
|
self._get_n_results(query, self._max_youtube_results)
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
n = int(prefix)
|
n = int(prefix)
|
||||||
|
@ -1524,14 +1522,12 @@ class YoutubeSearchIE(InfoExtractor):
|
||||||
elif n > self._max_youtube_results:
|
elif n > self._max_youtube_results:
|
||||||
self._downloader.report_warning(u'ytsearch returns max %i results (you requested %i)' % (self._max_youtube_results, n))
|
self._downloader.report_warning(u'ytsearch returns max %i results (you requested %i)' % (self._max_youtube_results, n))
|
||||||
n = self._max_youtube_results
|
n = self._max_youtube_results
|
||||||
self._download_n_results(query, n)
|
return self._get_n_results(query, n)
|
||||||
return
|
|
||||||
except ValueError: # parsing prefix as integer fails
|
except ValueError: # parsing prefix as integer fails
|
||||||
self._download_n_results(query, 1)
|
return self._get_n_results(query, 1)
|
||||||
return
|
|
||||||
|
|
||||||
def _download_n_results(self, query, n):
|
def _get_n_results(self, query, n):
|
||||||
"""Downloads a specified number of results for a query"""
|
"""Get a specified number of results for a query"""
|
||||||
|
|
||||||
video_ids = []
|
video_ids = []
|
||||||
pagenum = 0
|
pagenum = 0
|
||||||
|
@ -1560,9 +1556,8 @@ class YoutubeSearchIE(InfoExtractor):
|
||||||
|
|
||||||
if len(video_ids) > n:
|
if len(video_ids) > n:
|
||||||
video_ids = video_ids[:n]
|
video_ids = video_ids[:n]
|
||||||
for id in video_ids:
|
videos = [self.url_result('http://www.youtube.com/watch?v=%s' % id, 'Youtube') for id in video_ids]
|
||||||
self._downloader.download(['http://www.youtube.com/watch?v=%s' % id])
|
return videos
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
class GoogleSearchIE(InfoExtractor):
|
class GoogleSearchIE(InfoExtractor):
|
||||||
|
|
Loading…
Reference in a new issue