]>
Commit | Line | Data |
---|---|---|
9e68f9fd | 1 | import re |
9e68f9fd DW |
2 | |
3 | from .common import InfoExtractor | |
118f7add | 4 | from .kaltura import KalturaIE |
44cae2fb | 5 | from ..utils import ( |
41d1cca3 | 6 | HEADRequest, |
7 | remove_start, | |
5c2266df | 8 | sanitized_Request, |
41d1cca3 | 9 | smuggle_url, |
6e6bc8da | 10 | urlencode_postdata, |
44cae2fb | 11 | ) |
9e68f9fd | 12 | |
5d2519e5 | 13 | |
9e68f9fd | 14 | class GDCVaultIE(InfoExtractor): |
118f7add | 15 | _VALID_URL = r'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)(?:/(?P<name>[\w-]+))?' |
499bfcbf | 16 | _NETRC_MACHINE = 'gdcvault' |
83cebb8b | 17 | _TESTS = [ |
83cebb8b | 18 | { |
45344855 DW |
19 | 'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple', |
20 | 'md5': '7ce8388f544c88b7ac11c7ab1b593704', | |
21 | 'info_dict': { | |
118f7add | 22 | 'id': '201311826596_AWNY', |
c8ff6457 | 23 | 'display_id': 'Doki-Doki-Universe-Sweet-Simple', |
45344855 DW |
24 | 'ext': 'mp4', |
25 | 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)' | |
83cebb8b DW |
26 | } |
27 | }, | |
50a138d9 | 28 | { |
45344855 | 29 | 'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of', |
45344855 | 30 | 'info_dict': { |
118f7add | 31 | 'id': '201203272_1330951438328RSXR', |
c8ff6457 | 32 | 'display_id': 'Embracing-the-Dark-Art-of', |
45344855 DW |
33 | 'ext': 'flv', |
34 | 'title': 'Embracing the Dark Art of Mathematical Modeling in AI' | |
35 | }, | |
f604c93c PH |
36 | 'params': { |
37 | 'skip_download': True, # Requires rtmpdump | |
50a138d9 DW |
38 | } |
39 | }, | |
5d2519e5 PH |
40 | { |
41 | 'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or', | |
42 | 'md5': 'a5eb77996ef82118afbbe8e48731b98e', | |
43 | 'info_dict': { | |
44 | 'id': '1015301', | |
c8ff6457 | 45 | 'display_id': 'Thexder-Meets-Windows-95-or', |
5d2519e5 PH |
46 | 'ext': 'flv', |
47 | 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment', | |
740a7fcb PH |
48 | }, |
49 | 'skip': 'Requires login', | |
25f7d1be YCH |
50 | }, |
51 | { | |
52 | 'url': 'http://gdcvault.com/play/1020791/', | |
53 | 'only_matching': True, | |
99ef96f8 YCH |
54 | }, |
55 | { | |
442c4d36 | 56 | # Hard-coded hostname |
99ef96f8 YCH |
57 | 'url': 'http://gdcvault.com/play/1023460/Tenacious-Design-and-The-Interface', |
58 | 'md5': 'a8efb6c31ed06ca8739294960b2dbabd', | |
59 | 'info_dict': { | |
118f7add | 60 | 'id': '840376_BQRC', |
99ef96f8 YCH |
61 | 'ext': 'mp4', |
62 | 'display_id': 'Tenacious-Design-and-The-Interface', | |
63 | 'title': 'Tenacious Design and The Interface of \'Destiny\'', | |
64 | }, | |
65 | }, | |
442c4d36 YCH |
66 | { |
67 | # Multiple audios | |
68 | 'url': 'http://www.gdcvault.com/play/1014631/Classic-Game-Postmortem-PAC', | |
69 | 'info_dict': { | |
118f7add RA |
70 | 'id': '12396_1299111843500GMPX', |
71 | 'ext': 'mp4', | |
442c4d36 YCH |
72 | 'title': 'How to Create a Good Game - From My Experience of Designing Pac-Man', |
73 | }, | |
118f7add RA |
74 | # 'params': { |
75 | # 'skip_download': True, # Requires rtmpdump | |
76 | # 'format': 'jp', # The japanese audio | |
77 | # } | |
442c4d36 | 78 | }, |
50ad078b YCH |
79 | { |
80 | # gdc-player.html | |
81 | 'url': 'http://www.gdcvault.com/play/1435/An-American-engine-in-Tokyo', | |
82 | 'info_dict': { | |
118f7add | 83 | 'id': '9350_1238021887562UHXB', |
50ad078b | 84 | 'display_id': 'An-American-engine-in-Tokyo', |
118f7add | 85 | 'ext': 'mp4', |
50ad078b YCH |
86 | 'title': 'An American Engine in Tokyo:/nThe collaboration of Epic Games and Square Enix/nFor THE LAST REMINANT', |
87 | }, | |
118f7add RA |
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 | }, | |
50ad078b | 100 | 'params': { |
118f7add | 101 | 'format': 'mp4-408', |
50ad078b YCH |
102 | }, |
103 | }, | |
41d1cca3 | 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 | }, | |
83cebb8b | 124 | ] |
9e68f9fd | 125 | |
c8ff6457 | 126 | def _login(self, webpage_url, display_id): |
68217024 | 127 | username, password = self._get_login_info() |
50a138d9 | 128 | if username is None or password is None: |
45344855 | 129 | self.report_warning('It looks like ' + webpage_url + ' requires a login. Try specifying a username and password and try again.') |
50a138d9 DW |
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 | ||
6e6bc8da | 141 | request = sanitized_Request(login_url, urlencode_postdata(login_form)) |
50a138d9 | 142 | request.add_header('Content-Type', 'application/x-www-form-urlencoded') |
c8ff6457 | 143 | self._download_webpage(request, display_id, 'Logging in') |
41d1cca3 | 144 | start_page = self._download_webpage(webpage_url, display_id, 'Getting authenticated video page') |
c8ff6457 | 145 | self._download_webpage(logout_url, display_id, 'Logging out') |
50a138d9 | 146 | |
41d1cca3 | 147 | return start_page |
50a138d9 | 148 | |
9e68f9fd | 149 | def _real_extract(self, url): |
5ad28e7f | 150 | video_id, name = self._match_valid_url(url).groups() |
118f7add | 151 | display_id = name or video_id |
c8ff6457 | 152 | |
41d1cca3 | 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 | } | |
d23f9ec7 | 174 | |
41d1cca3 | 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' | |
83cebb8b | 211 | |
45344855 | 212 | return { |
ec59d657 | 213 | '_type': 'url_transparent', |
9e68f9fd | 214 | 'id': video_id, |
c8ff6457 | 215 | 'display_id': display_id, |
41d1cca3 | 216 | 'url': embed_url, |
217 | 'ie_key': ie_key, | |
4b819d14 | 218 | } |