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.

64 lines
2.2 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .brightcove import BrightcoveIE
  5. from .common import InfoExtractor
  6. from ..utils import ExtractorError
  7. class NownessIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:(?:www|cn)\.)?nowness\.com/[^?#]*?/(?P<id>[0-9]+)/(?P<slug>[^/]+?)(?:$|[?#])'
  9. _TESTS = [
  10. {
  11. 'url': 'http://www.nowness.com/day/2013/6/27/3131/candor--the-art-of-gesticulation',
  12. 'md5': '068bc0202558c2e391924cb8cc470676',
  13. 'info_dict': {
  14. 'id': '2520295746001',
  15. 'ext': 'mp4',
  16. 'title': 'Candor: The Art of Gesticulation',
  17. 'description': 'Candor: The Art of Gesticulation',
  18. 'thumbnail': 're:^https?://.*\.jpg',
  19. 'uploader': 'Nowness',
  20. }
  21. },
  22. {
  23. 'url': 'http://cn.nowness.com/day/2014/8/7/4069/kasper-bj-rke-ft-jaakko-eino-kalevi--tnr',
  24. 'md5': 'e79cf125e387216f86b2e0a5b5c63aa3',
  25. 'info_dict': {
  26. 'id': '3716354522001',
  27. 'ext': 'mp4',
  28. 'title': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
  29. 'description': 'Kasper Bjørke ft. Jaakko Eino Kalevi: TNR',
  30. 'thumbnail': 're:^https?://.*\.jpg',
  31. 'uploader': 'Nowness',
  32. }
  33. },
  34. ]
  35. def _real_extract(self, url):
  36. mobj = re.match(self._VALID_URL, url)
  37. video_id = mobj.group('slug')
  38. webpage = self._download_webpage(url, video_id)
  39. player_url = self._search_regex(
  40. r'"([^"]+/content/issue-[0-9.]+.js)"', webpage, 'player URL')
  41. real_id = self._search_regex(
  42. r'\sdata-videoId="([0-9]+)"', webpage, 'internal video ID')
  43. player_code = self._download_webpage(
  44. player_url, video_id,
  45. note='Downloading player JavaScript',
  46. errnote='Player download failed')
  47. player_code = player_code.replace("'+d+'", real_id)
  48. bc_url = BrightcoveIE._extract_brightcove_url(player_code)
  49. if bc_url is None:
  50. raise ExtractorError('Could not find player definition')
  51. return {
  52. '_type': 'url',
  53. 'url': bc_url,
  54. 'ie_key': 'Brightcove',
  55. }