diff --git a/weboob/backend.py b/weboob/backend.py index 84e7e4e3..dfc22bb5 100644 --- a/weboob/backend.py +++ b/weboob/backend.py @@ -115,3 +115,36 @@ class BaseBackend(object): if isinstance(self, c): return True return False + + +def check_domain(domain): + def wrapper(func): + def inner(self, *args, **kwargs): + url = args[0] + if isinstance(url, (str,unicode)) and not url.isdigit() and u'youjizz.com' not in url: + return None + return func(self, *args, **kwargs) + return inner + return wrapper + + +def id2url(domain, id2url): + def wrapper(func): + def inner(self, *args, **kwargs): + arg = unicode(args[0]) + if arg.startswith('http://'): + if domain in arg: + url = arg + else: + return None + else: + provider, _id = arg.split(':') + if provider == self.name: + url = id2url(_id) + else: + return None + new_args = [url] + new_args.extend(args[1:]) + return func(self, *new_args, **kwargs) + return inner + return wrapper diff --git a/weboob/backends/youjizz/backend.py b/weboob/backends/youjizz/backend.py index 3b333eec..f43cd792 100644 --- a/weboob/backends/youjizz/backend.py +++ b/weboob/backends/youjizz/backend.py @@ -1,27 +1,26 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Roger Philibert +# 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. -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.backend import BaseBackend +from weboob.backend import check_domain, id2url, BaseBackend from weboob.capabilities.video import ICapVideoProvider from .browser import YoujizzBrowser +from .video import YoujizzVideo __all__ = ['YoujizzBackend'] @@ -37,6 +36,7 @@ class YoujizzBackend(BaseBackend, ICapVideoProvider): CONFIG = {} _browser = None + domain = u'youjizz.com' def __getattr__(self, name): if name == 'browser': @@ -45,19 +45,11 @@ class YoujizzBackend(BaseBackend, ICapVideoProvider): return self._browser raise AttributeError, name - def check_url(func): - def inner(self, *args, **kwargs): - url = args[0] - if isinstance(url, (str,unicode)) and not url.isdigit() and u'youjizz.com' not in url: - return None - return func(self, *args, **kwargs) - return inner - - @check_url + @id2url(domain, YoujizzVideo.id2url) def get_video(self, _id): return self.browser.get_video(_id) - @check_url + @check_domain(domain) def iter_page_urls(self, mozaic_url): return self.browser.iter_page_urls(mozaic_url) diff --git a/weboob/backends/youjizz/pages/index.py b/weboob/backends/youjizz/pages/index.py index fc1268d8..a8c09fa8 100644 --- a/weboob/backends/youjizz/pages/index.py +++ b/weboob/backends/youjizz/pages/index.py @@ -1,22 +1,20 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Roger Philibert +# 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. -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. - -""" import re @@ -56,7 +54,7 @@ class IndexPage(BasePage): minutes, seconds = time_span.text.strip().split(':') duration = 60 * int(minutes) + int(seconds) - yield YoujizzVideo(_id, + yield YoujizzVideo(u'youjizz:%s' % _id, title=title, duration=duration, thumbnail_url=thumbnail_url, diff --git a/weboob/backends/youjizz/video.py b/weboob/backends/youjizz/video.py index e65da5f3..a6ff82e6 100644 --- a/weboob/backends/youjizz/video.py +++ b/weboob/backends/youjizz/video.py @@ -1,25 +1,27 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Roger Philibert +# 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. -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.capabilities.video import BaseVideo + +__all__ = ['YoujizzVideo'] + + class YoujizzVideo(BaseVideo): @classmethod def id2url(cls, _id): diff --git a/weboob/backends/youporn/backend.py b/weboob/backends/youporn/backend.py index 5452696e..3adf4204 100644 --- a/weboob/backends/youporn/backend.py +++ b/weboob/backends/youporn/backend.py @@ -1,27 +1,26 @@ # -*- 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.backend import BaseBackend +from weboob.backend import check_domain, id2url, BaseBackend from weboob.capabilities.video import ICapVideoProvider from .browser import YoupornBrowser +from .video import YoupornVideo __all__ = ['YoupornBackend'] @@ -37,6 +36,7 @@ class YoupornBackend(BaseBackend, ICapVideoProvider): CONFIG = {} _browser = None + domain = u'youporn.com' def __getattr__(self, name): if name == 'browser': @@ -45,15 +45,7 @@ class YoupornBackend(BaseBackend, ICapVideoProvider): return self._browser raise AttributeError, name - def need_url(func): - def inner(self, *args, **kwargs): - url = args[0] - if isinstance(url, (str,unicode)) and not url.isdigit() and u'youporn.com' not in url: - return None - return func(self, *args, **kwargs) - return inner - - @need_url + @id2url(domain, YoupornVideo.id2url) def get_video(self, _id): return self.browser.get_video(_id) @@ -63,6 +55,6 @@ class YoupornBackend(BaseBackend, ICapVideoProvider): return iter(set()) return self.browser.iter_search_results(pattern, self.SORTBY[sortby]) - @need_url + @check_domain(domain) def iter_page_urls(self, mozaic_url): raise NotImplementedError() diff --git a/weboob/backends/youporn/browser.py b/weboob/backends/youporn/browser.py index af924b2b..ba82219b 100644 --- a/weboob/backends/youporn/browser.py +++ b/weboob/backends/youporn/browser.py @@ -50,6 +50,6 @@ class YoupornBrowser(BaseBrowser): assert self.is_on_page(IndexPage) return self.page.iter_videos() - def get_video(self, _id): - self.location(YoupornVideo.id2url(_id)) + def get_video(self, url): + self.location(url) return self.page.video diff --git a/weboob/backends/youporn/pages/index.py b/weboob/backends/youporn/pages/index.py index 25d1def0..f8a21611 100644 --- a/weboob/backends/youporn/pages/index.py +++ b/weboob/backends/youporn/pages/index.py @@ -64,7 +64,7 @@ class IndexPage(PornPage): rating = float(p.text.strip()) rating_max = float(p.find('span').text.strip()[2:]) - yield YoupornVideo(int(_id), + yield YoupornVideo('youporn:%d' % int(_id), title=title, rating=rating, rating_max=rating_max, diff --git a/weboob/backends/youporn/pages/video.py b/weboob/backends/youporn/pages/video.py index 92ab8320..530aa539 100644 --- a/weboob/backends/youporn/pages/video.py +++ b/weboob/backends/youporn/pages/video.py @@ -32,7 +32,7 @@ class VideoPage(PornPage): if not PornPage.on_loaded(self): return - self.video = YoupornVideo(self.get_id(), + self.video = YoupornVideo('youporn:%d' % self.get_id(), self.get_title(), self.get_url(), nsfw=True) diff --git a/weboob/backends/youporn/video.py b/weboob/backends/youporn/video.py index 1fd18a14..b983a984 100644 --- a/weboob/backends/youporn/video.py +++ b/weboob/backends/youporn/video.py @@ -1,29 +1,28 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Roger Philibert +# 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. -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.capabilities.video import BaseVideo + +__all__ = ['YoupornVideo'] + + class YoupornVideo(BaseVideo): @classmethod def id2url(cls, _id): - if isinstance(_id, int) or isinstance(_id, (str,unicode)) and _id.isdigit(): - return 'http://www.youporn.com/watch/%d' % int(_id) - else: - return str(_id) + return 'http://www.youporn.com/watch/%d' % int(_id) diff --git a/weboob/backends/youtube/__init__.py b/weboob/backends/youtube/__init__.py index cdaca2fd..9b6c1140 100644 --- a/weboob/backends/youtube/__init__.py +++ b/weboob/backends/youtube/__init__.py @@ -1,21 +1,18 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Christophe Benz - -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 Christophe Benz +# +# 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 YoutubeBackend diff --git a/weboob/backends/youtube/backend.py b/weboob/backends/youtube/backend.py index 5d91b1ef..ca48fcc1 100644 --- a/weboob/backends/youtube/backend.py +++ b/weboob/backends/youtube/backend.py @@ -1,26 +1,24 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Christophe Benz, Romain Bignon +# Copyright(C) 2010 Christophe Benz, 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. - -""" import logging -from weboob.backend import BaseBackend +from weboob.backend import check_domain, id2url, BaseBackend from weboob.capabilities.video import ICapVideoProvider from .browser import YoutubeBrowser @@ -40,6 +38,7 @@ class YoutubeBackend(BaseBackend, ICapVideoProvider): CONFIG = {} _browser = None + domain = u'youtube.com' def __getattr__(self, name): if name == 'browser': @@ -48,6 +47,7 @@ class YoutubeBackend(BaseBackend, ICapVideoProvider): return self._browser raise AttributeError, name + @id2url(domain, YoutubeVideo.id2url) def get_video(self, _id): return self.browser.get_video(_id) @@ -69,11 +69,12 @@ class YoutubeBackend(BaseBackend, ICapVideoProvider): author = entry.media.name.text.decode('utf-8').strip() else: author = None - yield YoutubeVideo(entry.id.text.split('/')[-1].decode('utf-8'), + yield YoutubeVideo(u'youtube:%s' % entry.id.text.split('/')[-1].decode('utf-8'), title=entry.media.title.text.decode('utf-8').strip(), author=author, duration=int(entry.media.duration.seconds.decode('utf-8').strip()), thumbnail_url=entry.media.thumbnail[0].url.decode('utf-8').strip()) + @check_domain(domain) def iter_page_urls(self, mozaic_url): raise NotImplementedError() diff --git a/weboob/backends/youtube/browser.py b/weboob/backends/youtube/browser.py index 707f9c8a..6451cfec 100644 --- a/weboob/backends/youtube/browser.py +++ b/weboob/backends/youtube/browser.py @@ -1,34 +1,34 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Christophe Benz, Romain Bignon +# Copyright(C) 2010 Christophe Benz, 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 .pages import VideoPage from .video import YoutubeVideo + __all__ = ['YoutubeBrowser'] + class YoutubeBrowser(BaseBrowser): PAGES = {'.*youtube\.com/watch\?v=(.+)': VideoPage, } - def get_video(self, _id): - self.location(YoutubeVideo.id2url(_id)) + def get_video(self, url): + self.location(url) return self.page.video diff --git a/weboob/backends/youtube/pages/__init__.py b/weboob/backends/youtube/pages/__init__.py index 7d739457..96e4eade 100644 --- a/weboob/backends/youtube/pages/__init__.py +++ b/weboob/backends/youtube/pages/__init__.py @@ -1,21 +1,18 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Christophe Benz - -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 Christophe Benz +# +# 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 .video import VideoPage diff --git a/weboob/backends/youtube/pages/video.py b/weboob/backends/youtube/pages/video.py index 70037edc..c939a97e 100644 --- a/weboob/backends/youtube/pages/video.py +++ b/weboob/backends/youtube/pages/video.py @@ -1,22 +1,20 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Christophe Benz, Romain Bignon +# Copyright(C) 2010 Christophe Benz, 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. - -""" import re from logging import warning @@ -26,12 +24,15 @@ from weboob.tools.browser import BasePage from ..video import YoutubeVideo +__all__ = ['VideoPage'] + + class VideoPage(BasePage): URL_REGEX = re.compile(r"https?://[w\.]*youtube.com/watch\?v=(.+)") VIDEO_SIGNATURE_REGEX = re.compile(r'&t=([^ ,&]*)') def on_loaded(self): - self.video = YoutubeVideo(self.get_id()) + self.video = YoutubeVideo(u'youtube:%s' % self.get_id()) self.video.title = self.get_title() self.video.url = self.get_url() self.set_details(self.video) diff --git a/weboob/backends/youtube/video.py b/weboob/backends/youtube/video.py index 989ef447..a2176c64 100644 --- a/weboob/backends/youtube/video.py +++ b/weboob/backends/youtube/video.py @@ -1,26 +1,28 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Christophe Benz +# Copyright(C) 2010 Christophe Benz +# +# 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.capabilities.video import BaseVideo + +__all__ = ['YoutubeVideo'] + + class YoutubeVideo(BaseVideo): @classmethod def id2url(cls, _id): - return _id if 'youtube.com' in _id else 'http://www.youtube.com/watch?v=%s' % _id + return 'http://www.youtube.com/watch?v=%s' % _id diff --git a/weboob/capabilities/video.py b/weboob/capabilities/video.py index c8885295..fe9d4dee 100644 --- a/weboob/capabilities/video.py +++ b/weboob/capabilities/video.py @@ -49,7 +49,7 @@ class BaseVideo(object): @property def page_url(self): - return self.id2url(self.id) + return self.id2url(self.id.split(':')[1]) class ICapVideoProvider(ICap):