1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_urllib_request
16 def _decrypt_config(key, string):
21 while len(a) < (len(string) / 2):
24 a = a[0:int(len(string) / 2)]
27 while t < len(string):
28 i += chr(int(string[t] + string[t + 1], 16))
33 for t, c in enumerate(a):
34 r += chr(ord(c) ^ ord(icko[t]))
39 class EscapistIE(InfoExtractor):
40 _VALID_URL = r'https?://?(?:www\.)?escapistmagazine\.com/videos/view/[^/?#]+/(?P<id>[0-9]+)-[^/?#]*(?:$|[?#])'
42 'url': 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate',
43 'md5': 'ab3a706c681efca53f0a35f1415cf0d1',
47 '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.",
48 'title': "Breaking Down Baldur's Gate",
49 'thumbnail': 're:^https?://.*\.jpg$',
51 'uploader': 'The Escapist',
54 'url': 'http://www.escapistmagazine.com/videos/view/zero-punctuation/10044-Evolve-One-vs-Multiplayer',
55 'md5': '9e8c437b0dbb0387d3bd3255ca77f6bf',
59 'description': 'This week, Zero Punctuation reviews Evolve.',
60 'title': 'Evolve - One vs Multiplayer',
61 'thumbnail': 're:^https?://.*\.jpg$',
63 'uploader': 'The Escapist',
67 def _real_extract(self, url):
68 video_id = self._match_id(url)
69 webpage = self._download_webpage(url, video_id)
71 ims_video = self._parse_json(
73 r'imsVideo\.play\(({.+?})\);', webpage, 'imsVideo'),
75 video_id = ims_video['videoID']
76 key = ims_video['hash']
78 config_req = compat_urllib_request.Request(
79 'http://www.escapistmagazine.com/videos/'
80 'vidconfig.php?videoID=%s&hash=%s' % (video_id, key))
81 config_req.add_header('Referer', url)
82 config = self._download_webpage(config_req, video_id, 'Downloading video config')
84 data = json.loads(_decrypt_config(key, config))
86 video_data = data['videoData']
88 title = clean_html(video_data['title'])
89 duration = float_or_none(video_data.get('duration'), 1000)
90 uploader = video_data.get('publisher')
94 'format_id': '%s-%sp' % (determine_ext(video['src']), video['res']),
95 'height': int_or_none(video.get('res')),
96 } for video in data['files']['videos']]
97 self._sort_formats(formats)
103 'thumbnail': self._og_search_thumbnail(webpage),
104 'description': self._og_search_description(webpage),
105 'duration': duration,
106 'uploader': uploader,