1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-12-01 10:12:54 +01:00

Improvements

This commit is contained in:
Pierre Rudloff 2013-09-18 00:07:04 +02:00
parent 8f77093262
commit cc6943e86a

View File

@ -23,7 +23,7 @@ class WeBSurgIE(InfoExtractor):
_LOGIN_URL = 'http://www.websurg.com/inc/login/login_div.ajax.php?login=1' _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 = { login_form = {
'username': self._downloader.params['username'], 'username': self._downloader.params['username'],
@ -35,14 +35,13 @@ class WeBSurgIE(InfoExtractor):
self._LOGIN_URL, compat_urllib_parse.urlencode(login_form)) self._LOGIN_URL, compat_urllib_parse.urlencode(login_form))
request.add_header( request.add_header(
'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8') 'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8')
login_results = compat_urllib_request.urlopen(request).info() compat_urllib_request.urlopen(request).info()
sessid = re.match(r'PHPSESSID=(.*);', def _real_extract(self, url):
login_results['Set-Cookie']).group(1)
request = compat_urllib_request.Request( request = compat_urllib_request.Request(url)
url, compat_urllib_parse.urlencode(login_form), webpage = unicode(
{'Cookie': 'PHPSESSID=' + sessid + ';'}) compat_urllib_request.urlopen(request).read(), 'utf-8')
webpage = compat_urllib_request.urlopen(request).read()
video_id = re.match(self._VALID_URL, url).group(1) video_id = re.match(self._VALID_URL, url).group(1)
@ -52,16 +51,10 @@ class WeBSurgIE(InfoExtractor):
self._downloader.report_warning( self._downloader.report_warning(
u'Unable to log in: bad username/password') u'Unable to log in: bad username/password')
return return
return {'id': video_id, return {'id': video_id,
'title' : re.search( 'title': self._og_search_title(webpage),
r'property="og:title" content="(.*?)" />' 'description': self._og_search_description(webpage),
, webpage).group(1),
'description': re.search(
r'name="description" content="(.*?)" />', webpage).group(1),
'ext' : 'mp4', 'ext' : 'mp4',
'url' : url_info.group(1) + '/' + url_info.group(2), 'url' : url_info.group(1) + '/' + url_info.group(2),
'thumbnail': re.search( 'thumbnail': self._og_search_thumbnail(webpage)
r'property="og:image" content="(.*?)" />', webpage
).group(1)
} }