gdcvault.py 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import re
  2. from .common import InfoExtractor
  3. from .kaltura import KalturaIE
  4. from ..networking import HEADRequest, Request
  5. from ..utils import remove_start, smuggle_url, urlencode_postdata
  6. class GDCVaultIE(InfoExtractor):
  7. _WORKING = False
  8. _VALID_URL = r'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)(?:/(?P<name>[\w-]+))?'
  9. _NETRC_MACHINE = 'gdcvault'
  10. _TESTS = [
  11. {
  12. 'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple',
  13. 'md5': '7ce8388f544c88b7ac11c7ab1b593704',
  14. 'info_dict': {
  15. 'id': '201311826596_AWNY',
  16. 'display_id': 'Doki-Doki-Universe-Sweet-Simple',
  17. 'ext': 'mp4',
  18. 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)',
  19. },
  20. },
  21. {
  22. 'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of',
  23. 'info_dict': {
  24. 'id': '201203272_1330951438328RSXR',
  25. 'display_id': 'Embracing-the-Dark-Art-of',
  26. 'ext': 'flv',
  27. 'title': 'Embracing the Dark Art of Mathematical Modeling in AI',
  28. },
  29. 'params': {
  30. 'skip_download': True, # Requires rtmpdump
  31. },
  32. },
  33. {
  34. 'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or',
  35. 'md5': 'a5eb77996ef82118afbbe8e48731b98e',
  36. 'info_dict': {
  37. 'id': '1015301',
  38. 'display_id': 'Thexder-Meets-Windows-95-or',
  39. 'ext': 'flv',
  40. 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment',
  41. },
  42. 'skip': 'Requires login',
  43. },
  44. {
  45. 'url': 'http://gdcvault.com/play/1020791/',
  46. 'only_matching': True,
  47. },
  48. {
  49. # Hard-coded hostname
  50. 'url': 'http://gdcvault.com/play/1023460/Tenacious-Design-and-The-Interface',
  51. 'md5': 'a8efb6c31ed06ca8739294960b2dbabd',
  52. 'info_dict': {
  53. 'id': '840376_BQRC',
  54. 'ext': 'mp4',
  55. 'display_id': 'Tenacious-Design-and-The-Interface',
  56. 'title': 'Tenacious Design and The Interface of \'Destiny\'',
  57. },
  58. },
  59. {
  60. # Multiple audios
  61. 'url': 'http://www.gdcvault.com/play/1014631/Classic-Game-Postmortem-PAC',
  62. 'info_dict': {
  63. 'id': '12396_1299111843500GMPX',
  64. 'ext': 'mp4',
  65. 'title': 'How to Create a Good Game - From My Experience of Designing Pac-Man',
  66. },
  67. # 'params': {
  68. # 'skip_download': True, # Requires rtmpdump
  69. # 'format': 'jp', # The japanese audio
  70. # }
  71. },
  72. {
  73. # gdc-player.html
  74. 'url': 'http://www.gdcvault.com/play/1435/An-American-engine-in-Tokyo',
  75. 'info_dict': {
  76. 'id': '9350_1238021887562UHXB',
  77. 'display_id': 'An-American-engine-in-Tokyo',
  78. 'ext': 'mp4',
  79. 'title': 'An American Engine in Tokyo:/nThe collaboration of Epic Games and Square Enix/nFor THE LAST REMINANT',
  80. },
  81. },
  82. {
  83. # Kaltura Embed
  84. 'url': 'https://www.gdcvault.com/play/1026180/Mastering-the-Apex-of-Scaling',
  85. 'info_dict': {
  86. 'id': '0_h1fg8j3p',
  87. 'ext': 'mp4',
  88. 'title': 'Mastering the Apex of Scaling Game Servers (Presented by Multiplay)',
  89. 'timestamp': 1554401811,
  90. 'upload_date': '20190404',
  91. 'uploader_id': 'joe@blazestreaming.com',
  92. },
  93. 'params': {
  94. 'format': 'mp4-408',
  95. },
  96. },
  97. {
  98. # Kaltura embed, whitespace between quote and embedded URL in iframe's src
  99. 'url': 'https://www.gdcvault.com/play/1025699',
  100. 'info_dict': {
  101. 'id': '0_zagynv0a',
  102. 'ext': 'mp4',
  103. 'title': 'Tech Toolbox',
  104. 'upload_date': '20190408',
  105. 'uploader_id': 'joe@blazestreaming.com',
  106. 'timestamp': 1554764629,
  107. },
  108. 'params': {
  109. 'skip_download': True,
  110. },
  111. },
  112. {
  113. # HTML5 video
  114. 'url': 'http://www.gdcvault.com/play/1014846/Conference-Keynote-Shigeru',
  115. 'only_matching': True,
  116. },
  117. ]
  118. def _login(self, webpage_url, display_id):
  119. username, password = self._get_login_info()
  120. if username is None or password is None:
  121. self.report_warning('It looks like ' + webpage_url + ' requires a login. Try specifying a username and password and try again.')
  122. return None
  123. mobj = re.match(r'(?P<root_url>https?://.*?/).*', webpage_url)
  124. login_url = mobj.group('root_url') + 'api/login.php'
  125. logout_url = mobj.group('root_url') + 'logout'
  126. login_form = {
  127. 'email': username,
  128. 'password': password,
  129. }
  130. request = Request(login_url, urlencode_postdata(login_form))
  131. request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  132. self._download_webpage(request, display_id, 'Logging in')
  133. start_page = self._download_webpage(webpage_url, display_id, 'Getting authenticated video page')
  134. self._download_webpage(logout_url, display_id, 'Logging out')
  135. return start_page
  136. def _real_extract(self, url):
  137. video_id, name = self._match_valid_url(url).groups()
  138. display_id = name or video_id
  139. webpage_url = 'http://www.gdcvault.com/play/' + video_id
  140. start_page = self._download_webpage(webpage_url, display_id)
  141. direct_url = self._search_regex(
  142. r's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);',
  143. start_page, 'url', default=None)
  144. if direct_url:
  145. title = self._html_search_regex(
  146. r'<td><strong>Session Name:?</strong></td>\s*<td>(.*?)</td>',
  147. start_page, 'title')
  148. video_url = 'http://www.gdcvault.com' + direct_url
  149. # resolve the url so that we can detect the correct extension
  150. video_url = self._request_webpage(
  151. HEADRequest(video_url), video_id).url
  152. return {
  153. 'id': video_id,
  154. 'display_id': display_id,
  155. 'url': video_url,
  156. 'title': title,
  157. }
  158. embed_url = KalturaIE._extract_url(start_page)
  159. if embed_url:
  160. embed_url = smuggle_url(embed_url, {'source_url': url})
  161. ie_key = 'Kaltura'
  162. else:
  163. PLAYER_REGEX = r'<iframe src="(?P<xml_root>.+?)/(?:gdc-)?player.*?\.html.*?".*?</iframe>'
  164. xml_root = self._html_search_regex(
  165. PLAYER_REGEX, start_page, 'xml root', default=None)
  166. if xml_root is None:
  167. # Probably need to authenticate
  168. login_res = self._login(webpage_url, display_id)
  169. if login_res is None:
  170. self.report_warning('Could not login.')
  171. else:
  172. start_page = login_res
  173. # Grab the url from the authenticated page
  174. xml_root = self._html_search_regex(
  175. 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', default=None)
  179. if not xml_name:
  180. info = self._parse_html5_media_entries(url, start_page, video_id)[0]
  181. info.update({
  182. 'title': remove_start(self._search_regex(
  183. r'>Session Name:\s*<.*?>\s*<td>(.+?)</td>', start_page,
  184. 'title', default=None) or self._og_search_title(
  185. start_page, default=None), 'GDC Vault - '),
  186. 'id': video_id,
  187. 'display_id': display_id,
  188. })
  189. return info
  190. embed_url = f'{xml_root}/xml/{xml_name}'
  191. ie_key = 'DigitallySpeaking'
  192. return {
  193. '_type': 'url_transparent',
  194. 'id': video_id,
  195. 'display_id': display_id,
  196. 'url': embed_url,
  197. 'ie_key': ie_key,
  198. }