]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gdcvault.py
a6834db433de249ed2d0f9ffa7c07c3ff5becc16
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
16 class GDCVaultIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)/(?P<name>(\w|-)+)?'
18 _NETRC_MACHINE
= 'gdcvault'
21 'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple',
22 'md5': '7ce8388f544c88b7ac11c7ab1b593704',
25 'display_id': 'Doki-Doki-Universe-Sweet-Simple',
27 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)'
31 'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of',
34 'display_id': 'Embracing-the-Dark-Art-of',
36 'title': 'Embracing the Dark Art of Mathematical Modeling in AI'
39 'skip_download': True, # Requires rtmpdump
43 'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or',
44 'md5': 'a5eb77996ef82118afbbe8e48731b98e',
47 'display_id': 'Thexder-Meets-Windows-95-or',
49 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment',
51 'skip': 'Requires login',
54 'url': 'http://gdcvault.com/play/1020791/',
55 'only_matching': True,
59 def _parse_mp4(self
, xml_description
):
61 mp4_video
= xml_description
.find('./metadata/mp4video')
65 mobj
= re
.match(r
'(?P<root>https?://.*?/).*', mp4_video
.text
)
66 video_root
= mobj
.group('root')
67 formats
= xml_description
.findall('./metadata/MBRVideos/MBRVideo')
68 for format
in formats
:
69 mobj
= re
.match(r
'mp4\:(?P<path>.*)', format
.find('streamName').text
)
70 url
= video_root
+ mobj
.group('path')
71 vbr
= format
.find('bitrate').text
72 video_formats
.append({
78 def _parse_flv(self
, xml_description
):
80 akamai_url
= xml_description
.find('./metadata/akamaiHost').text
81 audios
= xml_description
.find('./metadata/audios')
82 if audios
is not None:
85 'url': 'rtmp://%s/ondemand?ovpfv=1.1' % akamai_url
,
86 'play_path': remove_end(audio
.get('url'), '.flv'),
89 'format_id': audio
.get('code'),
91 slide_video_path
= xml_description
.find('./metadata/slideVideo').text
93 'url': 'rtmp://%s/ondemand?ovpfv=1.1' % akamai_url
,
94 'play_path': remove_end(slide_video_path
, '.flv'),
96 'format_note': 'slide deck video',
99 'format_id': 'slides',
101 speaker_video_path
= xml_description
.find('./metadata/speakerVideo').text
103 'url': 'rtmp://%s/ondemand?ovpfv=1.1' % akamai_url
,
104 'play_path': remove_end(speaker_video_path
, '.flv'),
106 'format_note': 'speaker video',
109 'format_id': 'speaker',
113 def _login(self
, webpage_url
, display_id
):
114 (username
, password
) = self
._get
_login
_info
()
115 if username
is None or password
is None:
116 self
.report_warning('It looks like ' + webpage_url
+ ' requires a login. Try specifying a username and password and try again.')
119 mobj
= re
.match(r
'(?P<root_url>https?://.*?/).*', webpage_url
)
120 login_url
= mobj
.group('root_url') + 'api/login.php'
121 logout_url
= mobj
.group('root_url') + 'logout'
125 'password': password
,
128 request
= compat_urllib_request
.Request(login_url
, compat_urllib_parse
.urlencode(login_form
))
129 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
130 self
._download
_webpage
(request
, display_id
, 'Logging in')
131 start_page
= self
._download
_webpage
(webpage_url
, display_id
, 'Getting authenticated video page')
132 self
._download
_webpage
(logout_url
, display_id
, 'Logging out')
136 def _real_extract(self
, url
):
137 mobj
= re
.match(self
._VALID
_URL
, url
)
139 video_id
= mobj
.group('id')
140 display_id
= mobj
.group('name') or video_id
142 webpage_url
= 'http://www.gdcvault.com/play/' + video_id
143 start_page
= self
._download
_webpage
(webpage_url
, display_id
)
145 direct_url
= self
._search
_regex
(
146 r
's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);',
147 start_page
, 'url', default
=None)
149 title
= self
._html
_search
_regex
(
150 r
'<td><strong>Session Name</strong></td>\s*<td>(.*?)</td>',
152 video_url
= 'http://www.gdcvault.com' + direct_url
153 # resolve the url so that we can detect the correct extension
154 head
= self
._request
_webpage
(HEADRequest(video_url
), video_id
)
155 video_url
= head
.geturl()
159 'display_id': display_id
,
164 xml_root
= self
._html
_search
_regex
(
165 r
'<iframe src="(?P<xml_root>.*?)player.html.*?".*?</iframe>',
166 start_page
, 'xml root', default
=None)
168 # Probably need to authenticate
169 login_res
= self
._login
(webpage_url
, display_id
)
170 if login_res
is None:
171 self
.report_warning('Could not login.')
173 start_page
= login_res
174 # Grab the url from the authenticated page
175 xml_root
= self
._html
_search
_regex
(
176 r
'<iframe src="(.*?)player.html.*?".*?</iframe>',
177 start_page
, 'xml root')
179 xml_name
= self
._html
_search
_regex
(
180 r
'<iframe src=".*?\?xml=(.+?\.xml).*?".*?</iframe>',
181 start_page
, 'xml filename', default
=None)
183 # Fallback to the older format
184 xml_name
= self
._html
_search
_regex
(r
'<iframe src=".*?\?xmlURL=xml/(?P<xml_file>.+?\.xml).*?".*?</iframe>', start_page
, 'xml filename')
186 xml_description_url
= xml_root
+ 'xml/' + xml_name
187 xml_description
= self
._download
_xml
(xml_description_url
, display_id
)
189 video_title
= xml_description
.find('./metadata/title').text
190 video_formats
= self
._parse
_mp
4(xml_description
)
191 if video_formats
is None:
192 video_formats
= self
._parse
_flv
(xml_description
)
196 'display_id': display_id
,
197 'title': video_title
,
198 'formats': video_formats
,