move id2url to tools

This commit is contained in:
Christophe Benz 2010-04-27 12:19:48 +02:00 committed by Romain Bignon
commit 0667774952
12 changed files with 119 additions and 18 deletions

View file

@ -23,6 +23,10 @@ from weboob.capabilities.video import ICapVideoProvider
from .browser import YoujizzBrowser
__all__ = ['YoujizzBackend']
class YoujizzBackend(BaseBackend, ICapVideoProvider):
NAME = 'youjizz'
MAINTAINER = 'Roger Philibert'
@ -41,6 +45,10 @@ 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]

View file

@ -37,9 +37,6 @@ class YoujizzBrowser(BaseBrowser):
r'http://.*youjizz\.com/search/.+\.html': IndexPage,
}
def id2url(self, _id):
return 'http://www.youjizz.com/videos/%s.html' % _id
def get_video(self, url):
self.location(url)
return self.page.video

View file

@ -23,6 +23,8 @@ import re
from weboob.capabilities.video import Video
from weboob.tools.browser import BasePage
from .. import tools
__all__ = ['IndexPage']
@ -59,4 +61,5 @@ class IndexPage(BasePage):
title=title,
duration=duration,
preview_url=preview_url,
nsfw=True)
nsfw=True,
id2url=tools.id2url)

View file

@ -0,0 +1,22 @@
# -*- 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.
"""
def id2url(_id):
return 'http://www.youjizz.com/videos/%s.html' % _id