mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-13 18:50:59 +01:00
[youtube] Encode ytsearch query
This commit is contained in:
parent
c72477bd32
commit
83d548ef0f
@ -1609,7 +1609,7 @@ class YoutubeUserIE(InfoExtractor):
|
|||||||
|
|
||||||
class YoutubeSearchIE(SearchInfoExtractor):
|
class YoutubeSearchIE(SearchInfoExtractor):
|
||||||
IE_DESC = u'YouTube.com searches'
|
IE_DESC = u'YouTube.com searches'
|
||||||
_API_URL = 'https://gdata.youtube.com/feeds/api/videos?q=%s&start-index=%i&max-results=50&v=2&alt=jsonc'
|
_API_URL = u'https://gdata.youtube.com/feeds/api/videos?q=%s&start-index=%i&max-results=50&v=2&alt=jsonc'
|
||||||
_MAX_RESULTS = 1000
|
_MAX_RESULTS = 1000
|
||||||
IE_NAME = u'youtube:search'
|
IE_NAME = u'youtube:search'
|
||||||
_SEARCH_KEY = 'ytsearch'
|
_SEARCH_KEY = 'ytsearch'
|
||||||
@ -1620,9 +1620,12 @@ class YoutubeSearchIE(SearchInfoExtractor):
|
|||||||
video_ids = []
|
video_ids = []
|
||||||
pagenum = 0
|
pagenum = 0
|
||||||
limit = n
|
limit = n
|
||||||
|
PAGE_SIZE = 50
|
||||||
|
|
||||||
while (50 * pagenum) < limit:
|
while (PAGE_SIZE * pagenum) < limit:
|
||||||
result_url = self._API_URL % (compat_urllib_parse.quote_plus(query), (50*pagenum)+1)
|
result_url = self._API_URL % (
|
||||||
|
compat_urllib_parse.quote_plus(query.encode('utf-8')),
|
||||||
|
(PAGE_SIZE * pagenum) + 1)
|
||||||
data_json = self._download_webpage(
|
data_json = self._download_webpage(
|
||||||
result_url, video_id=u'query "%s"' % query,
|
result_url, video_id=u'query "%s"' % query,
|
||||||
note=u'Downloading page %s' % (pagenum + 1),
|
note=u'Downloading page %s' % (pagenum + 1),
|
||||||
|
Loading…
Reference in New Issue
Block a user