]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/wayofthemaster.py
[videolecturesnet] Check http format URLs (Closes #4968)
[youtube-dl] / youtube_dl / extractor / wayofthemaster.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class WayOfTheMasterIE(InfoExtractor):
9     _VALID_URL = r'https?://www\.wayofthemaster\.com/([^/?#]*/)*(?P<id>[^/?#]+)\.s?html(?:$|[?#])'
10
11     _TEST = {
12         'url': 'http://www.wayofthemaster.com/hbks.shtml',
13         'md5': '5316b57487ada8480606a93cb3d18d24',
14         'info_dict': {
15             'id': 'hbks',
16             'ext': 'mp4',
17             'title': 'Intelligent Design vs. Evolution',
18         },
19     }
20
21     def _real_extract(self, url):
22         mobj = re.match(self._VALID_URL, url)
23         video_id = mobj.group('id')
24
25         webpage = self._download_webpage(url, video_id)
26
27         title = self._search_regex(
28             r'<img src="images/title_[^"]+".*?alt="([^"]+)"',
29             webpage, 'title', default=None)
30         if title is None:
31             title = self._html_search_regex(
32                 r'<title>(.*?)</title>', webpage, 'page title')
33
34         url_base = self._search_regex(
35             r'<param\s+name="?movie"?\s+value=".*?/wotm_videoplayer_highlow[0-9]*\.swf\?vid=([^"]+)"',
36             webpage, 'URL base')
37         formats = [{
38             'format_id': 'low',
39             'quality': 1,
40             'url': url_base + '_low.mp4',
41         }, {
42             'format_id': 'high',
43             'quality': 2,
44             'url': url_base + '_high.mp4',
45         }]
46         self._sort_formats(formats)
47
48         return {
49             'id': video_id,
50             'title': title,
51             'formats': formats,
52         }