]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
3c1b4669 PH |
2 | |
3 | from __future__ import unicode_literals | |
4 | ||
5d8afe69 | 5 | import re |
5d8afe69 PR |
6 | |
7 | from .common import InfoExtractor | |
8faa338f S |
8 | from ..compat import ( |
9 | compat_str, | |
10 | compat_urlparse, | |
11 | ) | |
1cc79574 | 12 | from ..utils import ( |
64892c0b | 13 | clean_html, |
760f8121 | 14 | determine_ext, |
1cc79574 | 15 | ExtractorError, |
64892c0b | 16 | int_or_none, |
1cc79574 | 17 | parse_duration, |
760f8121 | 18 | try_get, |
3052a30d | 19 | url_or_none, |
5d8afe69 | 20 | ) |
3c4fbfec | 21 | from .dailymotion import DailymotionIE |
5d8afe69 PR |
22 | |
23 | ||
648d25d4 | 24 | class FranceTVBaseInfoExtractor(InfoExtractor): |
79080573 S |
25 | def _make_url_result(self, video_or_full_id, catalog=None): |
26 | full_id = 'francetv:%s' % video_or_full_id | |
27 | if '@' not in video_or_full_id and catalog: | |
99892e99 S |
28 | full_id += '@%s' % catalog |
29 | return self.url_result( | |
79080573 S |
30 | full_id, ie=FranceTVIE.ie_key(), |
31 | video_id=video_or_full_id.split('@')[0]) | |
99892e99 S |
32 | |
33 | ||
34 | class FranceTVIE(InfoExtractor): | |
35 | _VALID_URL = r'''(?x) | |
36 | (?: | |
37 | https?:// | |
38 | sivideo\.webservices\.francetelevisions\.fr/tools/getInfosOeuvre/v2/\? | |
39 | .*?\bidDiffusion=[^&]+| | |
40 | (?: | |
41 | https?://videos\.francetv\.fr/video/| | |
42 | francetv: | |
43 | ) | |
44 | (?P<id>[^@]+)(?:@(?P<catalog>.+))? | |
45 | ) | |
46 | ''' | |
47 | ||
48 | _TESTS = [{ | |
49 | # without catalog | |
50 | 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=162311093&callback=_jsonp_loader_callback_request_0', | |
51 | 'md5': 'c2248a8de38c4e65ea8fae7b5df2d84f', | |
52 | 'info_dict': { | |
53 | 'id': '162311093', | |
54 | 'ext': 'mp4', | |
55 | 'title': '13h15, le dimanche... - Les mystères de Jésus', | |
56 | 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42', | |
57 | 'timestamp': 1502623500, | |
58 | 'upload_date': '20170813', | |
59 | }, | |
60 | }, { | |
61 | # with catalog | |
62 | 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=NI_1004933&catalogue=Zouzous&callback=_jsonp_loader_callback_request_4', | |
63 | 'only_matching': True, | |
64 | }, { | |
65 | 'url': 'http://videos.francetv.fr/video/NI_657393@Regions', | |
66 | 'only_matching': True, | |
67 | }, { | |
68 | 'url': 'francetv:162311093', | |
69 | 'only_matching': True, | |
70 | }, { | |
71 | 'url': 'francetv:NI_1004933@Zouzous', | |
72 | 'only_matching': True, | |
73 | }, { | |
74 | 'url': 'francetv:NI_983319@Info-web', | |
75 | 'only_matching': True, | |
76 | }, { | |
77 | 'url': 'francetv:NI_983319', | |
78 | 'only_matching': True, | |
79 | }, { | |
80 | 'url': 'francetv:NI_657393@Regions', | |
81 | 'only_matching': True, | |
760f8121 S |
82 | }, { |
83 | # france-3 live | |
84 | 'url': 'francetv:SIM_France3', | |
85 | 'only_matching': True, | |
99892e99 S |
86 | }] |
87 | ||
6d1ded75 | 88 | def _extract_video(self, video_id, catalogue=None): |
99892e99 S |
89 | # Videos are identified by idDiffusion so catalogue part is optional. |
90 | # However when provided, some extra formats may be returned so we pass | |
91 | # it if available. | |
64892c0b | 92 | info = self._download_json( |
6d1ded75 S |
93 | 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/', |
94 | video_id, 'Downloading video JSON', query={ | |
95 | 'idDiffusion': video_id, | |
96 | 'catalogue': catalogue or '', | |
97 | }) | |
64892c0b S |
98 | |
99 | if info.get('status') == 'NOK': | |
100 | raise ExtractorError( | |
8faa338f S |
101 | '%s returned error: %s' % (self.IE_NAME, info['message']), |
102 | expected=True) | |
00e9d396 JMF |
103 | allowed_countries = info['videos'][0].get('geoblocage') |
104 | if allowed_countries: | |
105 | georestricted = True | |
106 | geo_info = self._download_json( | |
107 | 'http://geo.francetv.fr/ws/edgescape.json', video_id, | |
108 | 'Downloading geo restriction info') | |
109 | country = geo_info['reponse']['geo_info']['country_code'] | |
110 | if country not in allowed_countries: | |
111 | raise ExtractorError( | |
112 | 'The video is not available from your location', | |
113 | expected=True) | |
114 | else: | |
115 | georestricted = False | |
116 | ||
8faa338f S |
117 | def sign(manifest_url, manifest_id): |
118 | for host in ('hdfauthftv-a.akamaihd.net', 'hdfauth.francetv.fr'): | |
3052a30d | 119 | signed_url = url_or_none(self._download_webpage( |
8faa338f S |
120 | 'https://%s/esi/TA' % host, video_id, |
121 | 'Downloading signed %s manifest URL' % manifest_id, | |
122 | fatal=False, query={ | |
123 | 'url': manifest_url, | |
3052a30d S |
124 | })) |
125 | if signed_url: | |
8faa338f S |
126 | return signed_url |
127 | return manifest_url | |
128 | ||
760f8121 S |
129 | is_live = None |
130 | ||
64892c0b S |
131 | formats = [] |
132 | for video in info['videos']: | |
133 | if video['statut'] != 'ONLINE': | |
134 | continue | |
135 | video_url = video['url'] | |
136 | if not video_url: | |
137 | continue | |
760f8121 S |
138 | if is_live is None: |
139 | is_live = (try_get( | |
140 | video, lambda x: x['plages_ouverture'][0]['direct'], | |
141 | bool) is True) or '/live.francetv.fr/' in video_url | |
64892c0b | 142 | format_id = video['format'] |
bc03228a S |
143 | ext = determine_ext(video_url) |
144 | if ext == 'f4m': | |
00e9d396 | 145 | if georestricted: |
067aa17e | 146 | # See https://github.com/ytdl-org/youtube-dl/issues/3963 |
00e9d396 JMF |
147 | # m3u8 urls work fine |
148 | continue | |
8faa338f S |
149 | formats.extend(self._extract_f4m_formats( |
150 | sign(video_url, format_id) + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44', | |
151 | video_id, f4m_id=format_id, fatal=False)) | |
bc03228a | 152 | elif ext == 'm3u8': |
8faa338f S |
153 | formats.extend(self._extract_m3u8_formats( |
154 | sign(video_url, format_id), video_id, 'mp4', | |
155 | entry_protocol='m3u8_native', m3u8_id=format_id, | |
156 | fatal=False)) | |
64892c0b S |
157 | elif video_url.startswith('rtmp'): |
158 | formats.append({ | |
159 | 'url': video_url, | |
160 | 'format_id': 'rtmp-%s' % format_id, | |
161 | 'ext': 'flv', | |
64892c0b S |
162 | }) |
163 | else: | |
3c20208e S |
164 | if self._is_valid_url(video_url, video_id, format_id): |
165 | formats.append({ | |
166 | 'url': video_url, | |
167 | 'format_id': format_id, | |
168 | }) | |
64892c0b | 169 | self._sort_formats(formats) |
648d25d4 | 170 | |
36c15522 S |
171 | title = info['titre'] |
172 | subtitle = info.get('sous_titre') | |
173 | if subtitle: | |
174 | title += ' - %s' % subtitle | |
db264e3c | 175 | title = title.strip() |
36c15522 | 176 | |
5dadae07 | 177 | subtitles = {} |
6e4b8b28 | 178 | subtitles_list = [{ |
7ccb2b84 JMF |
179 | 'url': subformat['url'], |
180 | 'ext': subformat.get('format'), | |
181 | } for subformat in info.get('subtitles', []) if subformat.get('url')] | |
6e4b8b28 S |
182 | if subtitles_list: |
183 | subtitles['fr'] = subtitles_list | |
5dadae07 | 184 | |
7e8d73c1 JMF |
185 | return { |
186 | 'id': video_id, | |
760f8121 | 187 | 'title': self._live_title(title) if is_live else title, |
64892c0b S |
188 | 'description': clean_html(info['synopsis']), |
189 | 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', info['image']), | |
5705ee6e | 190 | 'duration': int_or_none(info.get('real_duration')) or parse_duration(info['duree']), |
64892c0b | 191 | 'timestamp': int_or_none(info['diffusion']['timestamp']), |
760f8121 | 192 | 'is_live': is_live, |
7e8d73c1 | 193 | 'formats': formats, |
5dadae07 | 194 | 'subtitles': subtitles, |
7e8d73c1 | 195 | } |
648d25d4 | 196 | |
99892e99 S |
197 | def _real_extract(self, url): |
198 | mobj = re.match(self._VALID_URL, url) | |
199 | video_id = mobj.group('id') | |
200 | catalog = mobj.group('catalog') | |
201 | ||
202 | if not video_id: | |
203 | qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query) | |
204 | video_id = qs.get('idDiffusion', [None])[0] | |
205 | catalog = qs.get('catalogue', [None])[0] | |
206 | if not video_id: | |
207 | raise ExtractorError('Invalid URL', expected=True) | |
208 | ||
209 | return self._extract_video(video_id, catalog) | |
210 | ||
648d25d4 | 211 | |
99892e99 | 212 | class FranceTVSiteIE(FranceTVBaseInfoExtractor): |
4489d418 | 213 | _VALID_URL = r'https?://(?:(?:www\.)?france\.tv|mobile\.france\.tv)/(?:[^/]+/)*(?P<id>[^/]+)\.html' |
5d8afe69 | 214 | |
6d1ded75 S |
215 | _TESTS = [{ |
216 | 'url': 'https://www.france.tv/france-2/13h15-le-dimanche/140921-les-mysteres-de-jesus.html', | |
217 | 'info_dict': { | |
9d74ea6d | 218 | 'id': 'ec217ecc-0733-48cf-ac06-af1347b849d1', |
6d1ded75 S |
219 | 'ext': 'mp4', |
220 | 'title': '13h15, le dimanche... - Les mystères de Jésus', | |
221 | 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42', | |
99892e99 S |
222 | 'timestamp': 1502623500, |
223 | 'upload_date': '20170813', | |
6d1ded75 S |
224 | }, |
225 | 'params': { | |
6d1ded75 S |
226 | 'skip_download': True, |
227 | }, | |
99892e99 | 228 | 'add_ie': [FranceTVIE.ie_key()], |
6d1ded75 S |
229 | }, { |
230 | # france3 | |
231 | 'url': 'https://www.france.tv/france-3/des-chiffres-et-des-lettres/139063-emission-du-mardi-9-mai-2017.html', | |
232 | 'only_matching': True, | |
233 | }, { | |
234 | # france4 | |
235 | 'url': 'https://www.france.tv/france-4/hero-corp/saison-1/134151-apres-le-calme.html', | |
236 | 'only_matching': True, | |
237 | }, { | |
238 | # france5 | |
239 | 'url': 'https://www.france.tv/france-5/c-a-dire/saison-10/137013-c-a-dire.html', | |
240 | 'only_matching': True, | |
241 | }, { | |
242 | # franceo | |
243 | 'url': 'https://www.france.tv/france-o/archipels/132249-mon-ancetre-l-esclave.html', | |
244 | 'only_matching': True, | |
245 | }, { | |
246 | # france2 live | |
247 | 'url': 'https://www.france.tv/france-2/direct.html', | |
248 | 'only_matching': True, | |
249 | }, { | |
250 | 'url': 'https://www.france.tv/documentaires/histoire/136517-argentine-les-500-bebes-voles-de-la-dictature.html', | |
251 | 'only_matching': True, | |
252 | }, { | |
253 | 'url': 'https://www.france.tv/jeux-et-divertissements/divertissements/133965-le-web-contre-attaque.html', | |
254 | 'only_matching': True, | |
12f01118 S |
255 | }, { |
256 | 'url': 'https://mobile.france.tv/france-5/c-dans-l-air/137347-emission-du-vendredi-12-mai-2017.html', | |
257 | 'only_matching': True, | |
4489d418 S |
258 | }, { |
259 | 'url': 'https://www.france.tv/142749-rouge-sang.html', | |
260 | 'only_matching': True, | |
49702e36 S |
261 | }, { |
262 | # france-3 live | |
263 | 'url': 'https://www.france.tv/france-3/direct.html', | |
264 | 'only_matching': True, | |
6d1ded75 | 265 | }] |
5d8afe69 PR |
266 | |
267 | def _real_extract(self, url): | |
0a192fbe S |
268 | display_id = self._match_id(url) |
269 | ||
270 | webpage = self._download_webpage(url, display_id) | |
271 | ||
6d1ded75 S |
272 | catalogue = None |
273 | video_id = self._search_regex( | |
9d74ea6d | 274 | r'(?:data-main-video\s*=|videoId["\']?\s*[:=])\s*(["\'])(?P<id>(?:(?!\1).)+)\1', |
6d1ded75 S |
275 | webpage, 'video id', default=None, group='id') |
276 | ||
0a192fbe | 277 | if not video_id: |
6d1ded75 S |
278 | video_id, catalogue = self._html_search_regex( |
279 | r'(?:href=|player\.setVideo\(\s*)"http://videos?\.francetv\.fr/video/([^@]+@[^"]+)"', | |
280 | webpage, 'video ID').split('@') | |
99892e99 S |
281 | |
282 | return self._make_url_result(video_id, catalogue) | |
6d1ded75 S |
283 | |
284 | ||
285 | class FranceTVEmbedIE(FranceTVBaseInfoExtractor): | |
286 | _VALID_URL = r'https?://embed\.francetv\.fr/*\?.*?\bue=(?P<id>[^&]+)' | |
287 | ||
99892e99 | 288 | _TESTS = [{ |
6d1ded75 S |
289 | 'url': 'http://embed.francetv.fr/?ue=7fd581a2ccf59d2fc5719c5c13cf6961', |
290 | 'info_dict': { | |
291 | 'id': 'NI_983319', | |
292 | 'ext': 'mp4', | |
293 | 'title': 'Le Pen Reims', | |
294 | 'upload_date': '20170505', | |
295 | 'timestamp': 1493981780, | |
296 | 'duration': 16, | |
297 | }, | |
99892e99 S |
298 | 'params': { |
299 | 'skip_download': True, | |
300 | }, | |
301 | 'add_ie': [FranceTVIE.ie_key()], | |
302 | }] | |
0a192fbe | 303 | |
6d1ded75 S |
304 | def _real_extract(self, url): |
305 | video_id = self._match_id(url) | |
306 | ||
307 | video = self._download_json( | |
308 | 'http://api-embed.webservices.francetelevisions.fr/key/%s' % video_id, | |
309 | video_id) | |
5d8afe69 | 310 | |
99892e99 | 311 | return self._make_url_result(video['video_id'], video.get('catalog')) |
5d8afe69 | 312 | |
6d1ded75 S |
313 | |
314 | class FranceTVInfoIE(FranceTVBaseInfoExtractor): | |
3c1b4669 | 315 | IE_NAME = 'francetvinfo.fr' |
99892e99 | 316 | _VALID_URL = r'https?://(?:www|mobile|france3-regions)\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&.]+)' |
5d8afe69 | 317 | |
5c30b268 | 318 | _TESTS = [{ |
3c1b4669 | 319 | 'url': 'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html', |
3c1b4669 | 320 | 'info_dict': { |
5c30b268 | 321 | 'id': '84981923', |
3c20208e | 322 | 'ext': 'mp4', |
3c1b4669 | 323 | 'title': 'Soir 3', |
64892c0b S |
324 | 'upload_date': '20130826', |
325 | 'timestamp': 1377548400, | |
c137cc0d S |
326 | 'subtitles': { |
327 | 'fr': 'mincount:2', | |
328 | }, | |
648d25d4 | 329 | }, |
3c20208e | 330 | 'params': { |
3c20208e S |
331 | 'skip_download': True, |
332 | }, | |
99892e99 | 333 | 'add_ie': [FranceTVIE.ie_key()], |
5c30b268 PH |
334 | }, { |
335 | 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html', | |
99892e99 | 336 | 'only_matching': True, |
6f96e308 YCH |
337 | }, { |
338 | 'url': 'http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html', | |
99892e99 | 339 | 'only_matching': True, |
db264e3c S |
340 | }, { |
341 | 'url': 'http://france3-regions.francetvinfo.fr/bretagne/cotes-d-armor/thalassa-echappee-breizh-ce-venredi-dans-les-cotes-d-armor-954961.html', | |
99892e99 | 342 | 'only_matching': True, |
ad213a1d YCH |
343 | }, { |
344 | # Dailymotion embed | |
345 | 'url': 'http://www.francetvinfo.fr/politique/notre-dame-des-landes/video-sur-france-inter-cecile-duflot-denonce-le-regard-meprisant-de-patrick-cohen_1520091.html', | |
346 | 'md5': 'ee7f1828f25a648addc90cb2687b1f12', | |
347 | 'info_dict': { | |
348 | 'id': 'x4iiko0', | |
349 | 'ext': 'mp4', | |
350 | 'title': 'NDDL, référendum, Brexit : Cécile Duflot répond à Patrick Cohen', | |
351 | 'description': 'Au lendemain de la victoire du "oui" au référendum sur l\'aéroport de Notre-Dame-des-Landes, l\'ancienne ministre écologiste est l\'invitée de Patrick Cohen. Plus d\'info : https://www.franceinter.fr/emissions/le-7-9/le-7-9-27-juin-2016', | |
352 | 'timestamp': 1467011958, | |
353 | 'upload_date': '20160627', | |
354 | 'uploader': 'France Inter', | |
355 | 'uploader_id': 'x2q2ez', | |
356 | }, | |
357 | 'add_ie': ['Dailymotion'], | |
30b25d38 S |
358 | }, { |
359 | 'url': 'http://france3-regions.francetvinfo.fr/limousin/emissions/jt-1213-limousin', | |
360 | 'only_matching': True, | |
5c30b268 | 361 | }] |
648d25d4 JMF |
362 | |
363 | def _real_extract(self, url): | |
99892e99 S |
364 | display_id = self._match_id(url) |
365 | ||
366 | webpage = self._download_webpage(url, display_id) | |
6f96e308 | 367 | |
ad213a1d YCH |
368 | dailymotion_urls = DailymotionIE._extract_urls(webpage) |
369 | if dailymotion_urls: | |
370 | return self.playlist_result([ | |
371 | self.url_result(dailymotion_url, DailymotionIE.ie_key()) | |
372 | for dailymotion_url in dailymotion_urls]) | |
6f96e308 | 373 | |
876fed6b | 374 | video_id = self._search_regex( |
375 | (r'player\.load[^;]+src:\s*["\']([^"\']+)', | |
376 | r'id-video=([^@]+@[^"]+)', | |
db264e3c | 377 | r'<a[^>]+href="(?:https?:)?//videos\.francetv\.fr/video/([^@]+@[^"]+)"'), |
876fed6b | 378 | webpage, 'video id') |
99892e99 | 379 | |
876fed6b | 380 | return self._make_url_result(video_id) |
a825f330 JMF |
381 | |
382 | ||
3a8e3730 RA |
383 | class FranceTVInfoSportIE(FranceTVBaseInfoExtractor): |
384 | IE_NAME = 'sport.francetvinfo.fr' | |
385 | _VALID_URL = r'https?://sport\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&]+)' | |
386 | _TESTS = [{ | |
387 | 'url': 'https://sport.francetvinfo.fr/les-jeux-olympiques/retour-sur-les-meilleurs-moments-de-pyeongchang-2018', | |
388 | 'info_dict': { | |
389 | 'id': '6e49080e-3f45-11e8-b459-000d3a2439ea', | |
390 | 'ext': 'mp4', | |
391 | 'title': 'Retour sur les meilleurs moments de Pyeongchang 2018', | |
392 | 'timestamp': 1523639962, | |
393 | 'upload_date': '20180413', | |
394 | }, | |
395 | 'params': { | |
396 | 'skip_download': True, | |
397 | }, | |
398 | 'add_ie': [FranceTVIE.ie_key()], | |
399 | }] | |
400 | ||
401 | def _real_extract(self, url): | |
402 | display_id = self._match_id(url) | |
403 | webpage = self._download_webpage(url, display_id) | |
404 | video_id = self._search_regex(r'data-video="([^"]+)"', webpage, 'video_id') | |
405 | return self._make_url_result(video_id, 'Sport-web') | |
406 | ||
407 | ||
6f5c598a RA |
408 | class GenerationWhatIE(InfoExtractor): |
409 | IE_NAME = 'france2.fr:generation-what' | |
99892e99 | 410 | _VALID_URL = r'https?://generation-what\.francetv\.fr/[^/]+/video/(?P<id>[^/?#&]+)' |
5b333c1c | 411 | |
6f5c598a RA |
412 | _TESTS = [{ |
413 | 'url': 'http://generation-what.francetv.fr/portrait/video/present-arms', | |
3c1b4669 | 414 | 'info_dict': { |
6f5c598a | 415 | 'id': 'wtvKYUG45iw', |
c4e817ce | 416 | 'ext': 'mp4', |
6f5c598a RA |
417 | 'title': 'Generation What - Garde à vous - FRA', |
418 | 'uploader': 'Generation What', | |
419 | 'uploader_id': 'UCHH9p1eetWCgt4kXBYCb3_w', | |
420 | 'upload_date': '20160411', | |
5b333c1c | 421 | }, |
99892e99 S |
422 | 'params': { |
423 | 'skip_download': True, | |
424 | }, | |
425 | 'add_ie': ['Youtube'], | |
6f5c598a RA |
426 | }, { |
427 | 'url': 'http://generation-what.francetv.fr/europe/video/present-arms', | |
428 | 'only_matching': True, | |
429 | }] | |
5b333c1c JMF |
430 | |
431 | def _real_extract(self, url): | |
c4e817ce | 432 | display_id = self._match_id(url) |
99892e99 | 433 | |
6f5c598a | 434 | webpage = self._download_webpage(url, display_id) |
99892e99 | 435 | |
6f5c598a RA |
436 | youtube_id = self._search_regex( |
437 | r"window\.videoURL\s*=\s*'([0-9A-Za-z_-]{11})';", | |
438 | webpage, 'youtube id') | |
99892e99 S |
439 | |
440 | return self.url_result(youtube_id, ie='Youtube', video_id=youtube_id) | |
469ec941 JMF |
441 | |
442 | ||
443 | class CultureboxIE(FranceTVBaseInfoExtractor): | |
99892e99 | 444 | _VALID_URL = r'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&]+)' |
469ec941 | 445 | |
99892e99 S |
446 | _TESTS = [{ |
447 | 'url': 'https://culturebox.francetvinfo.fr/opera-classique/musique-classique/c-est-baroque/concerts/cantates-bwv-4-106-et-131-de-bach-par-raphael-pichon-57-268689', | |
3c1b4669 | 448 | 'info_dict': { |
99892e99 S |
449 | 'id': 'EV_134885', |
450 | 'ext': 'mp4', | |
451 | 'title': 'Cantates BWV 4, 106 et 131 de Bach par Raphaël Pichon 5/7', | |
452 | 'description': 'md5:19c44af004b88219f4daa50fa9a351d4', | |
453 | 'upload_date': '20180206', | |
454 | 'timestamp': 1517945220, | |
455 | 'duration': 5981, | |
aed2d4b3 | 456 | }, |
99892e99 S |
457 | 'params': { |
458 | 'skip_download': True, | |
459 | }, | |
460 | 'add_ie': [FranceTVIE.ie_key()], | |
461 | }] | |
469ec941 JMF |
462 | |
463 | def _real_extract(self, url): | |
99892e99 | 464 | display_id = self._match_id(url) |
184a1974 | 465 | |
99892e99 | 466 | webpage = self._download_webpage(url, display_id) |
184a1974 S |
467 | |
468 | if ">Ce live n'est plus disponible en replay<" in webpage: | |
99892e99 S |
469 | raise ExtractorError( |
470 | 'Video %s is not available' % display_id, expected=True) | |
184a1974 | 471 | |
64892c0b | 472 | video_id, catalogue = self._search_regex( |
c38970ca S |
473 | r'["\'>]https?://videos\.francetv\.fr/video/([^@]+@.+?)["\'<]', |
474 | webpage, 'video id').split('@') | |
64892c0b | 475 | |
99892e99 | 476 | return self._make_url_result(video_id, catalogue) |
79080573 S |
477 | |
478 | ||
479 | class FranceTVJeunesseIE(FranceTVBaseInfoExtractor): | |
480 | _VALID_URL = r'(?P<url>https?://(?:www\.)?(?:zouzous|ludo)\.fr/heros/(?P<id>[^/?#&]+))' | |
481 | ||
482 | _TESTS = [{ | |
483 | 'url': 'https://www.zouzous.fr/heros/simon', | |
484 | 'info_dict': { | |
485 | 'id': 'simon', | |
486 | }, | |
487 | 'playlist_count': 9, | |
488 | }, { | |
489 | 'url': 'https://www.ludo.fr/heros/ninjago', | |
490 | 'info_dict': { | |
491 | 'id': 'ninjago', | |
492 | }, | |
493 | 'playlist_count': 10, | |
494 | }, { | |
495 | 'url': 'https://www.zouzous.fr/heros/simon?abc', | |
496 | 'only_matching': True, | |
497 | }] | |
498 | ||
499 | def _real_extract(self, url): | |
500 | mobj = re.match(self._VALID_URL, url) | |
501 | playlist_id = mobj.group('id') | |
502 | ||
503 | playlist = self._download_json( | |
504 | '%s/%s' % (mobj.group('url'), 'playlist'), playlist_id) | |
505 | ||
506 | if not playlist.get('count'): | |
507 | raise ExtractorError( | |
508 | '%s is not available' % playlist_id, expected=True) | |
509 | ||
510 | entries = [] | |
511 | for item in playlist['items']: | |
512 | identity = item.get('identity') | |
513 | if identity and isinstance(identity, compat_str): | |
514 | entries.append(self._make_url_result(identity)) | |
515 | ||
516 | return self.playlist_result(entries, playlist_id) |