1 from __future__ import unicode_literals
5 from .common import InfoExtractor
14 class EscapistIE(InfoExtractor):
15 _VALID_URL = r'^https?://?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<id>[0-9]+)-'
17 'url': 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate',
18 'md5': 'ab3a706c681efca53f0a35f1415cf0d1',
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",
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 showName = mobj.group('showname')
31 video_id = mobj.group('id')
33 self.report_extraction(video_id)
34 webpage = self._download_webpage(url, video_id)
36 videoDesc = self._html_search_regex(
37 r'<meta name="description" content="([^"]*)"',
38 webpage, 'description', fatal=False)
40 playerUrl = self._og_search_video_url(webpage, name='player URL')
42 title = self._html_search_regex(
43 r'<meta name="title" content="([^"]*)"',
44 webpage, 'title').split(' : ')[-1]
46 configUrl = self._search_regex('config=(.*)$', playerUrl, 'config URL')
47 configUrl = compat_urllib_parse.unquote(configUrl)
51 def _add_format(name, cfgurl, quality):
52 config = self._download_json(
54 'Downloading ' + name + ' configuration',
55 'Unable to download ' + name + ' configuration',
56 transform_source=lambda s: s.replace("'", '"'))
58 playlist = config['playlist']
60 'url': playlist[1]['url'],
65 _add_format('normal', configUrl, quality=0)
67 ('&hq=1' if '?' in configUrl else configUrl + '?hq=1'))
69 _add_format('hq', hq_url, quality=1)
70 except ExtractorError:
71 pass # That's fine, we'll just use normal quality
73 self._sort_formats(formats)
80 'thumbnail': self._og_search_thumbnail(webpage),
81 'description': videoDesc,
82 'player_url': playerUrl,