]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tva.py
9afe233284e6365800806740fb815c3c9839126b
[yt-dlp.git] / yt_dlp / extractor / tva.py
1 from .common import InfoExtractor
2 from ..utils import (
3 float_or_none,
4 int_or_none,
5 smuggle_url,
6 strip_or_none,
7 )
8
9
10 class TVAIE(InfoExtractor):
11 _VALID_URL = r'https?://videos?\.tva\.ca/details/_(?P<id>\d+)'
12 _TESTS = [{
13 'url': 'https://videos.tva.ca/details/_5596811470001',
14 'info_dict': {
15 'id': '5596811470001',
16 'ext': 'mp4',
17 'title': 'Un extrait de l\'Ă©pisode du dimanche 8 octobre 2017 !',
18 'uploader_id': '5481942443001',
19 'upload_date': '20171003',
20 'timestamp': 1507064617,
21 },
22 'params': {
23 # m3u8 download
24 'skip_download': True,
25 },
26 'skip': 'HTTP Error 404: Not Found',
27 }, {
28 'url': 'https://video.tva.ca/details/_5596811470001',
29 'only_matching': True,
30 }]
31 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s'
32
33 def _real_extract(self, url):
34 video_id = self._match_id(url)
35
36 return {
37 '_type': 'url_transparent',
38 'id': video_id,
39 'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
40 'ie_key': 'BrightcoveNew',
41 }
42
43
44 class QubIE(InfoExtractor):
45 _VALID_URL = r'https?://(?:www\.)?qub\.ca/(?:[^/]+/)*[0-9a-z-]+-(?P<id>\d+)'
46 _TESTS = [{
47 'url': 'https://www.qub.ca/tvaplus/tva/alerte-amber/saison-1/episode-01-1000036619',
48 'md5': '949490fd0e7aee11d0543777611fbd53',
49 'info_dict': {
50 'id': '6084352463001',
51 'ext': 'mp4',
52 'title': 'Épisode 01',
53 'uploader_id': '5481942443001',
54 'upload_date': '20190907',
55 'timestamp': 1567899756,
56 'description': 'md5:9c0d7fbb90939420c651fd977df90145',
57 },
58 }, {
59 'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
60 'only_matching': True,
61 }]
62 # reference_id also works with old account_id(5481942443001)
63 # BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5813221784001/default_default/index.html?videoId=ref:%s'
64
65 def _real_extract(self, url):
66 entity_id = self._match_id(url)
67 entity = self._download_json(
68 'https://www.qub.ca/proxy/pfu/content-delivery-service/v1/entities',
69 entity_id, query={'id': entity_id})
70 video_id = entity['videoId']
71 episode = strip_or_none(entity.get('name'))
72
73 return {
74 '_type': 'url_transparent',
75 'id': video_id,
76 'title': episode,
77 # 'url': self.BRIGHTCOVE_URL_TEMPLATE % entity['referenceId'],
78 'url': 'https://videos.tva.ca/details/_' + video_id,
79 'description': entity.get('longDescription'),
80 'duration': float_or_none(entity.get('durationMillis'), 1000),
81 'episode': episode,
82 'episode_number': int_or_none(entity.get('episodeNumber')),
83 # 'ie_key': 'BrightcoveNew',
84 'ie_key': TVAIE.ie_key(),
85 }