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