]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/noovo.py
[YoutubeDL] Ensure dir existence for each requested format (closes #14116)
[yt-dlp.git] / youtube_dl / extractor / noovo.py
CommitLineData
1c7c76e4
FB
1# coding: utf-8
2from __future__ import unicode_literals
b5c39537
S
3
4from .brightcove import BrightcoveNewIE
1c7c76e4 5from .common import InfoExtractor
b5c39537
S
6from ..compat import compat_str
7from ..utils import (
8 int_or_none,
9 smuggle_url,
10 try_get,
11)
1c7c76e4
FB
12
13
14class NoovoIE(InfoExtractor):
b5c39537 15 _VALID_URL = r'https?://(?:[^/]+\.)?noovo\.ca/videos/(?P<id>[^/]+/[^/?#&]+)'
1c7c76e4 16 _TESTS = [{
b5c39537 17 # clip
1c7c76e4 18 'url': 'http://noovo.ca/videos/rpm-plus/chrysler-imperial',
1c7c76e4
FB
19 'info_dict': {
20 'id': '5386045029001',
1c7c76e4 21 'ext': 'mp4',
1c7c76e4 22 'title': 'Chrysler Imperial',
b5c39537
S
23 'description': 'md5:de3c898d1eb810f3e6243e08c8b4a056',
24 'timestamp': 1491399228,
1c7c76e4 25 'upload_date': '20170405',
b5c39537
S
26 'uploader_id': '618566855001',
27 'creator': 'vtele',
28 'view_count': int,
29 'series': 'RPM+',
30 },
31 'params': {
32 'skip_download': True,
33 },
1c7c76e4 34 }, {
b5c39537 35 # episode
1c7c76e4 36 'url': 'http://noovo.ca/videos/l-amour-est-dans-le-pre/episode-13-8',
1c7c76e4
FB
37 'info_dict': {
38 'id': '5395865725001',
b5c39537 39 'title': 'Épisode 13 : Les retrouvailles',
1c7c76e4
FB
40 'description': 'md5:336d5ebc5436534e61d16e63ddfca327',
41 'ext': 'mp4',
42 'timestamp': 1492019320,
1c7c76e4 43 'upload_date': '20170412',
b5c39537
S
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 },
1c7c76e4 55 }]
1c7c76e4
FB
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)
1c7c76e4 60
b5c39537
S
61 data = self._download_json(
62 'http://api.noovo.ca/api/v1/pages/single-episode/%s' % video_id,
63 video_id)['data']
1c7c76e4 64
b5c39537
S
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 }