You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
6.0 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. HEADRequest,
  6. sanitized_Request,
  7. urlencode_postdata,
  8. )
  9. class GDCVaultIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?gdcvault\.com/play/(?P<id>\d+)/(?P<name>(\w|-)+)?'
  11. _NETRC_MACHINE = 'gdcvault'
  12. _TESTS = [
  13. {
  14. 'url': 'http://www.gdcvault.com/play/1019721/Doki-Doki-Universe-Sweet-Simple',
  15. 'md5': '7ce8388f544c88b7ac11c7ab1b593704',
  16. 'info_dict': {
  17. 'id': '1019721',
  18. 'display_id': 'Doki-Doki-Universe-Sweet-Simple',
  19. 'ext': 'mp4',
  20. 'title': 'Doki-Doki Universe: Sweet, Simple and Genuine (GDC Next 10)'
  21. }
  22. },
  23. {
  24. 'url': 'http://www.gdcvault.com/play/1015683/Embracing-the-Dark-Art-of',
  25. 'info_dict': {
  26. 'id': '1015683',
  27. 'display_id': 'Embracing-the-Dark-Art-of',
  28. 'ext': 'flv',
  29. 'title': 'Embracing the Dark Art of Mathematical Modeling in AI'
  30. },
  31. 'params': {
  32. 'skip_download': True, # Requires rtmpdump
  33. }
  34. },
  35. {
  36. 'url': 'http://www.gdcvault.com/play/1015301/Thexder-Meets-Windows-95-or',
  37. 'md5': 'a5eb77996ef82118afbbe8e48731b98e',
  38. 'info_dict': {
  39. 'id': '1015301',
  40. 'display_id': 'Thexder-Meets-Windows-95-or',
  41. 'ext': 'flv',
  42. 'title': 'Thexder Meets Windows 95, or Writing Great Games in the Windows 95 Environment',
  43. },
  44. 'skip': 'Requires login',
  45. },
  46. {
  47. 'url': 'http://gdcvault.com/play/1020791/',
  48. 'only_matching': True,
  49. },
  50. {
  51. # Hard-coded hostname
  52. 'url': 'http://gdcvault.com/play/1023460/Tenacious-Design-and-The-Interface',
  53. 'md5': 'a8efb6c31ed06ca8739294960b2dbabd',
  54. 'info_dict': {
  55. 'id': '1023460',
  56. 'ext': 'mp4',
  57. 'display_id': 'Tenacious-Design-and-The-Interface',
  58. 'title': 'Tenacious Design and The Interface of \'Destiny\'',
  59. },
  60. },
  61. {
  62. # Multiple audios
  63. 'url': 'http://www.gdcvault.com/play/1014631/Classic-Game-Postmortem-PAC',
  64. 'info_dict': {
  65. 'id': '1014631',
  66. 'ext': 'flv',
  67. 'title': 'How to Create a Good Game - From My Experience of Designing Pac-Man',
  68. },
  69. 'params': {
  70. 'skip_download': True, # Requires rtmpdump
  71. 'format': 'jp', # The japanese audio
  72. }
  73. },
  74. ]
  75. def _login(self, webpage_url, display_id):
  76. (username, password) = self._get_login_info()
  77. if username is None or password is None:
  78. self.report_warning('It looks like ' + webpage_url + ' requires a login. Try specifying a username and password and try again.')
  79. return None
  80. mobj = re.match(r'(?P<root_url>https?://.*?/).*', webpage_url)
  81. login_url = mobj.group('root_url') + 'api/login.php'
  82. logout_url = mobj.group('root_url') + 'logout'
  83. login_form = {
  84. 'email': username,
  85. 'password': password,
  86. }
  87. request = sanitized_Request(login_url, urlencode_postdata(login_form))
  88. request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  89. self._download_webpage(request, display_id, 'Logging in')
  90. start_page = self._download_webpage(webpage_url, display_id, 'Getting authenticated video page')
  91. self._download_webpage(logout_url, display_id, 'Logging out')
  92. return start_page
  93. def _real_extract(self, url):
  94. mobj = re.match(self._VALID_URL, url)
  95. video_id = mobj.group('id')
  96. display_id = mobj.group('name') or video_id
  97. webpage_url = 'http://www.gdcvault.com/play/' + video_id
  98. start_page = self._download_webpage(webpage_url, display_id)
  99. direct_url = self._search_regex(
  100. r's1\.addVariable\("file",\s*encodeURIComponent\("(/[^"]+)"\)\);',
  101. start_page, 'url', default=None)
  102. if direct_url:
  103. title = self._html_search_regex(
  104. r'<td><strong>Session Name</strong></td>\s*<td>(.*?)</td>',
  105. start_page, 'title')
  106. video_url = 'http://www.gdcvault.com' + direct_url
  107. # resolve the url so that we can detect the correct extension
  108. head = self._request_webpage(HEADRequest(video_url), video_id)
  109. video_url = head.geturl()
  110. return {
  111. 'id': video_id,
  112. 'display_id': display_id,
  113. 'url': video_url,
  114. 'title': title,
  115. }
  116. PLAYER_REGEX = r'<iframe src="(?P<xml_root>.+?)/player.*?\.html.*?".*?</iframe>'
  117. xml_root = self._html_search_regex(
  118. PLAYER_REGEX, start_page, 'xml root', default=None)
  119. if xml_root is None:
  120. # Probably need to authenticate
  121. login_res = self._login(webpage_url, display_id)
  122. if login_res is None:
  123. self.report_warning('Could not login.')
  124. else:
  125. start_page = login_res
  126. # Grab the url from the authenticated page
  127. xml_root = self._html_search_regex(
  128. PLAYER_REGEX, start_page, 'xml root')
  129. xml_name = self._html_search_regex(
  130. r'<iframe src=".*?\?xml=(.+?\.xml).*?".*?</iframe>',
  131. start_page, 'xml filename', default=None)
  132. if xml_name is None:
  133. # Fallback to the older format
  134. xml_name = self._html_search_regex(
  135. r'<iframe src=".*?\?xmlURL=xml/(?P<xml_file>.+?\.xml).*?".*?</iframe>',
  136. start_page, 'xml filename')
  137. return {
  138. '_type': 'url_transparent',
  139. 'id': video_id,
  140. 'display_id': display_id,
  141. 'url': '%s/xml/%s' % (xml_root, xml_name),
  142. 'ie_key': 'DigitallySpeaking',
  143. }