]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/websurg.py
Update changelog.
[youtubedl] / youtube_dl / extractor / websurg.py
1 # coding: utf-8
2
3 import re
4
5 from ..utils import (
6 compat_urllib_request,
7 compat_urllib_parse
8 )
9
10 from .common import InfoExtractor
11
12 class WeBSurgIE(InfoExtractor):
13 IE_NAME = u'websurg.com'
14 _VALID_URL = r'http://.*?\.websurg\.com/MEDIA/\?noheader=1&doi=(.*)'
15
16 _TEST = {
17 u'url': u'http://www.websurg.com/MEDIA/?noheader=1&doi=vd01en4012',
18 u'file': u'vd01en4012.mp4',
19 u'params': {
20 u'skip_download': True,
21 },
22 u'skip': u'Requires login information',
23 }
24
25 _LOGIN_URL = 'http://www.websurg.com/inc/login/login_div.ajax.php?login=1'
26
27 def _real_initialize(self):
28
29 login_form = {
30 'username': self._downloader.params['username'],
31 'password': self._downloader.params['password'],
32 'Submit': 1
33 }
34
35 request = compat_urllib_request.Request(
36 self._LOGIN_URL, compat_urllib_parse.urlencode(login_form))
37 request.add_header(
38 'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8')
39 compat_urllib_request.urlopen(request).info()
40 webpage = self._download_webpage(self._LOGIN_URL, '', 'Logging in')
41
42 if webpage != 'OK':
43 self._downloader.report_error(
44 u'Unable to log in: bad username/password')
45
46 def _real_extract(self, url):
47 video_id = re.match(self._VALID_URL, url).group(1)
48
49 webpage = self._download_webpage(url, video_id)
50
51 url_info = re.search(r'streamer="(.*?)" src="(.*?)"', webpage)
52
53 return {'id': video_id,
54 'title': self._og_search_title(webpage),
55 'description': self._og_search_description(webpage),
56 'ext' : 'mp4',
57 'url' : url_info.group(1) + '/' + url_info.group(2),
58 'thumbnail': self._og_search_thumbnail(webpage)
59 }