]>
Commit | Line | Data |
---|---|---|
6b54cccd AH |
1 | import functools |
2 | import re | |
3 | ||
94636378 | 4 | from .common import InfoExtractor |
6b54cccd AH |
5 | from ..utils import float_or_none, int_or_none, smuggle_url, strip_or_none |
6 | from ..utils.traversal import traverse_obj | |
94636378 RA |
7 | |
8 | ||
9 | class TVAIE(InfoExtractor): | |
49357497 S |
10 | _VALID_URL = r'https?://videos?\.tva\.ca/details/_(?P<id>\d+)' |
11 | _TESTS = [{ | |
5fe75f97 | 12 | 'url': 'https://videos.tva.ca/details/_5596811470001', |
94636378 | 13 | 'info_dict': { |
5fe75f97 | 14 | 'id': '5596811470001', |
94636378 | 15 | 'ext': 'mp4', |
5fe75f97 RA |
16 | 'title': 'Un extrait de l\'épisode du dimanche 8 octobre 2017 !', |
17 | 'uploader_id': '5481942443001', | |
18 | 'upload_date': '20171003', | |
19 | 'timestamp': 1507064617, | |
94636378 RA |
20 | }, |
21 | 'params': { | |
22 | # m3u8 download | |
23 | 'skip_download': True, | |
29f7c58a | 24 | }, |
25 | 'skip': 'HTTP Error 404: Not Found', | |
49357497 S |
26 | }, { |
27 | 'url': 'https://video.tva.ca/details/_5596811470001', | |
28 | 'only_matching': True, | |
29 | }] | |
5fe75f97 | 30 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s' |
94636378 RA |
31 | |
32 | def _real_extract(self, url): | |
33 | video_id = self._match_id(url) | |
94636378 RA |
34 | |
35 | return { | |
36 | '_type': 'url_transparent', | |
37 | 'id': video_id, | |
5fe75f97 | 38 | 'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}), |
5fe75f97 | 39 | 'ie_key': 'BrightcoveNew', |
94636378 | 40 | } |
29f7c58a | 41 | |
42 | ||
43 | class QubIE(InfoExtractor): | |
44 | _VALID_URL = r'https?://(?:www\.)?qub\.ca/(?:[^/]+/)*[0-9a-z-]+-(?P<id>\d+)' | |
45 | _TESTS = [{ | |
46 | 'url': 'https://www.qub.ca/tvaplus/tva/alerte-amber/saison-1/episode-01-1000036619', | |
47 | 'md5': '949490fd0e7aee11d0543777611fbd53', | |
48 | 'info_dict': { | |
49 | 'id': '6084352463001', | |
50 | 'ext': 'mp4', | |
6b54cccd | 51 | 'title': 'Ép 01. Mon dernier jour', |
29f7c58a | 52 | 'uploader_id': '5481942443001', |
53 | 'upload_date': '20190907', | |
54 | 'timestamp': 1567899756, | |
55 | 'description': 'md5:9c0d7fbb90939420c651fd977df90145', | |
6b54cccd AH |
56 | 'thumbnail': r're:https://.+\.jpg', |
57 | 'episode': 'Ép 01. Mon dernier jour', | |
58 | 'episode_number': 1, | |
59 | 'tags': ['alerte amber', 'alerte amber saison 1', 'surdemande'], | |
60 | 'duration': 2625.963, | |
61 | 'season': 'Season 1', | |
62 | 'season_number': 1, | |
63 | 'series': 'Alerte Amber', | |
64 | 'channel': 'TVA', | |
29f7c58a | 65 | }, |
66 | }, { | |
67 | 'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943', | |
68 | 'only_matching': True, | |
69 | }] | |
70 | # reference_id also works with old account_id(5481942443001) | |
71 | # BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5813221784001/default_default/index.html?videoId=ref:%s' | |
72 | ||
73 | def _real_extract(self, url): | |
74 | entity_id = self._match_id(url) | |
6b54cccd AH |
75 | webpage = self._download_webpage(url, entity_id) |
76 | entity = self._search_nextjs_data(webpage, entity_id)['props']['initialProps']['pageProps']['fallbackData'] | |
29f7c58a | 77 | video_id = entity['videoId'] |
78 | episode = strip_or_none(entity.get('name')) | |
79 | ||
80 | return { | |
81 | '_type': 'url_transparent', | |
6b54cccd AH |
82 | 'url': f'https://videos.tva.ca/details/_{video_id}', |
83 | 'ie_key': TVAIE.ie_key(), | |
29f7c58a | 84 | 'id': video_id, |
85 | 'title': episode, | |
29f7c58a | 86 | 'episode': episode, |
6b54cccd AH |
87 | **traverse_obj(entity, { |
88 | 'description': ('longDescription', {str}), | |
89 | 'duration': ('durationMillis', {functools.partial(float_or_none, scale=1000)}), | |
90 | 'channel': ('knownEntities', 'channel', 'name', {str}), | |
91 | 'series': ('knownEntities', 'videoShow', 'name', {str}), | |
92 | 'season_number': ('slug', {lambda x: re.search(r'/s(?:ai|ea)son-(\d+)/', x)}, 1, {int_or_none}), | |
93 | 'episode_number': ('episodeNumber', {int_or_none}), | |
94 | }), | |
29f7c58a | 95 | } |