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.

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