- ad_formats = []
-
- def _add_format(name, cfg_url, quality):
- cfg_req = compat_urllib_request.Request(cfg_url)
- cfg_req.add_header('User-Agent', self._USER_AGENT)
- config = self._download_json(
- cfg_req, video_id,
- 'Downloading ' + name + ' configuration',
- 'Unable to download ' + name + ' configuration',
- transform_source=js_to_json)
-
- playlist = config['playlist']
- for p in playlist:
- if p.get('eventCategory') == 'Video':
- ar = formats
- elif p.get('eventCategory') == 'Video Postroll':
- ar = ad_formats
- else:
- continue
-
- ar.append({
- 'url': p['url'],
- 'format_id': name,
- 'quality': quality,
- 'http_headers': {
- 'User-Agent': self._USER_AGENT,
- },
- })
-
- _add_format('normal', config_url, quality=0)
- hq_url = (config_url +
- ('&hq=1' if '?' in config_url else config_url + '?hq=1'))
- try:
- _add_format('hq', hq_url, quality=1)
- except ExtractorError:
- pass # That's fine, we'll just use normal quality
- self._sort_formats(formats)
-
- if '/escapist/sales-marketing/' in formats[-1]['url']:
- raise ExtractorError('This IP address has been blocked by The Escapist', expected=True)
-
- res = {
+ for q in ['lq', 'hq', 'hd']:
+ config_req = compat_urllib_request.Request('http://www.escapistmagazine.com/videos/'
+ 'vidconfig.php?videoID=%s&hash=%s&quality=%s' % (video_id, key, 'mp4_' + q))
+ config_req.add_header('Referer', url)
+ config = self._download_webpage(config_req, video_id, 'Downloading video config ' + q.upper())
+
+ data = json.loads(_decrypt_config(key, config))
+
+ title = clean_html(data['videoData']['title'])
+ duration = data['videoData']['duration'] / 1000
+
+ for i, v in enumerate(data['files']['videos']):
+
+ formats.append({
+ 'url': v,
+ 'format_id': determine_ext(v) + '_' + q + str(i),
+ 'quality': quality(q),
+ })
+
+
+ return {