1 from __future__ import unicode_literals
5 from .common import InfoExtractor
12 class GDCVaultIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)/(?P<name>(\w|-)+)'
16 'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple',
17 'md5': '7ce8388f544c88b7ac11c7ab1b593704',
21 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)'
25 'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of',
29 'title': 'Embracing the Dark Art of Mathematical Modeling in AI'
32 'skip_download': True, # Requires rtmpdump
36 'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or',
37 'md5': 'a5eb77996ef82118afbbe8e48731b98e',
41 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment',
46 def _parse_mp4(self, xml_description):
48 mp4_video = xml_description.find('./metadata/mp4video')
52 mobj = re.match(r'(?P<root>https?://.*?/).*', mp4_video.text)
53 video_root = mobj.group('root')
54 formats = xml_description.findall('./metadata/MBRVideos/MBRVideo')
55 for format in formats:
56 mobj = re.match(r'mp4\:(?P<path>.*)', format.find('streamName').text)
57 url = video_root + mobj.group('path')
58 vbr = format.find('bitrate').text
59 video_formats.append({
65 def _parse_flv(self, xml_description):
67 akami_url = xml_description.find('./metadata/akamaiHost').text
68 slide_video_path = xml_description.find('./metadata/slideVideo').text
69 video_formats.append({
70 'url': 'rtmp://' + akami_url + '/' + slide_video_path,
71 'format_note': 'slide deck video',
74 'format_id': 'slides',
76 speaker_video_path = xml_description.find('./metadata/speakerVideo').text
77 video_formats.append({
78 'url': 'rtmp://' + akami_url + '/' + speaker_video_path,
79 'format_note': 'speaker video',
82 'format_id': 'speaker',
86 def _login(self, webpage_url, video_id):
87 (username, password) = self._get_login_info()
88 if username is None or password is None:
89 self.report_warning('It looks like ' + webpage_url + ' requires a login. Try specifying a username and password and try again.')
92 mobj = re.match(r'(?P<root_url>https?://.*?/).*', webpage_url)
93 login_url = mobj.group('root_url') + 'api/login.php'
94 logout_url = mobj.group('root_url') + 'logout'
101 request = compat_urllib_request.Request(login_url, compat_urllib_parse.urlencode(login_form))
102 request.add_header('Content-Type', 'application/x-www-form-urlencoded')
103 self._download_webpage(request, video_id, 'Logging in')
104 start_page = self._download_webpage(webpage_url, video_id, 'Getting authenticated video page')
105 self._download_webpage(logout_url, video_id, 'Logging out')
109 def _real_extract(self, url):
110 mobj = re.match(self._VALID_URL, url)
112 video_id = mobj.group('id')
113 webpage_url = 'http://www.gdcvault.com/play/' + video_id
114 start_page = self._download_webpage(webpage_url, video_id)
116 direct_url = self._search_regex(
117 r's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);',
118 start_page, 'url', default=None)
120 video_url = 'http://www.gdcvault.com/' + direct_url
121 title = self._html_search_regex(
122 r'<td><strong>Session Name</strong></td>\s*<td>(.*?)</td>',
132 xml_root = self._html_search_regex(
133 r'<iframe src="(?P<xml_root>.*?)player.html.*?".*?</iframe>',
134 start_page, 'xml root', default=None)
136 # Probably need to authenticate
137 login_res = self._login(webpage_url, video_id)
138 if login_res is None:
139 self.report_warning('Could not login.')
141 start_page = login_res
142 # Grab the url from the authenticated page
143 xml_root = self._html_search_regex(
144 r'<iframe src="(.*?)player.html.*?".*?</iframe>',
145 start_page, 'xml root')
147 xml_name = self._html_search_regex(
148 r'<iframe src=".*?\?xml=(.+?\.xml).*?".*?</iframe>',
149 start_page, 'xml filename', default=None)
151 # Fallback to the older format
152 xml_name = self._html_search_regex(r'<iframe src=".*?\?xmlURL=xml/(?P<xml_file>.+?\.xml).*?".*?</iframe>', start_page, 'xml filename')
154 xml_decription_url = xml_root + 'xml/' + xml_name
155 xml_description = self._download_xml(xml_decription_url, video_id)
157 video_title = xml_description.find('./metadata/title').text
158 video_formats = self._parse_mp4(xml_description)
159 if video_formats is None:
160 video_formats = self._parse_flv(xml_description)
164 'title': video_title,
165 'formats': video_formats,