]>
Commit | Line | Data |
---|---|---|
1 | import functools | |
2 | import re | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..utils import float_or_none, int_or_none, smuggle_url, strip_or_none | |
6 | from ..utils.traversal import traverse_obj | |
7 | ||
8 | ||
9 | class TVAIE(InfoExtractor): | |
10 | _VALID_URL = r'https?://videos?\.tva\.ca/details/_(?P<id>\d+)' | |
11 | _TESTS = [{ | |
12 | 'url': 'https://videos.tva.ca/details/_5596811470001', | |
13 | 'info_dict': { | |
14 | 'id': '5596811470001', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'Un extrait de l\'épisode du dimanche 8 octobre 2017 !', | |
17 | 'uploader_id': '5481942443001', | |
18 | 'upload_date': '20171003', | |
19 | 'timestamp': 1507064617, | |
20 | }, | |
21 | 'params': { | |
22 | # m3u8 download | |
23 | 'skip_download': True, | |
24 | }, | |
25 | 'skip': 'HTTP Error 404: Not Found', | |
26 | }, { | |
27 | 'url': 'https://video.tva.ca/details/_5596811470001', | |
28 | 'only_matching': True, | |
29 | }] | |
30 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s' | |
31 | ||
32 | def _real_extract(self, url): | |
33 | video_id = self._match_id(url) | |
34 | ||
35 | return { | |
36 | '_type': 'url_transparent', | |
37 | 'id': video_id, | |
38 | 'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}), | |
39 | 'ie_key': 'BrightcoveNew', | |
40 | } | |
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', | |
51 | 'title': 'Ép 01. Mon dernier jour', | |
52 | 'uploader_id': '5481942443001', | |
53 | 'upload_date': '20190907', | |
54 | 'timestamp': 1567899756, | |
55 | 'description': 'md5:9c0d7fbb90939420c651fd977df90145', | |
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', | |
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) | |
75 | webpage = self._download_webpage(url, entity_id) | |
76 | entity = self._search_nextjs_data(webpage, entity_id)['props']['initialProps']['pageProps']['fallbackData'] | |
77 | video_id = entity['videoId'] | |
78 | episode = strip_or_none(entity.get('name')) | |
79 | ||
80 | return { | |
81 | '_type': 'url_transparent', | |
82 | 'url': f'https://videos.tva.ca/details/_{video_id}', | |
83 | 'ie_key': TVAIE.ie_key(), | |
84 | 'id': video_id, | |
85 | 'title': episode, | |
86 | 'episode': episode, | |
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 | }), | |
95 | } |