]>
Commit | Line | Data |
---|---|---|
1 | import re | |
2 | ||
3 | from .common import InfoExtractor | |
4 | from .kaltura import KalturaIE | |
5 | from ..utils import ( | |
6 | HEADRequest, | |
7 | remove_start, | |
8 | sanitized_Request, | |
9 | smuggle_url, | |
10 | urlencode_postdata, | |
11 | ) | |
12 | ||
13 | ||
14 | class GDCVaultIE(InfoExtractor): | |
15 | _VALID_URL = r'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)(?:/(?P<name>[\w-]+))?' | |
16 | _NETRC_MACHINE = 'gdcvault' | |
17 | _TESTS = [ | |
18 | { | |
19 | 'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple', | |
20 | 'md5': '7ce8388f544c88b7ac11c7ab1b593704', | |
21 | 'info_dict': { | |
22 | 'id': '201311826596_AWNY', | |
23 | 'display_id': 'Doki-Doki-Universe-Sweet-Simple', | |
24 | 'ext': 'mp4', | |
25 | 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)' | |
26 | } | |
27 | }, | |
28 | { | |
29 | 'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of', | |
30 | 'info_dict': { | |
31 | 'id': '201203272_1330951438328RSXR', | |
32 | 'display_id': 'Embracing-the-Dark-Art-of', | |
33 | 'ext': 'flv', | |
34 | 'title': 'Embracing the Dark Art of Mathematical Modeling in AI' | |
35 | }, | |
36 | 'params': { | |
37 | 'skip_download': True, # Requires rtmpdump | |
38 | } | |
39 | }, | |
40 | { | |
41 | 'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or', | |
42 | 'md5': 'a5eb77996ef82118afbbe8e48731b98e', | |
43 | 'info_dict': { | |
44 | 'id': '1015301', | |
45 | 'display_id': 'Thexder-Meets-Windows-95-or', | |
46 | 'ext': 'flv', | |
47 | 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment', | |
48 | }, | |
49 | 'skip': 'Requires login', | |
50 | }, | |
51 | { | |
52 | 'url': 'http://gdcvault.com/play/1020791/', | |
53 | 'only_matching': True, | |
54 | }, | |
55 | { | |
56 | # Hard-coded hostname | |
57 | 'url': 'http://gdcvault.com/play/1023460/Tenacious-Design-and-The-Interface', | |
58 | 'md5': 'a8efb6c31ed06ca8739294960b2dbabd', | |
59 | 'info_dict': { | |
60 | 'id': '840376_BQRC', | |
61 | 'ext': 'mp4', | |
62 | 'display_id': 'Tenacious-Design-and-The-Interface', | |
63 | 'title': 'Tenacious Design and The Interface of \'Destiny\'', | |
64 | }, | |
65 | }, | |
66 | { | |
67 | # Multiple audios | |
68 | 'url': 'http://www.gdcvault.com/play/1014631/Classic-Game-Postmortem-PAC', | |
69 | 'info_dict': { | |
70 | 'id': '12396_1299111843500GMPX', | |
71 | 'ext': 'mp4', | |
72 | 'title': 'How to Create a Good Game - From My Experience of Designing Pac-Man', | |
73 | }, | |
74 | # 'params': { | |
75 | # 'skip_download': True, # Requires rtmpdump | |
76 | # 'format': 'jp', # The japanese audio | |
77 | # } | |
78 | }, | |
79 | { | |
80 | # gdc-player.html | |
81 | 'url': 'http://www.gdcvault.com/play/1435/An-American-engine-in-Tokyo', | |
82 | 'info_dict': { | |
83 | 'id': '9350_1238021887562UHXB', | |
84 | 'display_id': 'An-American-engine-in-Tokyo', | |
85 | 'ext': 'mp4', | |
86 | 'title': 'An American Engine in Tokyo:/nThe collaboration of Epic Games and Square Enix/nFor THE LAST REMINANT', | |
87 | }, | |
88 | }, | |
89 | { | |
90 | # Kaltura Embed | |
91 | 'url': 'https://www.gdcvault.com/play/1026180/Mastering-the-Apex-of-Scaling', | |
92 | 'info_dict': { | |
93 | 'id': '0_h1fg8j3p', | |
94 | 'ext': 'mp4', | |
95 | 'title': 'Mastering the Apex of Scaling Game Servers (Presented by Multiplay)', | |
96 | 'timestamp': 1554401811, | |
97 | 'upload_date': '20190404', | |
98 | 'uploader_id': 'joe@blazestreaming.com', | |
99 | }, | |
100 | 'params': { | |
101 | 'format': 'mp4-408', | |
102 | }, | |
103 | }, | |
104 | { | |
105 | # Kaltura embed, whitespace between quote and embedded URL in iframe's src | |
106 | 'url': 'https://www.gdcvault.com/play/1025699', | |
107 | 'info_dict': { | |
108 | 'id': '0_zagynv0a', | |
109 | 'ext': 'mp4', | |
110 | 'title': 'Tech Toolbox', | |
111 | 'upload_date': '20190408', | |
112 | 'uploader_id': 'joe@blazestreaming.com', | |
113 | 'timestamp': 1554764629, | |
114 | }, | |
115 | 'params': { | |
116 | 'skip_download': True, | |
117 | }, | |
118 | }, | |
119 | { | |
120 | # HTML5 video | |
121 | 'url': 'http://www.gdcvault.com/play/1014846/Conference-Keynote-Shigeru', | |
122 | 'only_matching': True, | |
123 | }, | |
124 | ] | |
125 | ||
126 | def _login(self, webpage_url, display_id): | |
127 | username, password = self._get_login_info() | |
128 | if username is None or password is None: | |
129 | self.report_warning('It looks like ' + webpage_url + ' requires a login. Try specifying a username and password and try again.') | |
130 | return None | |
131 | ||
132 | mobj = re.match(r'(?P<root_url>https?://.*?/).*', webpage_url) | |
133 | login_url = mobj.group('root_url') + 'api/login.php' | |
134 | logout_url = mobj.group('root_url') + 'logout' | |
135 | ||
136 | login_form = { | |
137 | 'email': username, | |
138 | 'password': password, | |
139 | } | |
140 | ||
141 | request = sanitized_Request(login_url, urlencode_postdata(login_form)) | |
142 | request.add_header('Content-Type', 'application/x-www-form-urlencoded') | |
143 | self._download_webpage(request, display_id, 'Logging in') | |
144 | start_page = self._download_webpage(webpage_url, display_id, 'Getting authenticated video page') | |
145 | self._download_webpage(logout_url, display_id, 'Logging out') | |
146 | ||
147 | return start_page | |
148 | ||
149 | def _real_extract(self, url): | |
150 | video_id, name = self._match_valid_url(url).groups() | |
151 | display_id = name or video_id | |
152 | ||
153 | webpage_url = 'http://www.gdcvault.com/play/' + video_id | |
154 | start_page = self._download_webpage(webpage_url, display_id) | |
155 | ||
156 | direct_url = self._search_regex( | |
157 | r's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);', | |
158 | start_page, 'url', default=None) | |
159 | if direct_url: | |
160 | title = self._html_search_regex( | |
161 | r'<td><strong>Session Name:?</strong></td>\s*<td>(.*?)</td>', | |
162 | start_page, 'title') | |
163 | video_url = 'http://www.gdcvault.com' + direct_url | |
164 | # resolve the url so that we can detect the correct extension | |
165 | video_url = self._request_webpage( | |
166 | HEADRequest(video_url), video_id).geturl() | |
167 | ||
168 | return { | |
169 | 'id': video_id, | |
170 | 'display_id': display_id, | |
171 | 'url': video_url, | |
172 | 'title': title, | |
173 | } | |
174 | ||
175 | embed_url = KalturaIE._extract_url(start_page) | |
176 | if embed_url: | |
177 | embed_url = smuggle_url(embed_url, {'source_url': url}) | |
178 | ie_key = 'Kaltura' | |
179 | else: | |
180 | PLAYER_REGEX = r'<iframe src="(?P<xml_root>.+?)/(?:gdc-)?player.*?\.html.*?".*?</iframe>' | |
181 | ||
182 | xml_root = self._html_search_regex( | |
183 | PLAYER_REGEX, start_page, 'xml root', default=None) | |
184 | if xml_root is None: | |
185 | # Probably need to authenticate | |
186 | login_res = self._login(webpage_url, display_id) | |
187 | if login_res is None: | |
188 | self.report_warning('Could not login.') | |
189 | else: | |
190 | start_page = login_res | |
191 | # Grab the url from the authenticated page | |
192 | xml_root = self._html_search_regex( | |
193 | PLAYER_REGEX, start_page, 'xml root') | |
194 | ||
195 | xml_name = self._html_search_regex( | |
196 | r'<iframe src=".*?\?xml(?:=|URL=xml/)(.+?\.xml).*?".*?</iframe>', | |
197 | start_page, 'xml filename', default=None) | |
198 | if not xml_name: | |
199 | info = self._parse_html5_media_entries(url, start_page, video_id)[0] | |
200 | info.update({ | |
201 | 'title': remove_start(self._search_regex( | |
202 | r'>Session Name:\s*<.*?>\s*<td>(.+?)</td>', start_page, | |
203 | 'title', default=None) or self._og_search_title( | |
204 | start_page, default=None), 'GDC Vault - '), | |
205 | 'id': video_id, | |
206 | 'display_id': display_id, | |
207 | }) | |
208 | return info | |
209 | embed_url = '%s/xml/%s' % (xml_root, xml_name) | |
210 | ie_key = 'DigitallySpeaking' | |
211 | ||
212 | return { | |
213 | '_type': 'url_transparent', | |
214 | 'id': video_id, | |
215 | 'display_id': display_id, | |
216 | 'url': embed_url, | |
217 | 'ie_key': ie_key, | |
218 | } |