]>
Commit | Line | Data |
---|---|---|
4d5726b0 | 1 | from .common import InfoExtractor |
d7344d33 | 2 | from ..compat import compat_str |
33dc173c RA |
3 | from ..utils import ( |
4 | int_or_none, | |
5 | smuggle_url, | |
d7344d33 | 6 | try_get, |
05446d48 | 7 | unified_timestamp, |
33dc173c | 8 | ) |
4d5726b0 RA |
9 | |
10 | ||
9306b0c8 | 11 | class TeleQuebecBaseIE(InfoExtractor): |
29f7c58a | 12 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/%s_default/index.html?videoId=%s' |
13 | ||
9306b0c8 | 14 | @staticmethod |
29f7c58a | 15 | def _brightcove_result(brightcove_id, player_id, account_id='6150020952001'): |
9306b0c8 S |
16 | return { |
17 | '_type': 'url_transparent', | |
29f7c58a | 18 | 'url': smuggle_url(TeleQuebecBaseIE.BRIGHTCOVE_URL_TEMPLATE % (account_id, player_id, brightcove_id), {'geo_countries': ['CA']}), |
19 | 'ie_key': 'BrightcoveNew', | |
9306b0c8 S |
20 | } |
21 | ||
22 | ||
23 | class TeleQuebecIE(TeleQuebecBaseIE): | |
c2915de8 PL |
24 | _VALID_URL = r'''(?x) |
25 | https?:// | |
26 | (?: | |
27 | zonevideo\.telequebec\.tv/media| | |
28 | coucou\.telequebec\.tv/videos | |
29 | )/(?P<id>\d+) | |
30 | ''' | |
d7344d33 | 31 | _TESTS = [{ |
9306b0c8 S |
32 | # available till 01.01.2023 |
33 | 'url': 'http://zonevideo.telequebec.tv/media/37578/un-petit-choc-et-puis-repart/un-chef-a-la-cabane', | |
4d5726b0 | 34 | 'info_dict': { |
29f7c58a | 35 | 'id': '6155972771001', |
4d5726b0 | 36 | 'ext': 'mp4', |
9306b0c8 | 37 | 'title': 'Un petit choc et puis repart!', |
29f7c58a | 38 | 'description': 'md5:b04a7e6b3f74e32d7b294cffe8658374', |
39 | 'timestamp': 1589262469, | |
40 | 'uploader_id': '6150020952001', | |
41 | 'upload_date': '20200512', | |
9306b0c8 | 42 | }, |
29f7c58a | 43 | 'add_ie': ['BrightcoveNew'], |
82ef02e9 S |
44 | }, { |
45 | 'url': 'https://zonevideo.telequebec.tv/media/55267/le-soleil/passe-partout', | |
46 | 'info_dict': { | |
47 | 'id': '6167180337001', | |
48 | 'ext': 'mp4', | |
49 | 'title': 'Le soleil', | |
50 | 'description': 'md5:64289c922a8de2abbe99c354daffde02', | |
51 | 'uploader_id': '6150020952001', | |
52 | 'upload_date': '20200625', | |
53 | 'timestamp': 1593090307, | |
54 | }, | |
82ef02e9 | 55 | 'add_ie': ['BrightcoveNew'], |
d7344d33 S |
56 | }, { |
57 | # no description | |
58 | 'url': 'http://zonevideo.telequebec.tv/media/30261', | |
59 | 'only_matching': True, | |
c2915de8 PL |
60 | }, { |
61 | 'url': 'https://coucou.telequebec.tv/videos/41788/idee-de-genie/l-heure-du-bain', | |
62 | 'only_matching': True, | |
d7344d33 | 63 | }] |
4d5726b0 RA |
64 | |
65 | def _real_extract(self, url): | |
66 | media_id = self._match_id(url) | |
29f7c58a | 67 | media = self._download_json( |
68 | 'https://mnmedias.api.telequebec.tv/api/v3/media/' + media_id, | |
4d5726b0 | 69 | media_id)['media'] |
29f7c58a | 70 | source_id = next(source_info['sourceId'] for source_info in media['streamInfos'] if source_info.get('source') == 'Brightcove') |
71 | info = self._brightcove_result(source_id, '22gPKdt7f') | |
72 | product = media.get('product') or {} | |
73 | season = product.get('season') or {} | |
9306b0c8 | 74 | info.update({ |
29f7c58a | 75 | 'description': try_get(media, lambda x: x['descriptions'][-1]['text'], compat_str), |
76 | 'series': try_get(season, lambda x: x['serie']['titre']), | |
77 | 'season': season.get('name'), | |
78 | 'season_number': int_or_none(season.get('seasonNo')), | |
79 | 'episode': product.get('titre'), | |
80 | 'episode_number': int_or_none(product.get('episodeNo')), | |
9306b0c8 S |
81 | }) |
82 | return info | |
83 | ||
84 | ||
05446d48 S |
85 | class TeleQuebecSquatIE(InfoExtractor): |
86 | _VALID_URL = r'https://squat\.telequebec\.tv/videos/(?P<id>\d+)' | |
87 | _TESTS = [{ | |
88 | 'url': 'https://squat.telequebec.tv/videos/9314', | |
89 | 'info_dict': { | |
90 | 'id': 'd59ae78112d542e793d83cc9d3a5b530', | |
91 | 'ext': 'mp4', | |
92 | 'title': 'Poupeflekta', | |
93 | 'description': 'md5:2f0718f8d2f8fece1646ee25fb7bce75', | |
94 | 'duration': 1351, | |
95 | 'timestamp': 1569057600, | |
96 | 'upload_date': '20190921', | |
97 | 'series': 'Miraculous : Les Aventures de Ladybug et Chat Noir', | |
98 | 'season': 'Saison 3', | |
99 | 'season_number': 3, | |
100 | 'episode_number': 57, | |
101 | }, | |
102 | 'params': { | |
103 | 'skip_download': True, | |
104 | }, | |
105 | }] | |
106 | ||
107 | def _real_extract(self, url): | |
108 | video_id = self._match_id(url) | |
109 | ||
110 | video = self._download_json( | |
111 | 'https://squat.api.telequebec.tv/v1/videos/%s' % video_id, | |
112 | video_id) | |
113 | ||
114 | media_id = video['sourceId'] | |
115 | ||
116 | return { | |
117 | '_type': 'url_transparent', | |
118 | 'url': 'http://zonevideo.telequebec.tv/media/%s' % media_id, | |
119 | 'ie_key': TeleQuebecIE.ie_key(), | |
120 | 'id': media_id, | |
121 | 'title': video.get('titre'), | |
122 | 'description': video.get('description'), | |
123 | 'timestamp': unified_timestamp(video.get('datePublication')), | |
124 | 'series': video.get('container'), | |
125 | 'season': video.get('saison'), | |
126 | 'season_number': int_or_none(video.get('noSaison')), | |
127 | 'episode_number': int_or_none(video.get('episode')), | |
128 | } | |
129 | ||
130 | ||
29f7c58a | 131 | class TeleQuebecEmissionIE(InfoExtractor): |
f01df14c S |
132 | _VALID_URL = r'''(?x) |
133 | https?:// | |
134 | (?: | |
135 | [^/]+\.telequebec\.tv/emissions/| | |
136 | (?:www\.)?telequebec\.tv/ | |
137 | ) | |
138 | (?P<id>[^?#&]+) | |
139 | ''' | |
9306b0c8 S |
140 | _TESTS = [{ |
141 | 'url': 'http://lindicemcsween.telequebec.tv/emissions/100430013/des-soins-esthetiques-a-377-d-interets-annuels-ca-vous-tente', | |
142 | 'info_dict': { | |
29f7c58a | 143 | 'id': '6154476028001', |
9306b0c8 | 144 | 'ext': 'mp4', |
29f7c58a | 145 | 'title': 'Des soins esthétiques à 377 % d’intérêts annuels, ça vous tente?', |
146 | 'description': 'md5:cb4d378e073fae6cce1f87c00f84ae9f', | |
147 | 'upload_date': '20200505', | |
148 | 'timestamp': 1588713424, | |
149 | 'uploader_id': '6150020952001', | |
9306b0c8 | 150 | }, |
9306b0c8 S |
151 | }, { |
152 | 'url': 'http://bancpublic.telequebec.tv/emissions/emission-49/31986/jeunes-meres-sous-pression', | |
153 | 'only_matching': True, | |
f01df14c S |
154 | }, { |
155 | 'url': 'http://www.telequebec.tv/masha-et-michka/epi059masha-et-michka-3-053-078', | |
156 | 'only_matching': True, | |
157 | }, { | |
158 | 'url': 'http://www.telequebec.tv/documentaire/bebes-sur-mesure/', | |
159 | 'only_matching': True, | |
9306b0c8 S |
160 | }] |
161 | ||
162 | def _real_extract(self, url): | |
163 | display_id = self._match_id(url) | |
164 | ||
165 | webpage = self._download_webpage(url, display_id) | |
166 | ||
167 | media_id = self._search_regex( | |
29f7c58a | 168 | r'mediaId\s*:\s*(?P<id>\d+)', webpage, 'media id') |
9306b0c8 | 169 | |
29f7c58a | 170 | return self.url_result( |
171 | 'http://zonevideo.telequebec.tv/media/' + media_id, | |
172 | TeleQuebecIE.ie_key()) | |
300148b4 S |
173 | |
174 | ||
29f7c58a | 175 | class TeleQuebecLiveIE(TeleQuebecBaseIE): |
300148b4 S |
176 | _VALID_URL = r'https?://zonevideo\.telequebec\.tv/(?P<id>endirect)' |
177 | _TEST = { | |
178 | 'url': 'http://zonevideo.telequebec.tv/endirect/', | |
179 | 'info_dict': { | |
29f7c58a | 180 | 'id': '6159095684001', |
300148b4 | 181 | 'ext': 'mp4', |
29f7c58a | 182 | 'title': 're:^Télé-Québec [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', |
300148b4 | 183 | 'is_live': True, |
29f7c58a | 184 | 'description': 'Canal principal de Télé-Québec', |
185 | 'uploader_id': '6150020952001', | |
186 | 'timestamp': 1590439901, | |
187 | 'upload_date': '20200525', | |
300148b4 S |
188 | }, |
189 | 'params': { | |
190 | 'skip_download': True, | |
191 | }, | |
192 | } | |
193 | ||
194 | def _real_extract(self, url): | |
29f7c58a | 195 | return self._brightcove_result('6159095684001', 'skCsmi2Uw') |
300148b4 | 196 | |
300148b4 | 197 | |
29f7c58a | 198 | class TeleQuebecVideoIE(TeleQuebecBaseIE): |
199 | _VALID_URL = r'https?://video\.telequebec\.tv/player(?:-live)?/(?P<id>\d+)' | |
200 | _TESTS = [{ | |
201 | 'url': 'https://video.telequebec.tv/player/31110/stream', | |
202 | 'info_dict': { | |
203 | 'id': '6202570652001', | |
204 | 'ext': 'mp4', | |
205 | 'title': 'Le coût du véhicule le plus vendu au Canada / Tous les frais liés à la procréation assistée', | |
206 | 'description': 'md5:685a7e4c450ba777c60adb6e71e41526', | |
207 | 'upload_date': '20201019', | |
208 | 'timestamp': 1603115930, | |
209 | 'uploader_id': '6101674910001', | |
210 | }, | |
29f7c58a | 211 | }, { |
212 | 'url': 'https://video.telequebec.tv/player-live/28527', | |
213 | 'only_matching': True, | |
214 | }] | |
215 | ||
216 | def _call_api(self, path, video_id): | |
217 | return self._download_json( | |
218 | 'http://beacon.playback.api.brightcove.com/telequebec/api/assets/' + path, | |
219 | video_id, query={'device_layout': 'web', 'device_type': 'web'})['data'] | |
220 | ||
221 | def _real_extract(self, url): | |
222 | asset_id = self._match_id(url) | |
223 | asset = self._call_api(asset_id, asset_id)['asset'] | |
224 | stream = self._call_api( | |
225 | asset_id + '/streams/' + asset['streams'][0]['id'], asset_id)['stream'] | |
226 | stream_url = stream['url'] | |
227 | account_id = try_get( | |
228 | stream, lambda x: x['video_provider_details']['account_id']) or '6101674910001' | |
229 | info = self._brightcove_result(stream_url, 'default', account_id) | |
230 | info.update({ | |
231 | 'description': asset.get('long_description') or asset.get('short_description'), | |
232 | 'series': asset.get('series_original_name'), | |
233 | 'season_number': int_or_none(asset.get('season_number')), | |
234 | 'episode': asset.get('original_name'), | |
235 | 'episode_number': int_or_none(asset.get('episode_number')), | |
236 | }) | |
237 | return info |