You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yt-dlp/youtube_dl/extractor/websurg.py

61 lines
1.9 KiB
Python

# coding: utf-8
import re
from ..utils import (
compat_urllib_request,
compat_urllib_parse
)
from .common import InfoExtractor
class WeBSurgIE(InfoExtractor):
IE_NAME = u'websurg.com'
_VALID_URL = r'http://.*?\.websurg\.com/MEDIA/\?noheader=1&doi=(.*)'
_TEST = {
u'url': u'http://www.websurg.com/MEDIA/?noheader=1&doi=vd01en4012',
u'file': u'vd01en4012.mp4',
u'params': {
u'skip_download': True,
}
}
_LOGIN_URL = 'http://www.websurg.com/inc/login/login_div.ajax.php?login=1'
11 years ago
def _real_initialize(self):
login_form = {
'username': self._downloader.params['username'],
'password': self._downloader.params['password'],
'Submit': 1
}
request = compat_urllib_request.Request(
self._LOGIN_URL, compat_urllib_parse.urlencode(login_form))
request.add_header(
'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8')
11 years ago
compat_urllib_request.urlopen(request).info()
11 years ago
def _real_extract(self, url):
request = compat_urllib_request.Request(url)
webpage = unicode(
compat_urllib_request.urlopen(request).read(), 'utf-8')
video_id = re.match(self._VALID_URL, url).group(1)
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,
11 years ago
'title': self._og_search_title(webpage),
'description': self._og_search_description(webpage),
'ext' : 'mp4',
'url' : url_info.group(1) + '/' + url_info.group(2),
11 years ago
'thumbnail': self._og_search_thumbnail(webpage)
}