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