]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gdcvault.py
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
   6 from .kaltura 
import KalturaIE
 
  15 class GDCVaultIE(InfoExtractor
): 
  16     _VALID_URL 
= r
'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)(?:/(?P<name>[\w-]+))?' 
  17     _NETRC_MACHINE 
= 'gdcvault' 
  20             'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple', 
  21             'md5': '7ce8388f544c88b7ac11c7ab1b593704', 
  23                 'id': '201311826596_AWNY', 
  24                 'display_id': 'Doki-Doki-Universe-Sweet-Simple', 
  26                 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)' 
  30             'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of', 
  32                 'id': '201203272_1330951438328RSXR', 
  33                 'display_id': 'Embracing-the-Dark-Art-of', 
  35                 'title': 'Embracing the Dark Art of Mathematical Modeling in AI' 
  38                 'skip_download': True,  # Requires rtmpdump 
  42             'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or', 
  43             'md5': 'a5eb77996ef82118afbbe8e48731b98e', 
  46                 'display_id': 'Thexder-Meets-Windows-95-or', 
  48                 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment', 
  50             'skip': 'Requires login', 
  53             'url': 'http://gdcvault.com/play/1020791/', 
  54             'only_matching': True, 
  58             'url': 'http://gdcvault.com/play/1023460/Tenacious-Design-and-The-Interface', 
  59             'md5': 'a8efb6c31ed06ca8739294960b2dbabd', 
  63                 'display_id': 'Tenacious-Design-and-The-Interface', 
  64                 'title': 'Tenacious Design and The Interface of \'Destiny\'', 
  69             'url': 'http://www.gdcvault.com/play/1014631/Classic-Game-Postmortem-PAC', 
  71                 'id': '12396_1299111843500GMPX', 
  73                 'title': 'How to Create a Good Game - From My Experience of Designing Pac-Man', 
  76             #     'skip_download': True,  # Requires rtmpdump 
  77             #     'format': 'jp',  # The japanese audio 
  82             'url': 'http://www.gdcvault.com/play/1435/An-American-engine-in-Tokyo', 
  84                 'id': '9350_1238021887562UHXB', 
  85                 'display_id': 'An-American-engine-in-Tokyo', 
  87                 'title': 'An American Engine in Tokyo:/nThe collaboration of Epic Games and Square Enix/nFor THE LAST REMINANT', 
  92             'url': 'https://www.gdcvault.com/play/1026180/Mastering-the-Apex-of-Scaling', 
  96                 'title': 'Mastering the Apex of Scaling Game Servers (Presented by Multiplay)', 
  97                 'timestamp': 1554401811, 
  98                 'upload_date': '20190404', 
  99                 'uploader_id': 'joe@blazestreaming.com', 
 107     def _login(self
, webpage_url
, display_id
): 
 108         username
, password 
= self
._get
_login
_info
() 
 109         if username 
is None or password 
is None: 
 110             self
.report_warning('It looks like ' + webpage_url 
+ ' requires a login. Try specifying a username and password and try again.') 
 113         mobj 
= re
.match(r
'(?P<root_url>https?://.*?/).*', webpage_url
) 
 114         login_url 
= mobj
.group('root_url') + 'api/login.php' 
 115         logout_url 
= mobj
.group('root_url') + 'logout' 
 119             'password': password
, 
 122         request 
= sanitized_Request(login_url
, urlencode_postdata(login_form
)) 
 123         request
.add_header('Content-Type', 'application/x-www-form-urlencoded') 
 124         self
._download
_webpage
(request
, display_id
, 'Logging in') 
 125         start_page 
= self
._download
_webpage
(webpage_url
, display_id
, 'Getting authenticated video page') 
 126         self
._download
_webpage
(logout_url
, display_id
, 'Logging out') 
 130     def _real_extract(self
, url
): 
 131         video_id
, name 
= re
.match(self
._VALID
_URL
, url
).groups() 
 132         display_id 
= name 
or video_id
 
 134         webpage_url 
= 'http://www.gdcvault.com/play/' + video_id
 
 135         start_page 
= self
._download
_webpage
(webpage_url
, display_id
) 
 137         direct_url 
= self
._search
_regex
( 
 138             r
's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);', 
 139             start_page
, 'url', default
=None) 
 141             title 
= self
._html
_search
_regex
( 
 142                 r
'<td><strong>Session Name:?</strong></td>\s*<td>(.*?)</td>', 
 144             video_url 
= 'http://www.gdcvault.com' + direct_url
 
 145             # resolve the url so that we can detect the correct extension 
 146             video_url 
= self
._request
_webpage
( 
 147                 HEADRequest(video_url
), video_id
).geturl() 
 151                 'display_id': display_id
, 
 156         embed_url 
= KalturaIE
._extract
_url
(start_page
) 
 158             embed_url 
= smuggle_url(embed_url
, {'source_url': url
}) 
 161             PLAYER_REGEX 
= r
'<iframe src="(?P<xml_root>.+?)/(?:gdc-)?player.*?\.html.*?".*?</iframe>' 
 163             xml_root 
= self
._html
_search
_regex
( 
 164                 PLAYER_REGEX
, start_page
, 'xml root', default
=None) 
 166                 # Probably need to authenticate 
 167                 login_res 
= self
._login
(webpage_url
, display_id
) 
 168                 if login_res 
is None: 
 169                     self
.report_warning('Could not login.') 
 171                     start_page 
= login_res
 
 172                     # Grab the url from the authenticated page 
 173                     xml_root 
= self
._html
_search
_regex
( 
 174                         PLAYER_REGEX
, start_page
, 'xml root') 
 176             xml_name 
= self
._html
_search
_regex
( 
 177                 r
'<iframe src=".*?\?xml(?:=|URL=xml/)(.+?\.xml).*?".*?</iframe>', 
 178                 start_page
, 'xml filename') 
 179             embed_url 
= '%s/xml/%s' % (xml_root
, xml_name
) 
 180             ie_key 
= 'DigitallySpeaking' 
 183             '_type': 'url_transparent', 
 185             'display_id': display_id
,