wip (I commit everythings because my computer will die coming soon)
This commit is contained in:
parent
8fe2facd9f
commit
b1f688e6d5
4 changed files with 39 additions and 15 deletions
|
|
@ -37,19 +37,23 @@ class YoujizzBackend(BaseBackend, ICapVideo):
|
|||
BROWSER = YoujizzBrowser
|
||||
|
||||
def get_video(self, _id):
|
||||
video = self.browser.get_video(_id)
|
||||
with self.browser:
|
||||
video = self.browser.get_video(_id)
|
||||
return video
|
||||
|
||||
def iter_page_urls(self, mozaic_url):
|
||||
return self.browser.iter_page_urls(mozaic_url)
|
||||
with self.browser:
|
||||
return self.browser.iter_page_urls(mozaic_url)
|
||||
|
||||
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||
if not nsfw:
|
||||
return
|
||||
return self.browser.iter_search_results(pattern)
|
||||
with self.browser:
|
||||
return self.browser.iter_search_results(pattern)
|
||||
|
||||
def fill_video(self, video, fields):
|
||||
# ignore the fields param: VideoPage.get_video() returns all the information
|
||||
return self.browser.get_video(YoujizzVideo.id2url(video.id), video)
|
||||
with self.browser:
|
||||
return self.browser.get_video(YoujizzVideo.id2url(video.id), video)
|
||||
|
||||
OBJECTS = {YoujizzVideo: fill_video}
|
||||
|
|
|
|||
|
|
@ -37,19 +37,22 @@ class YoupornBackend(BaseBackend, ICapVideo):
|
|||
BROWSER = YoupornBrowser
|
||||
|
||||
def get_video(self, _id):
|
||||
return self.browser.get_video(_id)
|
||||
with self.browser:
|
||||
return self.browser.get_video(_id)
|
||||
|
||||
SORTBY = ['relevance', 'rating', 'views', 'time']
|
||||
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||
if not nsfw:
|
||||
return
|
||||
return self.browser.iter_search_results(pattern, self.SORTBY[sortby])
|
||||
with self.browser:
|
||||
return self.browser.iter_search_results(pattern, self.SORTBY[sortby])
|
||||
|
||||
def iter_page_urls(self, mozaic_url):
|
||||
raise NotImplementedError()
|
||||
|
||||
def fill_video(self, video, fields):
|
||||
# ignore the fields param: VideoPage.get_video() returns all the information
|
||||
return self.browser.get_video(YoupornVideo.id2url(video.id), video)
|
||||
with self.browser:
|
||||
return self.browser.get_video(YoupornVideo.id2url(video.id), video)
|
||||
|
||||
OBJECTS = {YoupornVideo: fill_video}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ class YoutubeBackend(BaseBackend, ICapVideo):
|
|||
BROWSER = YoutubeBrowser
|
||||
|
||||
def get_video(self, _id):
|
||||
return self.browser.get_video(_id)
|
||||
with self.browser:
|
||||
return self.browser.get_video(_id)
|
||||
|
||||
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||
import gdata.youtube.service
|
||||
|
|
@ -68,6 +69,7 @@ class YoutubeBackend(BaseBackend, ICapVideo):
|
|||
|
||||
def fill_video(self, video, fields):
|
||||
# ignore the fields param: VideoPage.get_video() returns all the information
|
||||
return self.browser.get_video(YoutubeVideo.id2url(video.id), video)
|
||||
with self.browser:
|
||||
return self.browser.get_video(YoutubeVideo.id2url(video.id), video)
|
||||
|
||||
OBJECTS = {YoutubeVideo: fill_video}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue