fetch thumbnails asynchroneously

This commit is contained in:
Romain Bignon 2010-08-01 21:08:22 +02:00
commit d710c93b36
6 changed files with 58 additions and 16 deletions

View file

@ -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}

View file

@ -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}

View file

@ -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}