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