]>
Commit | Line | Data |
---|---|---|
6f90d098 PH |
1 | from __future__ import unicode_literals |
2 | ||
15369766 PH |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
1cc79574 | 6 | from ..compat import ( |
15369766 | 7 | compat_urllib_parse, |
1cc79574 PH |
8 | ) |
9 | from ..utils import ( | |
15369766 PH |
10 | ExtractorError, |
11 | ) | |
12 | ||
13 | ||
14 | class EscapistIE(InfoExtractor): | |
6f90d098 | 15 | _VALID_URL = r'^https?://?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<id>[0-9]+)-' |
6f5ac90c | 16 | _TEST = { |
6f90d098 PH |
17 | 'url': 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate', |
18 | 'md5': 'ab3a706c681efca53f0a35f1415cf0d1', | |
19 | 'info_dict': { | |
20 | 'id': '6618', | |
21 | 'ext': 'mp4', | |
22 | 'description': "Baldur's Gate: Original, Modded or Enhanced Edition? I'll break down what you can expect from the new Baldur's Gate: Enhanced Edition.", | |
23 | 'uploader': 'the-escapist-presents', | |
24 | 'title': "Breaking Down Baldur's Gate", | |
6f5ac90c PH |
25 | } |
26 | } | |
15369766 PH |
27 | |
28 | def _real_extract(self, url): | |
29 | mobj = re.match(self._VALID_URL, url) | |
15369766 | 30 | showName = mobj.group('showname') |
6f90d098 | 31 | video_id = mobj.group('id') |
15369766 | 32 | |
6f90d098 PH |
33 | self.report_extraction(video_id) |
34 | webpage = self._download_webpage(url, video_id) | |
15369766 | 35 | |
100959a6 PH |
36 | videoDesc = self._html_search_regex( |
37 | r'<meta name="description" content="([^"]*)"', | |
6f90d098 | 38 | webpage, 'description', fatal=False) |
15369766 | 39 | |
a3681973 | 40 | playerUrl = self._og_search_video_url(webpage, name='player URL') |
15369766 | 41 | |
100959a6 | 42 | title = self._html_search_regex( |
da6a795f | 43 | r'<meta name="title" content="([^"]*)"', |
6f90d098 | 44 | webpage, 'title').split(' : ')[-1] |
15369766 | 45 | |
6f90d098 | 46 | configUrl = self._search_regex('config=(.*)$', playerUrl, 'config URL') |
15369766 PH |
47 | configUrl = compat_urllib_parse.unquote(configUrl) |
48 | ||
100959a6 | 49 | formats = [] |
15369766 | 50 | |
6f90d098 PH |
51 | def _add_format(name, cfgurl, quality): |
52 | config = self._download_json( | |
53 | cfgurl, video_id, | |
54 | 'Downloading ' + name + ' configuration', | |
55 | 'Unable to download ' + name + ' configuration', | |
56 | transform_source=lambda s: s.replace("'", '"')) | |
15369766 | 57 | |
100959a6 PH |
58 | playlist = config['playlist'] |
59 | formats.append({ | |
60 | 'url': playlist[1]['url'], | |
61 | 'format_id': name, | |
6f90d098 | 62 | 'quality': quality, |
100959a6 | 63 | }) |
15369766 | 64 | |
6f90d098 | 65 | _add_format('normal', configUrl, quality=0) |
15ff3c83 PH |
66 | hq_url = (configUrl + |
67 | ('&hq=1' if '?' in configUrl else configUrl + '?hq=1')) | |
100959a6 | 68 | try: |
6f90d098 | 69 | _add_format('hq', hq_url, quality=1) |
15ff3c83 PH |
70 | except ExtractorError: |
71 | pass # That's fine, we'll just use normal quality | |
100959a6 | 72 | |
6f90d098 PH |
73 | self._sort_formats(formats) |
74 | ||
100959a6 | 75 | return { |
6f90d098 | 76 | 'id': video_id, |
100959a6 | 77 | 'formats': formats, |
15369766 | 78 | 'uploader': showName, |
15369766 | 79 | 'title': title, |
46720279 | 80 | 'thumbnail': self._og_search_thumbnail(webpage), |
15369766 PH |
81 | 'description': videoDesc, |
82 | 'player_url': playerUrl, | |
83 | } |