rewrite video decorators to be in browser
This commit is contained in:
parent
83ec57629b
commit
0de0f2a768
19 changed files with 167 additions and 119 deletions
|
|
@ -16,11 +16,10 @@
|
|||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
from weboob.backend import check_domain, id2url, BaseBackend
|
||||
from weboob.backend import BaseBackend
|
||||
from weboob.capabilities.video import ICapVideoProvider
|
||||
|
||||
from .browser import YoupornBrowser
|
||||
from .video import YoupornVideo
|
||||
|
||||
|
||||
__all__ = ['YoupornBackend']
|
||||
|
|
@ -38,7 +37,6 @@ class YoupornBackend(BaseBackend, ICapVideoProvider):
|
|||
BROWSER = YoupornBrowser
|
||||
domain = u'youporn.com'
|
||||
|
||||
@id2url(domain, YoupornVideo.id2url)
|
||||
def get_video(self, _id):
|
||||
return self.browser.get_video(_id)
|
||||
|
||||
|
|
@ -48,6 +46,5 @@ class YoupornBackend(BaseBackend, ICapVideoProvider):
|
|||
return iter(set())
|
||||
return self.browser.iter_search_results(pattern, self.SORTBY[sortby])
|
||||
|
||||
@check_domain(domain)
|
||||
def iter_page_urls(self, mozaic_url):
|
||||
raise NotImplementedError()
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2010 Romain Bignon
|
||||
# Copyright(C) 2010 Romain Bignon
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, version 3 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
"""
|
||||
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
from weboob.tools.browser.decorators import id2url
|
||||
|
||||
from .pages.index import IndexPage
|
||||
from .pages.video import VideoPage
|
||||
from .video import YoupornVideo
|
||||
|
||||
|
||||
__all__ = ['YoupornBrowser']
|
||||
|
|
@ -49,6 +49,7 @@ class YoupornBrowser(BaseBrowser):
|
|||
assert self.is_on_page(IndexPage)
|
||||
return self.page.iter_videos()
|
||||
|
||||
@id2url(YoupornVideo.id2url)
|
||||
def get_video(self, url):
|
||||
self.location(url)
|
||||
return self.page.video
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class IndexPage(PornPage):
|
|||
rating = float(p.text.strip())
|
||||
rating_max = float(p.find('span').text.strip()[2:])
|
||||
|
||||
yield YoupornVideo('youporn:%d' % int(_id),
|
||||
yield YoupornVideo(int(_id),
|
||||
title=title,
|
||||
rating=rating,
|
||||
rating_max=rating_max,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class VideoPage(PornPage):
|
|||
if not PornPage.on_loaded(self):
|
||||
return
|
||||
|
||||
self.video = YoupornVideo('youporn:%d' % self.get_id(),
|
||||
self.video = YoupornVideo(self.get_id(),
|
||||
self.get_title(),
|
||||
self.get_url(),
|
||||
nsfw=True)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ __all__ = ['YoupornVideo']
|
|||
|
||||
|
||||
class YoupornVideo(BaseVideo):
|
||||
def __init__(self, *args, **kwargs):
|
||||
BaseVideo.__init__(self, *args, **kwargs)
|
||||
self.id = u'%s@youporn.com' % self.id
|
||||
|
||||
@classmethod
|
||||
def id2url(cls, _id):
|
||||
return 'http://www.youporn.com/watch/%d' % int(_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue