move id2url to Video class
This commit is contained in:
parent
f7a92d9c72
commit
7bd936c11b
14 changed files with 69 additions and 76 deletions
|
|
@ -45,10 +45,6 @@ class YoujizzBackend(BaseBackend, ICapVideoProvider):
|
|||
return self._browser
|
||||
raise AttributeError, name
|
||||
|
||||
@classmethod
|
||||
def id2url(cls, _id):
|
||||
return 'http://www.youjizz.com/videos/%s.html' % _id
|
||||
|
||||
def check_url(func):
|
||||
def inner(self, *args, **kwargs):
|
||||
url = args[0]
|
||||
|
|
|
|||
|
|
@ -20,10 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
import re
|
||||
|
||||
from weboob.capabilities.video import Video
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
from .. import tools
|
||||
from ..video import YoujizzVideo
|
||||
|
||||
|
||||
__all__ = ['IndexPage']
|
||||
|
|
@ -57,9 +56,8 @@ class IndexPage(BasePage):
|
|||
minutes, seconds = time_span.text.strip().split(':')
|
||||
duration = 60 * int(minutes) + int(seconds)
|
||||
|
||||
yield Video(_id,
|
||||
title=title,
|
||||
duration=duration,
|
||||
thumbnail_url=thumbnail_url,
|
||||
nsfw=True,
|
||||
id2url=tools.id2url)
|
||||
yield YoujizzVideo(_id,
|
||||
title=title,
|
||||
duration=duration,
|
||||
thumbnail_url=thumbnail_url,
|
||||
nsfw=True)
|
||||
|
|
|
|||
|
|
@ -21,17 +21,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
from logging import error, warning
|
||||
import re
|
||||
|
||||
from weboob.capabilities.video import Video
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
from ..video import YoujizzVideo
|
||||
|
||||
class VideoPage(BasePage):
|
||||
URL_REGEX = re.compile(r'http://.*youjizz\.com/videos/.+-(\d+)\.html')
|
||||
VIDEO_FILE_REGEX = re.compile(r'"(http://media[^ ,]+\.flv)"')
|
||||
|
||||
def on_loaded(self):
|
||||
details = self.get_details()
|
||||
self.video = Video(_id=self.get_id(), title=details.get('title', u''), url=self.get_url(),
|
||||
duration=details.get('duration', 0), nsfw=True)
|
||||
self.video = YoujizzVideo(_id=self.get_id(), title=details.get('title', u''), url=self.get_url(),
|
||||
duration=details.get('duration', 0), nsfw=True)
|
||||
|
||||
def get_id(self):
|
||||
m = self.URL_REGEX.match(self.url)
|
||||
|
|
|
|||
|
|
@ -18,5 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
"""
|
||||
|
||||
def id2url(_id):
|
||||
return 'http://www.youjizz.com/videos/%s.html' % _id
|
||||
from weboob.capabilities.video import BaseVideo
|
||||
|
||||
class YoujizzVideo(BaseVideo):
|
||||
@classmethod
|
||||
def id2url(cls, _id):
|
||||
return 'http://www.youjizz.com/videos/%s.html' % _id
|
||||
Loading…
Add table
Add a link
Reference in a new issue