new API for the fillobj feature and severaaal fixes
This commit is contained in:
parent
fc4badf88e
commit
edc83df3a1
11 changed files with 60 additions and 42 deletions
|
|
@ -20,6 +20,7 @@ from weboob.capabilities.video import ICapVideo
|
|||
from weboob.tools.backend import BaseBackend
|
||||
|
||||
from .browser import YoujizzBrowser
|
||||
from .video import YoujizzVideo
|
||||
|
||||
|
||||
__all__ = ['YoujizzBackend']
|
||||
|
|
@ -46,3 +47,9 @@ class YoujizzBackend(BaseBackend, ICapVideo):
|
|||
if not nsfw:
|
||||
return
|
||||
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)
|
||||
|
||||
OBJECTS = {YoujizzVideo: fill_video}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,10 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
import logging
|
||||
import re
|
||||
import urllib
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserUnavailable
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
from weboob.tools.browser.decorators import check_domain, id2url
|
||||
from weboob.tools.misc import iter_fields, to_unicode
|
||||
|
||||
from .pages.index import IndexPage
|
||||
from .pages.video import VideoPage
|
||||
|
|
@ -41,15 +38,10 @@ class YoujizzBrowser(BaseBrowser):
|
|||
r'http://.*youjizz\.com/videos/(?P<id>.+)\.html': VideoPage,
|
||||
}
|
||||
|
||||
def fillobj(self, video, fields):
|
||||
# ignore the fields param: VideoPage.get_video() returns all the information
|
||||
self.location(YoujizzVideo.id2url(video.id))
|
||||
return self.page.get_video(video)
|
||||
|
||||
@id2url(YoujizzVideo.id2url)
|
||||
def get_video(self, url):
|
||||
def get_video(self, url, video=None):
|
||||
self.location(url)
|
||||
return self.page.get_video()
|
||||
return self.page.get_video(video)
|
||||
|
||||
@check_domain
|
||||
def iter_page_urls(self, mozaic_url):
|
||||
|
|
|
|||
|
|
@ -43,7 +43,14 @@ class IndexPage(BasePage):
|
|||
title = title_el.text.strip()
|
||||
|
||||
time_span = select(span, 'span.thumbtime span', 1)
|
||||
minutes, seconds = (int(v) for v in time_span.text.strip().split(':'))
|
||||
time_txt = time_span.text.strip()
|
||||
if time_txt == 'N/A':
|
||||
minutes, seconds = 0, 0
|
||||
elif ':' in time_txt:
|
||||
minutes, seconds = (int(v) for v in time_txt.split(':'))
|
||||
else:
|
||||
raise SelectElementException('Unable to parse the video duration: %s' % time_txt)
|
||||
|
||||
|
||||
yield YoujizzVideo(_id,
|
||||
title=title,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue