]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/gdcvault.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
13 class GDCVaultIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)/(?P<name>(\w|-)+)?'
15 _NETRC_MACHINE
= 'gdcvault'
18 'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple',
19 'md5': '7ce8388f544c88b7ac11c7ab1b593704',
22 'display_id': 'Doki-Doki-Universe-Sweet-Simple',
24 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)'
28 'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of',
31 'display_id': 'Embracing-the-Dark-Art-of',
33 'title': 'Embracing the Dark Art of Mathematical Modeling in AI'
36 'skip_download': True, # Requires rtmpdump
40 'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or',
41 'md5': 'a5eb77996ef82118afbbe8e48731b98e',
44 'display_id': 'Thexder-Meets-Windows-95-or',
46 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment',
48 'skip': 'Requires login',
51 'url': 'http://gdcvault.com/play/1020791/',
52 'only_matching': True,
55 'url': 'http://gdcvault.com/play/1023460/Tenacious-Design-and-The-Interface',
56 'md5': 'a8efb6c31ed06ca8739294960b2dbabd',
60 'display_id': 'Tenacious-Design-and-The-Interface',
61 'title': 'Tenacious Design and The Interface of \'Destiny\'',
66 def _login(self
, webpage_url
, display_id
):
67 (username
, password
) = self
._get
_login
_info
()
68 if username
is None or password
is None:
69 self
.report_warning('It looks like ' + webpage_url
+ ' requires a login. Try specifying a username and password and try again.')
72 mobj
= re
.match(r
'(?P<root_url>https?://.*?/).*', webpage_url
)
73 login_url
= mobj
.group('root_url') + 'api/login.php'
74 logout_url
= mobj
.group('root_url') + 'logout'
81 request
= sanitized_Request(login_url
, urlencode_postdata(login_form
))
82 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
83 self
._download
_webpage
(request
, display_id
, 'Logging in')
84 start_page
= self
._download
_webpage
(webpage_url
, display_id
, 'Getting authenticated video page')
85 self
._download
_webpage
(logout_url
, display_id
, 'Logging out')
89 def _real_extract(self
, url
):
90 mobj
= re
.match(self
._VALID
_URL
, url
)
92 video_id
= mobj
.group('id')
93 display_id
= mobj
.group('name') or video_id
95 webpage_url
= 'http://www.gdcvault.com/play/' + video_id
96 start_page
= self
._download
_webpage
(webpage_url
, display_id
)
98 direct_url
= self
._search
_regex
(
99 r
's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);',
100 start_page
, 'url', default
=None)
102 title
= self
._html
_search
_regex
(
103 r
'<td><strong>Session Name</strong></td>\s*<td>(.*?)</td>',
105 video_url
= 'http://www.gdcvault.com' + direct_url
106 # resolve the url so that we can detect the correct extension
107 head
= self
._request
_webpage
(HEADRequest(video_url
), video_id
)
108 video_url
= head
.geturl()
112 'display_id': display_id
,
117 PLAYER_REGEX
= r
'<iframe src="(?P<xml_root>.+?)/player.*?\.html.*?".*?</iframe>'
119 xml_root
= self
._html
_search
_regex
(
120 PLAYER_REGEX
, start_page
, 'xml root', default
=None)
122 # Probably need to authenticate
123 login_res
= self
._login
(webpage_url
, display_id
)
124 if login_res
is None:
125 self
.report_warning('Could not login.')
127 start_page
= login_res
128 # Grab the url from the authenticated page
129 xml_root
= self
._html
_search
_regex
(
130 PLAYER_REGEX
, start_page
, 'xml root')
132 xml_name
= self
._html
_search
_regex
(
133 r
'<iframe src=".*?\?xml=(.+?\.xml).*?".*?</iframe>',
134 start_page
, 'xml filename', default
=None)
136 # Fallback to the older format
137 xml_name
= self
._html
_search
_regex
(
138 r
'<iframe src=".*?\?xmlURL=xml/(?P<xml_file>.+?\.xml).*?".*?</iframe>',
139 start_page
, 'xml filename')
142 '_type': 'url_transparent',
144 'display_id': display_id
,
145 'url': '%s/xml/%s' % (xml_root
, xml_name
),
146 'ie': 'DigitalSpeaking',