# -*- 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. import re import urllib from logging import warning from weboob.tools.browser import BaseBrowser, BrowserUnavailable from weboob.tools.browser.decorators import check_domain, id2url from .pages.index import IndexPage from .video import YoujizzVideo __all__ = ['YoujizzBrowser'] class YoujizzBrowser(BaseBrowser): DOMAIN = 'youjizz.com' PROTOCOL = 'http' PAGES = {r'http://.*youjizz\.com/?': IndexPage, r'http://.*youjizz\.com/search/.+\.html': IndexPage, } @id2url(YoujizzVideo.id2url) def get_video(self, url): try: data = self.openurl(url).read() except BrowserUnavailable: return None def _get_url(): video_file_urls = re.findall(r'"(http://media[^ ,]+\.flv)"', data) if len(video_file_urls) == 0: return None else: if len(video_file_urls) > 1: warning('Many video file URL found for given URL: %s' % video_file_urls) return video_file_urls[0] m = re.search(r'http://.*youjizz\.com/videos/(.+)\.html', url) _id = unicode(m.group(1)) if m else None m = re.search(r'