fetch thumbnails asynchroneously
This commit is contained in:
parent
e5a27692b5
commit
d710c93b36
6 changed files with 58 additions and 16 deletions
|
|
@ -57,8 +57,14 @@ class YoujizzBackend(BaseBackend, ICapVideo):
|
|||
return self.browser.iter_search_results(pattern)
|
||||
|
||||
def fill_video(self, video, fields):
|
||||
# ignore the fields param: VideoPage.get_video() returns all the information
|
||||
with self.browser:
|
||||
return self.browser.get_video(YoujizzVideo.id2url(video.id), video)
|
||||
if fields != ['thumbnail']:
|
||||
# if we don't want only the thumbnail, we probably want also every fields
|
||||
with self.browser:
|
||||
video = self.browser.get_video(YoujizzVideo.id2url(video.id), video)
|
||||
if 'thumbnail' in fields:
|
||||
with self.browser:
|
||||
video.thumbnail.data = self.browser.openurl(video.thumbnail.url).read()
|
||||
|
||||
return video
|
||||
|
||||
OBJECTS = {YoujizzVideo: fill_video}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,14 @@ class YoupornBackend(BaseBackend, ICapVideo):
|
|||
raise NotImplementedError()
|
||||
|
||||
def fill_video(self, video, fields):
|
||||
# ignore the fields param: VideoPage.get_video() returns all the information
|
||||
with self.browser:
|
||||
return self.browser.get_video(YoupornVideo.id2url(video.id), video)
|
||||
if fields != ['thumbnail']:
|
||||
# if we don't want only the thumbnail, we probably want also every fields
|
||||
with self.browser:
|
||||
video = self.browser.get_video(YoupornVideo.id2url(video.id), video)
|
||||
if 'thumbnail' in fields:
|
||||
with self.browser:
|
||||
video.thumbnail.data = self.browser.openurl(video.thumbnail.url).read()
|
||||
|
||||
return video
|
||||
|
||||
OBJECTS = {YoupornVideo: fill_video}
|
||||
|
|
|
|||
|
|
@ -72,8 +72,14 @@ class YoutubeBackend(BaseBackend, ICapVideo):
|
|||
raise NotImplementedError()
|
||||
|
||||
def fill_video(self, video, fields):
|
||||
# ignore the fields param: VideoPage.get_video() returns all the information
|
||||
with self.browser:
|
||||
return self.browser.get_video(YoutubeVideo.id2url(video.id), video)
|
||||
if fields != ['thumbnail']:
|
||||
# if we don't want only the thumbnail, we probably want also every fields
|
||||
with self.browser:
|
||||
video = self.browser.get_video(YoutubeVideo.id2url(video.id), video)
|
||||
if 'thumbnail' in fields:
|
||||
with self.browser:
|
||||
video.thumbnail.data = self.browser.openurl(video.thumbnail.url).read()
|
||||
|
||||
return video
|
||||
|
||||
OBJECTS = {YoutubeVideo: fill_video}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue