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.

48 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .brightcove import BrightcoveIE
  4. from .common import InfoExtractor
  5. from ..utils import ExtractorError
  6. class NownessIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?nowness\.com/[^?#]*?/(?P<id>[0-9]+)/(?P<slug>[^/]+?)(?:$|[?#])'
  8. _TEST = {
  9. 'url': 'http://www.nowness.com/day/2013/6/27/3131/candor--the-art-of-gesticulation',
  10. 'md5': '068bc0202558c2e391924cb8cc470676',
  11. 'info_dict': {
  12. 'id': '2520295746001',
  13. 'ext': 'mp4',
  14. 'description': 'Candor: The Art of Gesticulation',
  15. 'uploader': 'Nowness',
  16. 'title': 'Candor: The Art of Gesticulation',
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('slug')
  22. webpage = self._download_webpage(url, video_id)
  23. player_url = self._search_regex(
  24. r'"([^"]+/content/issue-[0-9.]+.js)"', webpage, 'player URL')
  25. real_id = self._search_regex(
  26. r'\sdata-videoId="([0-9]+)"', webpage, 'internal video ID')
  27. player_code = self._download_webpage(
  28. player_url, video_id,
  29. note='Downloading player JavaScript',
  30. errnote='Player download failed')
  31. player_code = player_code.replace("'+d+'", real_id)
  32. bc_url = BrightcoveIE._extract_brightcove_url(player_code)
  33. if bc_url is None:
  34. raise ExtractorError('Could not find player definition')
  35. return {
  36. '_type': 'url',
  37. 'url': bc_url,
  38. 'ie_key': 'Brightcove',
  39. }