mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.6 KiB
Python
105 lines
3.6 KiB
Python
8 years ago
|
# coding: utf-8
|
||
|
from __future__ import unicode_literals
|
||
8 years ago
|
|
||
|
from .brightcove import BrightcoveNewIE
|
||
8 years ago
|
from .common import InfoExtractor
|
||
8 years ago
|
from ..compat import compat_str
|
||
|
from ..utils import (
|
||
|
int_or_none,
|
||
7 years ago
|
js_to_json,
|
||
8 years ago
|
smuggle_url,
|
||
|
try_get,
|
||
|
)
|
||
8 years ago
|
|
||
|
|
||
|
class NoovoIE(InfoExtractor):
|
||
8 years ago
|
_VALID_URL = r'https?://(?:[^/]+\.)?noovo\.ca/videos/(?P<id>[^/]+/[^/?#&]+)'
|
||
8 years ago
|
_TESTS = [{
|
||
8 years ago
|
# clip
|
||
8 years ago
|
'url': 'http://noovo.ca/videos/rpm-plus/chrysler-imperial',
|
||
|
'info_dict': {
|
||
|
'id': '5386045029001',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Chrysler Imperial',
|
||
8 years ago
|
'description': 'md5:de3c898d1eb810f3e6243e08c8b4a056',
|
||
|
'timestamp': 1491399228,
|
||
8 years ago
|
'upload_date': '20170405',
|
||
8 years ago
|
'uploader_id': '618566855001',
|
||
|
'series': 'RPM+',
|
||
|
},
|
||
|
'params': {
|
||
|
'skip_download': True,
|
||
|
},
|
||
8 years ago
|
}, {
|
||
8 years ago
|
# episode
|
||
8 years ago
|
'url': 'http://noovo.ca/videos/l-amour-est-dans-le-pre/episode-13-8',
|
||
|
'info_dict': {
|
||
|
'id': '5395865725001',
|
||
8 years ago
|
'title': 'Épisode 13 : Les retrouvailles',
|
||
7 years ago
|
'description': 'md5:888c3330f0c1b4476c5bc99a1c040473',
|
||
8 years ago
|
'ext': 'mp4',
|
||
|
'timestamp': 1492019320,
|
||
|
'upload_date': '20170412',
|
||
8 years ago
|
'uploader_id': '618566855001',
|
||
|
'series': "L'amour est dans le pré",
|
||
|
'season_number': 5,
|
||
|
'episode': 'Épisode 13',
|
||
|
'episode_number': 13,
|
||
|
},
|
||
|
'params': {
|
||
|
'skip_download': True,
|
||
|
},
|
||
8 years ago
|
}]
|
||
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/618566855001/default_default/index.html?videoId=%s'
|
||
|
|
||
|
def _real_extract(self, url):
|
||
|
video_id = self._match_id(url)
|
||
|
|
||
7 years ago
|
webpage = self._download_webpage(url, video_id)
|
||
8 years ago
|
|
||
6 years ago
|
brightcove_id = self._search_regex(
|
||
|
r'data-video-id=["\'](\d+)', webpage, 'brightcove id')
|
||
8 years ago
|
|
||
7 years ago
|
data = self._parse_json(
|
||
|
self._search_regex(
|
||
|
r'(?s)dataLayer\.push\(\s*({.+?})\s*\);', webpage, 'data',
|
||
|
default='{}'),
|
||
|
video_id, transform_source=js_to_json, fatal=False)
|
||
|
|
||
|
title = try_get(
|
||
|
data, lambda x: x['video']['nom'],
|
||
|
compat_str) or self._html_search_meta(
|
||
|
'dcterms.Title', webpage, 'title', fatal=True)
|
||
|
|
||
|
description = self._html_search_meta(
|
||
|
('dcterms.Description', 'description'), webpage, 'description')
|
||
8 years ago
|
|
||
|
series = try_get(
|
||
7 years ago
|
data, lambda x: x['emission']['nom']) or self._search_regex(
|
||
|
r'<div[^>]+class="banner-card__subtitle h4"[^>]*>([^<]+)',
|
||
|
webpage, 'series', default=None)
|
||
8 years ago
|
|
||
7 years ago
|
season_el = try_get(data, lambda x: x['emission']['saison'], dict) or {}
|
||
|
season = try_get(season_el, lambda x: x['nom'], compat_str)
|
||
|
season_number = int_or_none(try_get(season_el, lambda x: x['numero']))
|
||
8 years ago
|
|
||
7 years ago
|
episode_el = try_get(season_el, lambda x: x['episode'], dict) or {}
|
||
|
episode = try_get(episode_el, lambda x: x['nom'], compat_str)
|
||
|
episode_number = int_or_none(try_get(episode_el, lambda x: x['numero']))
|
||
8 years ago
|
|
||
|
return {
|
||
|
'_type': 'url_transparent',
|
||
|
'ie_key': BrightcoveNewIE.ie_key(),
|
||
6 years ago
|
'url': smuggle_url(
|
||
|
self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
|
||
|
{'geo_countries': ['CA']}),
|
||
|
'id': brightcove_id,
|
||
7 years ago
|
'title': title,
|
||
|
'description': description,
|
||
8 years ago
|
'series': series,
|
||
7 years ago
|
'season': season,
|
||
|
'season_number': season_number,
|
||
8 years ago
|
'episode': episode,
|
||
7 years ago
|
'episode_number': episode_number,
|
||
8 years ago
|
}
|