Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

189 Zeilen
7.1KB

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