rewrite video decorators to be in browser

This commit is contained in:
Christophe Benz 2010-05-20 11:46:00 +02:00 committed by Romain Bignon
commit 0de0f2a768
19 changed files with 167 additions and 119 deletions

View file

@ -1,21 +1,18 @@
# -*- coding: utf-8 -*-
"""
Copyright(C) 2010 Roger Philibert
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.
"""
# Copyright(C) 2010 Roger Philibert
#
# 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 .backend import YoujizzBackend

View file

@ -16,7 +16,7 @@
# 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 YoujizzBrowser
@ -36,13 +36,10 @@ class YoujizzBackend(BaseBackend, ICapVideoProvider):
CONFIG = {}
BROWSER = YoujizzBrowser
domain = u'youjizz.com'
@id2url(domain, YoujizzVideo.id2url)
def get_video(self, _id):
return self.browser.get_video(_id)
@check_domain(domain)
def iter_page_urls(self, mozaic_url):
return self.browser.iter_page_urls(mozaic_url)

View file

@ -21,6 +21,7 @@ import urllib
from logging import warning
from weboob.tools.browser import BaseBrowser
from weboob.tools.browser.decorators import check_domain, id2url
from .pages.index import IndexPage
from .video import YoujizzVideo
@ -36,6 +37,7 @@ class YoujizzBrowser(BaseBrowser):
r'http://.*youjizz\.com/search/.+\.html': IndexPage,
}
@id2url(YoujizzVideo.id2url)
def get_video(self, url):
data = self.openurl(url).read()
def _get_url():
@ -56,8 +58,9 @@ class YoujizzBrowser(BaseBrowser):
duration = minutes * 60 + seconds
else:
duration = 0
return YoujizzVideo(_id=u'youjizz:%s' % _id, title=title, url=_get_url(), duration=duration, nsfw=True)
return YoujizzVideo(_id=_id, title=title, url=_get_url(), duration=duration, nsfw=True)
@check_domain
def iter_page_urls(self, mozaic_url):
raise NotImplementedError()

View file

@ -54,7 +54,7 @@ class IndexPage(BasePage):
minutes, seconds = time_span.text.strip().split(':')
duration = 60 * int(minutes) + int(seconds)
yield YoujizzVideo(u'youjizz:%s' % _id,
yield YoujizzVideo(_id,
title=title,
duration=duration,
thumbnail_url=thumbnail_url,

View file

@ -23,6 +23,10 @@ __all__ = ['YoujizzVideo']
class YoujizzVideo(BaseVideo):
def __init__(self, *args, **kwargs):
BaseVideo.__init__(self, *args, **kwargs)
self.id = u'%s@youjizz.com' % self.id
@classmethod
def id2url(cls, _id):
return 'http://www.youjizz.com/videos/%s.html' % _id