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