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.

147 lines
5.9 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
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. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .brightcove import (
  4. BrightcoveLegacyIE,
  5. BrightcoveNewIE,
  6. )
  7. from .common import InfoExtractor
  8. from ..compat import compat_str
  9. from ..utils import (
  10. ExtractorError,
  11. sanitized_Request,
  12. )
  13. class NownessBaseIE(InfoExtractor):
  14. def _extract_url_result(self, post):
  15. if post['type'] == 'video':
  16. for media in post['media']:
  17. if media['type'] == 'video':
  18. video_id = media['content']
  19. source = media['source']
  20. if source == 'brightcove':
  21. player_code = self._download_webpage(
  22. 'http://www.nowness.com/iframe?id=%s' % video_id, video_id,
  23. note='Downloading player JavaScript',
  24. errnote='Unable to download player JavaScript')
  25. bc_url = BrightcoveLegacyIE._extract_brightcove_url(player_code)
  26. if bc_url:
  27. return self.url_result(bc_url, BrightcoveLegacyIE.ie_key())
  28. bc_url = BrightcoveNewIE._extract_url(player_code)
  29. if bc_url:
  30. return self.url_result(bc_url, BrightcoveNewIE.ie_key())
  31. raise ExtractorError('Could not find player definition')
  32. elif source == 'vimeo':
  33. return self.url_result('http://vimeo.com/%s' % video_id, 'Vimeo')
  34. elif source == 'youtube':
  35. return self.url_result(video_id, 'Youtube')
  36. elif source == 'cinematique':
  37. # youtube-dl currently doesn't support cinematique
  38. # return self.url_result('http://cinematique.com/embed/%s' % video_id, 'Cinematique')
  39. pass
  40. def _api_request(self, url, request_path):
  41. display_id = self._match_id(url)
  42. request = sanitized_Request(
  43. 'http://api.nowness.com/api/' + request_path % display_id,
  44. headers={
  45. 'X-Nowness-Language': 'zh-cn' if 'cn.nowness.com' in url else 'en-us',
  46. })
  47. return display_id, self._download_json(request, display_id)
  48. class NownessIE(NownessBaseIE):
  49. IE_NAME = 'nowness'
  50. _VALID_URL = r'https?://(?:(?:www|cn)\.)?nowness\.com/(?:story|(?:series|category)/[^/]+)/(?P<id>[^/]+?)(?:$|[?#])'
  51. _TESTS = [{
  52. 'url': 'https://www.nowness.com/story/candor-the-art-of-gesticulation',
  53. 'md5': '068bc0202558c2e391924cb8cc470676',
  54. 'info_dict': {
  55. 'id': '2520295746001',
  56. 'ext': 'mp4',
  57. 'title': 'Candor: The Art of Gesticulation',
  58. 'description': 'Candor: The Art of Gesticulation',
  59. 'thumbnail': 're:^https?://.*\.jpg',
  60. 'timestamp': 1446745676,
  61. 'upload_date': '20151105',
  62. 'uploader_id': '2385340575001',
  63. },
  64. 'add_ie': ['BrightcoveNew'],
  65. }, {
  66. 'url': 'https://cn.nowness.com/story/kasper-bjorke-ft-jaakko-eino-kalevi-tnr',
  67. 'md5': 'e79cf125e387216f86b2e0a5b5c63aa3',
  68. 'info_dict': {
  69. 'id': '3716354522001',
  70. 'ext': 'mp4',
  71. 'title': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
  72. 'description': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
  73. 'thumbnail': 're:^https?://.*\.jpg',
  74. 'timestamp': 1407315371,
  75. 'upload_date': '20140806',
  76. 'uploader_id': '2385340575001',
  77. },
  78. 'add_ie': ['BrightcoveNew'],
  79. }, {
  80. # vimeo
  81. 'url': 'https://www.nowness.com/series/nowness-picks/jean-luc-godard-supercut',
  82. 'md5': '9a5a6a8edf806407e411296ab6bc2a49',
  83. 'info_dict': {
  84. 'id': '130020913',
  85. 'ext': 'mp4',
  86. 'title': 'Bleu, Blanc, Rouge - A Godard Supercut',
  87. 'description': 'md5:f0ea5f1857dffca02dbd37875d742cec',
  88. 'thumbnail': 're:^https?://.*\.jpg',
  89. 'upload_date': '20150607',
  90. 'uploader': 'Cinema Sem Lei',
  91. 'uploader_id': 'cinemasemlei',
  92. },
  93. 'add_ie': ['Vimeo'],
  94. }]
  95. def _real_extract(self, url):
  96. _, post = self._api_request(url, 'post/getBySlug/%s')
  97. return self._extract_url_result(post)
  98. class NownessPlaylistIE(NownessBaseIE):
  99. IE_NAME = 'nowness:playlist'
  100. _VALID_URL = r'https?://(?:(?:www|cn)\.)?nowness\.com/playlist/(?P<id>\d+)'
  101. _TEST = {
  102. 'url': 'https://www.nowness.com/playlist/3286/i-guess-thats-why-they-call-it-the-blues',
  103. 'info_dict': {
  104. 'id': '3286',
  105. },
  106. 'playlist_mincount': 8,
  107. }
  108. def _real_extract(self, url):
  109. playlist_id, playlist = self._api_request(url, 'post?PlaylistId=%s')
  110. entries = [self._extract_url_result(item) for item in playlist['items']]
  111. return self.playlist_result(entries, playlist_id)
  112. class NownessSeriesIE(NownessBaseIE):
  113. IE_NAME = 'nowness:series'
  114. _VALID_URL = r'https?://(?:(?:www|cn)\.)?nowness\.com/series/(?P<id>[^/]+?)(?:$|[?#])'
  115. _TEST = {
  116. 'url': 'https://www.nowness.com/series/60-seconds',
  117. 'info_dict': {
  118. 'id': '60',
  119. 'title': '60 Seconds',
  120. 'description': 'One-minute wisdom in a new NOWNESS series',
  121. },
  122. 'playlist_mincount': 4,
  123. }
  124. def _real_extract(self, url):
  125. display_id, series = self._api_request(url, 'series/getBySlug/%s')
  126. entries = [self._extract_url_result(post) for post in series['posts']]
  127. series_title = None
  128. series_description = None
  129. translations = series.get('translations', [])
  130. if translations:
  131. series_title = translations[0].get('title') or translations[0]['seoTitle']
  132. series_description = translations[0].get('seoDescription')
  133. return self.playlist_result(
  134. entries, compat_str(series['id']), series_title, series_description)