1 from __future__ import unicode_literals
5 from .common import InfoExtractor
13 class EscapistIE(InfoExtractor):
14 _VALID_URL = r'^https?://?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<id>[0-9]+)-'
16 'url': 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate',
17 'md5': 'ab3a706c681efca53f0a35f1415cf0d1',
21 '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.",
22 'uploader': 'the-escapist-presents',
23 'title': "Breaking Down Baldur's Gate",
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 showName = mobj.group('showname')
30 video_id = mobj.group('id')
32 self.report_extraction(video_id)
33 webpage = self._download_webpage(url, video_id)
35 videoDesc = self._html_search_regex(
36 r'<meta name="description" content="([^"]*)"',
37 webpage, 'description', fatal=False)
39 playerUrl = self._og_search_video_url(webpage, name='player URL')
41 title = self._html_search_regex(
42 r'<meta name="title" content="([^"]*)"',
43 webpage, 'title').split(' : ')[-1]
45 configUrl = self._search_regex('config=(.*)$', playerUrl, 'config URL')
46 configUrl = compat_urllib_parse.unquote(configUrl)
50 def _add_format(name, cfgurl, quality):
51 config = self._download_json(
53 'Downloading ' + name + ' configuration',
54 'Unable to download ' + name + ' configuration',
55 transform_source=lambda s: s.replace("'", '"'))
57 playlist = config['playlist']
59 'url': playlist[1]['url'],
64 _add_format('normal', configUrl, quality=0)
66 ('&hq=1' if '?' in configUrl else configUrl + '?hq=1'))
68 _add_format('hq', hq_url, quality=1)
69 except ExtractorError:
70 pass # That's fine, we'll just use normal quality
72 self._sort_formats(formats)
79 'thumbnail': self._og_search_thumbnail(webpage),
80 'description': videoDesc,
81 'player_url': playerUrl,