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.

100 lines
3.4 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. js_to_json,
  9. smuggle_url,
  10. try_get,
  11. )
  12. class NoovoIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:[^/]+\.)?noovo\.ca/videos/(?P<id>[^/]+/[^/?#&]+)'
  14. _TESTS = [{
  15. # clip
  16. 'url': 'http://noovo.ca/videos/rpm-plus/chrysler-imperial',
  17. 'info_dict': {
  18. 'id': '5386045029001',
  19. 'ext': 'mp4',
  20. 'title': 'Chrysler Imperial',
  21. 'description': 'md5:de3c898d1eb810f3e6243e08c8b4a056',
  22. 'timestamp': 1491399228,
  23. 'upload_date': '20170405',
  24. 'uploader_id': '618566855001',
  25. 'series': 'RPM+',
  26. },
  27. 'params': {
  28. 'skip_download': True,
  29. },
  30. }, {
  31. # episode
  32. 'url': 'http://noovo.ca/videos/l-amour-est-dans-le-pre/episode-13-8',
  33. 'info_dict': {
  34. 'id': '5395865725001',
  35. 'title': 'Épisode 13 : Les retrouvailles',
  36. 'description': 'md5:888c3330f0c1b4476c5bc99a1c040473',
  37. 'ext': 'mp4',
  38. 'timestamp': 1492019320,
  39. 'upload_date': '20170412',
  40. 'uploader_id': '618566855001',
  41. 'series': "L'amour est dans le pré",
  42. 'season_number': 5,
  43. 'episode': 'Épisode 13',
  44. 'episode_number': 13,
  45. },
  46. 'params': {
  47. 'skip_download': True,
  48. },
  49. }]
  50. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/618566855001/default_default/index.html?videoId=%s'
  51. def _real_extract(self, url):
  52. video_id = self._match_id(url)
  53. webpage = self._download_webpage(url, video_id)
  54. bc_url = BrightcoveNewIE._extract_url(self, webpage)
  55. data = self._parse_json(
  56. self._search_regex(
  57. r'(?s)dataLayer\.push\(\s*({.+?})\s*\);', webpage, 'data',
  58. default='{}'),
  59. video_id, transform_source=js_to_json, fatal=False)
  60. title = try_get(
  61. data, lambda x: x['video']['nom'],
  62. compat_str) or self._html_search_meta(
  63. 'dcterms.Title', webpage, 'title', fatal=True)
  64. description = self._html_search_meta(
  65. ('dcterms.Description', 'description'), webpage, 'description')
  66. series = try_get(
  67. data, lambda x: x['emission']['nom']) or self._search_regex(
  68. r'<div[^>]+class="banner-card__subtitle h4"[^>]*>([^<]+)',
  69. webpage, 'series', default=None)
  70. season_el = try_get(data, lambda x: x['emission']['saison'], dict) or {}
  71. season = try_get(season_el, lambda x: x['nom'], compat_str)
  72. season_number = int_or_none(try_get(season_el, lambda x: x['numero']))
  73. episode_el = try_get(season_el, lambda x: x['episode'], dict) or {}
  74. episode = try_get(episode_el, lambda x: x['nom'], compat_str)
  75. episode_number = int_or_none(try_get(episode_el, lambda x: x['numero']))
  76. return {
  77. '_type': 'url_transparent',
  78. 'ie_key': BrightcoveNewIE.ie_key(),
  79. 'url': smuggle_url(bc_url, {'geo_countries': ['CA']}),
  80. 'title': title,
  81. 'description': description,
  82. 'series': series,
  83. 'season': season,
  84. 'season_number': season_number,
  85. 'episode': episode,
  86. 'episode_number': episode_number,
  87. }