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.

97 lines
3.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .brightcove import BrightcoveNewIE
  4. from .common import InfoExtractor
  5. from ..compat import compat_str
  6. from ..utils import (
  7. int_or_none,
  8. smuggle_url,
  9. try_get,
  10. )
  11. class NoovoIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:[^/]+\.)?noovo\.ca/videos/(?P<id>[^/]+/[^/?#&]+)'
  13. _TESTS = [{
  14. # clip
  15. 'url': 'http://noovo.ca/videos/rpm-plus/chrysler-imperial',
  16. 'info_dict': {
  17. 'id': '5386045029001',
  18. 'ext': 'mp4',
  19. 'title': 'Chrysler Imperial',
  20. 'description': 'md5:de3c898d1eb810f3e6243e08c8b4a056',
  21. 'timestamp': 1491399228,
  22. 'upload_date': '20170405',
  23. 'uploader_id': '618566855001',
  24. 'creator': 'vtele',
  25. 'view_count': int,
  26. 'series': 'RPM+',
  27. },
  28. 'params': {
  29. 'skip_download': True,
  30. },
  31. }, {
  32. # episode
  33. 'url': 'http://noovo.ca/videos/l-amour-est-dans-le-pre/episode-13-8',
  34. 'info_dict': {
  35. 'id': '5395865725001',
  36. 'title': 'Épisode 13 : Les retrouvailles',
  37. 'description': 'md5:336d5ebc5436534e61d16e63ddfca327',
  38. 'ext': 'mp4',
  39. 'timestamp': 1492019320,
  40. 'upload_date': '20170412',
  41. 'uploader_id': '618566855001',
  42. 'creator': 'vtele',
  43. 'view_count': int,
  44. 'series': "L'amour est dans le pré",
  45. 'season_number': 5,
  46. 'episode': 'Épisode 13',
  47. 'episode_number': 13,
  48. },
  49. 'params': {
  50. 'skip_download': True,
  51. },
  52. }]
  53. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/618566855001/default_default/index.html?videoId=%s'
  54. def _real_extract(self, url):
  55. video_id = self._match_id(url)
  56. data = self._download_json(
  57. 'http://api.noovo.ca/api/v1/pages/single-episode/%s' % video_id,
  58. video_id)['data']
  59. content = try_get(data, lambda x: x['contents'][0])
  60. brightcove_id = data.get('brightcoveId') or content['brightcoveId']
  61. series = try_get(
  62. data, (
  63. lambda x: x['show']['title'],
  64. lambda x: x['season']['show']['title']),
  65. compat_str)
  66. episode = None
  67. og = data.get('og')
  68. if isinstance(og, dict) and og.get('type') == 'video.episode':
  69. episode = og.get('title')
  70. video = content or data
  71. return {
  72. '_type': 'url_transparent',
  73. 'ie_key': BrightcoveNewIE.ie_key(),
  74. 'url': smuggle_url(
  75. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
  76. {'geo_countries': ['CA']}),
  77. 'id': brightcove_id,
  78. 'title': video.get('title'),
  79. 'creator': video.get('source'),
  80. 'view_count': int_or_none(video.get('viewsCount')),
  81. 'series': series,
  82. 'season_number': int_or_none(try_get(
  83. data, lambda x: x['season']['seasonNumber'])),
  84. 'episode': episode,
  85. 'episode_number': int_or_none(data.get('episodeNumber')),
  86. }