Bug fix on the video research method and coverage improvement.
The bug was solved by changing the maximum value of the 'search index'. Actually Youtube doesn't allow to get more than 500 results. That's why we changed the value of YOUTUBE_MAX_START_INDEX from 1000 to 500.
This commit is contained in:
parent
0006b52c19
commit
68a443768f
2 changed files with 7 additions and 5 deletions
|
|
@ -118,7 +118,7 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
|
|||
|
||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||
YOUTUBE_MAX_RESULTS = 50
|
||||
YOUTUBE_MAX_START_INDEX = 1000
|
||||
YOUTUBE_MAX_START_INDEX = 500
|
||||
yt_service = gdata.youtube.service.YouTubeService()
|
||||
yt_service.ssl = True
|
||||
|
||||
|
|
@ -134,8 +134,7 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
|
|||
query.racy = 'include' if nsfw else 'exclude'
|
||||
|
||||
query.max_results = YOUTUBE_MAX_RESULTS
|
||||
|
||||
if start_index > YOUTUBE_MAX_START_INDEX:
|
||||
if start_index >= YOUTUBE_MAX_START_INDEX:
|
||||
return
|
||||
query.start_index = start_index
|
||||
start_index += YOUTUBE_MAX_RESULTS
|
||||
|
|
@ -148,7 +147,6 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
|
|||
if nb_yielded < YOUTUBE_MAX_RESULTS:
|
||||
return
|
||||
|
||||
|
||||
def latest_videos(self):
|
||||
return self.search_videos(None, ICapVideo.SEARCH_DATE)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,11 @@ class YoutubeTest(BackendTest):
|
|||
v = self.backend.get_video('http://youtu.be/UxxajLWwzqY')
|
||||
self.backend.fillobj(v, ('url',))
|
||||
assert len(v.url)
|
||||
self.backend.browser.openurl(v.url)
|
||||
|
||||
try:
|
||||
self.backend.browser.openurl(v.url)
|
||||
except:
|
||||
self.fail('can\'t open url')
|
||||
|
||||
def test_weirdchars(self):
|
||||
v = self.backend.get_video('https://www.youtube.com/watch?v=BaW_jenozKc')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue