]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gdcvault.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
10 from ..utils
import remove_end
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,
56 def _parse_mp4(self
, xml_description
):
58 mp4_video
= xml_description
.find('./metadata/mp4video')
62 mobj
= re
.match(r
'(?P<root>https?://.*?/).*', mp4_video
.text
)
63 video_root
= mobj
.group('root')
64 formats
= xml_description
.findall('./metadata/MBRVideos/MBRVideo')
65 for format
in formats
:
66 mobj
= re
.match(r
'mp4\:(?P<path>.*)', format
.find('streamName').text
)
67 url
= video_root
+ mobj
.group('path')
68 vbr
= format
.find('bitrate').text
69 video_formats
.append({
75 def _parse_flv(self
, xml_description
):
77 akamai_url
= xml_description
.find('./metadata/akamaiHost').text
78 slide_video_path
= xml_description
.find('./metadata/slideVideo').text
79 video_formats
.append({
80 'url': 'rtmp://%s/ondemand?ovpfv=1.1' % akamai_url
,
81 'play_path': remove_end(slide_video_path
, '.flv'),
83 'format_note': 'slide deck video',
86 'format_id': 'slides',
88 speaker_video_path
= xml_description
.find('./metadata/speakerVideo').text
89 video_formats
.append({
90 'url': 'rtmp://%s/ondemand?ovpfv=1.1' % akamai_url
,
91 'play_path': remove_end(speaker_video_path
, '.flv'),
93 'format_note': 'speaker video',
96 'format_id': 'speaker',
100 def _login(self
, webpage_url
, display_id
):
101 (username
, password
) = self
._get
_login
_info
()
102 if username
is None or password
is None:
103 self
.report_warning('It looks like ' + webpage_url
+ ' requires a login. Try specifying a username and password and try again.')
106 mobj
= re
.match(r
'(?P<root_url>https?://.*?/).*', webpage_url
)
107 login_url
= mobj
.group('root_url') + 'api/login.php'
108 logout_url
= mobj
.group('root_url') + 'logout'
112 'password': password
,
115 request
= compat_urllib_request
.Request(login_url
, compat_urllib_parse
.urlencode(login_form
))
116 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
117 self
._download
_webpage
(request
, display_id
, 'Logging in')
118 start_page
= self
._download
_webpage
(webpage_url
, display_id
, 'Getting authenticated video page')
119 self
._download
_webpage
(logout_url
, display_id
, 'Logging out')
123 def _real_extract(self
, url
):
124 mobj
= re
.match(self
._VALID
_URL
, url
)
126 video_id
= mobj
.group('id')
127 display_id
= mobj
.group('name') or video_id
129 webpage_url
= 'http://www.gdcvault.com/play/' + video_id
130 start_page
= self
._download
_webpage
(webpage_url
, display_id
)
132 direct_url
= self
._search
_regex
(
133 r
's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);',
134 start_page
, 'url', default
=None)
136 video_url
= 'http://www.gdcvault.com/' + direct_url
137 title
= self
._html
_search
_regex
(
138 r
'<td><strong>Session Name</strong></td>\s*<td>(.*?)</td>',
143 'display_id': display_id
,
149 xml_root
= self
._html
_search
_regex
(
150 r
'<iframe src="(?P<xml_root>.*?)player.html.*?".*?</iframe>',
151 start_page
, 'xml root', default
=None)
153 # Probably need to authenticate
154 login_res
= self
._login
(webpage_url
, display_id
)
155 if login_res
is None:
156 self
.report_warning('Could not login.')
158 start_page
= login_res
159 # Grab the url from the authenticated page
160 xml_root
= self
._html
_search
_regex
(
161 r
'<iframe src="(.*?)player.html.*?".*?</iframe>',
162 start_page
, 'xml root')
164 xml_name
= self
._html
_search
_regex
(
165 r
'<iframe src=".*?\?xml=(.+?\.xml).*?".*?</iframe>',
166 start_page
, 'xml filename', default
=None)
168 # Fallback to the older format
169 xml_name
= self
._html
_search
_regex
(r
'<iframe src=".*?\?xmlURL=xml/(?P<xml_file>.+?\.xml).*?".*?</iframe>', start_page
, 'xml filename')
171 xml_decription_url
= xml_root
+ 'xml/' + xml_name
172 xml_description
= self
._download
_xml
(xml_decription_url
, display_id
)
174 video_title
= xml_description
.find('./metadata/title').text
175 video_formats
= self
._parse
_mp
4(xml_description
)
176 if video_formats
is None:
177 video_formats
= self
._parse
_flv
(xml_description
)
181 'display_id': display_id
,
182 'title': video_title
,
183 'formats': video_formats
,