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