X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fwebsurg.py;h=43953bfdd566c2a17b58c124f92ad7dab5c2312b;hb=eeb165e674e07aaa798f69e15f16faa01bc8feaa;hp=953bc983131e15c317782cf85e8115cd75464605;hpb=d79a0e233a329e543797478a2eeb377e469c0f3f;p=youtube-dl diff --git a/youtube_dl/extractor/websurg.py b/youtube_dl/extractor/websurg.py index 953bc9831..43953bfdd 100644 --- a/youtube_dl/extractor/websurg.py +++ b/youtube_dl/extractor/websurg.py @@ -18,12 +18,13 @@ class WeBSurgIE(InfoExtractor): u'file': u'vd01en4012.mp4', u'params': { u'skip_download': True, - } + }, + u'skip': u'Requires login information', } _LOGIN_URL = 'http://www.websurg.com/inc/login/login_div.ajax.php?login=1' - def _real_extract(self, url): + def _real_initialize(self): login_form = { 'username': self._downloader.params['username'], @@ -35,33 +36,24 @@ class WeBSurgIE(InfoExtractor): self._LOGIN_URL, compat_urllib_parse.urlencode(login_form)) request.add_header( 'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8') - login_results = compat_urllib_request.urlopen(request).info() + compat_urllib_request.urlopen(request).info() + webpage = self._download_webpage(self._LOGIN_URL, '', 'Logging in') - sessid = re.match(r'PHPSESSID=(.*);', - login_results['Set-Cookie']).group(1) - request = compat_urllib_request.Request( - url, compat_urllib_parse.urlencode(login_form), - {'Cookie': 'PHPSESSID=' + sessid + ';'}) - webpage = compat_urllib_request.urlopen(request).read() + if webpage != 'OK': + self._downloader.report_error( + u'Unable to log in: bad username/password') + def _real_extract(self, url): video_id = re.match(self._VALID_URL, url).group(1) + webpage = self._download_webpage(url, video_id) + url_info = re.search(r'streamer="(.*?)" src="(.*?)"', webpage) - if url_info is None: - self._downloader.report_warning( - u'Unable to log in: bad username/password') - return - return {'id': video_id, - 'title' : re.search( - r'property="og:title" content="(.*?)" />' - , webpage).group(1), - 'description': re.search( - r'name="description" content="(.*?)" />', webpage).group(1), + 'title': self._og_search_title(webpage), + 'description': self._og_search_description(webpage), 'ext' : 'mp4', 'url' : url_info.group(1) + '/' + url_info.group(2), - 'thumbnail': re.search( - r'property="og:image" content="(.*?)" />', webpage - ).group(1) + 'thumbnail': self._og_search_thumbnail(webpage) }