]>
Commit | Line | Data |
---|---|---|
15369766 | 1 | from .common import InfoExtractor |
1cc79574 | 2 | from ..utils import ( |
e2dc351d | 3 | determine_ext, |
4 | clean_html, | |
71fa56b8 | 5 | int_or_none, |
782e0568 | 6 | float_or_none, |
15369766 PH |
7 | ) |
8 | ||
9 | ||
e2dc351d | 10 | def _decrypt_config(key, string): |
11 | a = '' | |
12 | i = '' | |
13 | r = '' | |
14 | ||
15 | while len(a) < (len(string) / 2): | |
16 | a += key | |
17 | ||
18 | a = a[0:int(len(string) / 2)] | |
19 | ||
20 | t = 0 | |
21 | while t < len(string): | |
22 | i += chr(int(string[t] + string[t + 1], 16)) | |
23 | t += 2 | |
24 | ||
25 | icko = [s for s in i] | |
26 | ||
27 | for t, c in enumerate(a): | |
28 | r += chr(ord(c) ^ ord(icko[t])) | |
29 | ||
30 | return r | |
31 | ||
32 | ||
15369766 | 33 | class EscapistIE(InfoExtractor): |
fddb4a3a | 34 | _VALID_URL = r'https?://?(?:(?:www|v1)\.)?escapistmagazine\.com/videos/view/[^/]+/(?P<id>[0-9]+)' |
e2dc351d | 35 | _TESTS = [{ |
6f90d098 | 36 | 'url': 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate', |
cec04ef3 | 37 | 'md5': 'ab3a706c681efca53f0a35f1415cf0d1', |
6f90d098 PH |
38 | 'info_dict': { |
39 | 'id': '6618', | |
40 | 'ext': 'mp4', | |
41 | '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.", | |
6f90d098 | 42 | 'title': "Breaking Down Baldur's Gate", |
ec85ded8 | 43 | 'thumbnail': r're:^https?://.*\.jpg$', |
8237bec4 | 44 | 'duration': 264, |
b2f82360 | 45 | 'uploader': 'The Escapist', |
6f5ac90c | 46 | } |
e2dc351d | 47 | }, { |
48 | 'url': 'http://www.escapistmagazine.com/videos/view/zero-punctuation/10044-Evolve-One-vs-Multiplayer', | |
cec04ef3 | 49 | 'md5': '9e8c437b0dbb0387d3bd3255ca77f6bf', |
e2dc351d | 50 | 'info_dict': { |
51 | 'id': '10044', | |
52 | 'ext': 'mp4', | |
53 | 'description': 'This week, Zero Punctuation reviews Evolve.', | |
54 | 'title': 'Evolve - One vs Multiplayer', | |
ec85ded8 | 55 | 'thumbnail': r're:^https?://.*\.jpg$', |
e2dc351d | 56 | 'duration': 304, |
b2f82360 | 57 | 'uploader': 'The Escapist', |
e2dc351d | 58 | } |
fddb4a3a RA |
59 | }, { |
60 | 'url': 'http://escapistmagazine.com/videos/view/the-escapist-presents/6618', | |
61 | 'only_matching': True, | |
62 | }, { | |
63 | 'url': 'https://v1.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate', | |
64 | 'only_matching': True, | |
e2dc351d | 65 | }] |
15369766 PH |
66 | |
67 | def _real_extract(self, url): | |
596ac6e3 | 68 | video_id = self._match_id(url) |
e2dc351d | 69 | webpage = self._download_webpage(url, video_id) |
70 | ||
782e0568 | 71 | ims_video = self._parse_json( |
290a5a8d S |
72 | self._search_regex( |
73 | r'imsVideo\.play\(({.+?})\);', webpage, 'imsVideo'), | |
74 | video_id) | |
782e0568 S |
75 | video_id = ims_video['videoID'] |
76 | key = ims_video['hash'] | |
e2dc351d | 77 | |
fddb4a3a RA |
78 | config = self._download_webpage( |
79 | 'http://www.escapistmagazine.com/videos/vidconfig.php', | |
80 | video_id, 'Downloading video config', headers={ | |
81 | 'Referer': url, | |
82 | }, query={ | |
83 | 'videoID': video_id, | |
84 | 'hash': key, | |
85 | }) | |
15369766 | 86 | |
fddb4a3a | 87 | data = self._parse_json(_decrypt_config(key, config), video_id) |
e2dc351d | 88 | |
782e0568 S |
89 | video_data = data['videoData'] |
90 | ||
91 | title = clean_html(video_data['title']) | |
e2dc351d | 92 | |
71fa56b8 S |
93 | formats = [{ |
94 | 'url': video['src'], | |
95 | 'format_id': '%s-%sp' % (determine_ext(video['src']), video['res']), | |
96 | 'height': int_or_none(video.get('res')), | |
97 | } for video in data['files']['videos']] | |
e2dc351d | 98 | |
99 | return { | |
6f90d098 | 100 | 'id': video_id, |
100959a6 | 101 | 'formats': formats, |
15369766 | 102 | 'title': title, |
fddb4a3a | 103 | 'thumbnail': self._og_search_thumbnail(webpage) or data.get('poster'), |
e2dc351d | 104 | 'description': self._og_search_description(webpage), |
fddb4a3a RA |
105 | 'duration': float_or_none(video_data.get('duration'), 1000), |
106 | 'uploader': video_data.get('publisher'), | |
107 | 'series': video_data.get('show'), | |
15369766 | 108 | } |