3 from __future__ import unicode_literals
7 from .common import InfoExtractor
19 from .dailymotion import DailymotionIE
22 class FranceTVBaseInfoExtractor(InfoExtractor):
23 def _make_url_result(self, video_or_full_id, catalog=None):
24 full_id = 'francetv:%s' % video_or_full_id
25 if '@' not in video_or_full_id and catalog:
26 full_id += '@%s' % catalog
27 return self.url_result(
28 full_id, ie=FranceTVIE.ie_key(),
29 video_id=video_or_full_id.split('@')[0])
32 class FranceTVIE(InfoExtractor):
36 sivideo\.webservices\.francetelevisions\.fr/tools/getInfosOeuvre/v2/\?
37 .*?\bidDiffusion=[^&]+|
39 https?://videos\.francetv\.fr/video/|
42 (?P<id>[^@]+)(?:@(?P<catalog>.+))?
48 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=162311093&callback=_jsonp_loader_callback_request_0',
49 'md5': 'c2248a8de38c4e65ea8fae7b5df2d84f',
53 'title': '13h15, le dimanche... - Les mystères de Jésus',
54 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42',
55 'timestamp': 1502623500,
56 'upload_date': '20170813',
60 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=NI_1004933&catalogue=Zouzous&callback=_jsonp_loader_callback_request_4',
61 'only_matching': True,
63 'url': 'http://videos.francetv.fr/video/NI_657393@Regions',
64 'only_matching': True,
66 'url': 'francetv:162311093',
67 'only_matching': True,
69 'url': 'francetv:NI_1004933@Zouzous',
70 'only_matching': True,
72 'url': 'francetv:NI_983319@Info-web',
73 'only_matching': True,
75 'url': 'francetv:NI_983319',
76 'only_matching': True,
78 'url': 'francetv:NI_657393@Regions',
79 'only_matching': True,
82 def _extract_video(self, video_id, catalogue=None):
83 # Videos are identified by idDiffusion so catalogue part is optional.
84 # However when provided, some extra formats may be returned so we pass
86 info = self._download_json(
87 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/',
88 video_id, 'Downloading video JSON', query={
89 'idDiffusion': video_id,
90 'catalogue': catalogue or '',
93 if info.get('status') == 'NOK':
95 '%s returned error: %s' % (self.IE_NAME, info['message']),
97 allowed_countries = info['videos'][0].get('geoblocage')
100 geo_info = self._download_json(
101 'http://geo.francetv.fr/ws/edgescape.json', video_id,
102 'Downloading geo restriction info')
103 country = geo_info['reponse']['geo_info']['country_code']
104 if country not in allowed_countries:
105 raise ExtractorError(
106 'The video is not available from your location',
109 georestricted = False
111 def sign(manifest_url, manifest_id):
112 for host in ('hdfauthftv-a.akamaihd.net', 'hdfauth.francetv.fr'):
113 signed_url = self._download_webpage(
114 'https://%s/esi/TA' % host, video_id,
115 'Downloading signed %s manifest URL' % manifest_id,
119 if (signed_url and isinstance(signed_url, compat_str) and
120 re.search(r'^(?:https?:)?//', signed_url)):
125 for video in info['videos']:
126 if video['statut'] != 'ONLINE':
128 video_url = video['url']
131 format_id = video['format']
132 ext = determine_ext(video_url)
135 # See https://github.com/rg3/youtube-dl/issues/3963
136 # m3u8 urls work fine
138 formats.extend(self._extract_f4m_formats(
139 sign(video_url, format_id) + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44',
140 video_id, f4m_id=format_id, fatal=False))
142 formats.extend(self._extract_m3u8_formats(
143 sign(video_url, format_id), video_id, 'mp4',
144 entry_protocol='m3u8_native', m3u8_id=format_id,
146 elif video_url.startswith('rtmp'):
149 'format_id': 'rtmp-%s' % format_id,
153 if self._is_valid_url(video_url, video_id, format_id):
156 'format_id': format_id,
158 self._sort_formats(formats)
160 title = info['titre']
161 subtitle = info.get('sous_titre')
163 title += ' - %s' % subtitle
164 title = title.strip()
168 'url': subformat['url'],
169 'ext': subformat.get('format'),
170 } for subformat in info.get('subtitles', []) if subformat.get('url')]
172 subtitles['fr'] = subtitles_list
177 'description': clean_html(info['synopsis']),
178 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', info['image']),
179 'duration': int_or_none(info.get('real_duration')) or parse_duration(info['duree']),
180 'timestamp': int_or_none(info['diffusion']['timestamp']),
182 'subtitles': subtitles,
185 def _real_extract(self, url):
186 mobj = re.match(self._VALID_URL, url)
187 video_id = mobj.group('id')
188 catalog = mobj.group('catalog')
191 qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
192 video_id = qs.get('idDiffusion', [None])[0]
193 catalog = qs.get('catalogue', [None])[0]
195 raise ExtractorError('Invalid URL', expected=True)
197 return self._extract_video(video_id, catalog)
200 class FranceTVSiteIE(FranceTVBaseInfoExtractor):
201 _VALID_URL = r'https?://(?:(?:www\.)?france\.tv|mobile\.france\.tv)/(?:[^/]+/)*(?P<id>[^/]+)\.html'
204 'url': 'https://www.france.tv/france-2/13h15-le-dimanche/140921-les-mysteres-de-jesus.html',
208 'title': '13h15, le dimanche... - Les mystères de Jésus',
209 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42',
210 'timestamp': 1502623500,
211 'upload_date': '20170813',
214 'skip_download': True,
216 'add_ie': [FranceTVIE.ie_key()],
219 'url': 'https://www.france.tv/france-3/des-chiffres-et-des-lettres/139063-emission-du-mardi-9-mai-2017.html',
220 'only_matching': True,
223 'url': 'https://www.france.tv/france-4/hero-corp/saison-1/134151-apres-le-calme.html',
224 'only_matching': True,
227 'url': 'https://www.france.tv/france-5/c-a-dire/saison-10/137013-c-a-dire.html',
228 'only_matching': True,
231 'url': 'https://www.france.tv/france-o/archipels/132249-mon-ancetre-l-esclave.html',
232 'only_matching': True,
235 'url': 'https://www.france.tv/france-2/direct.html',
236 'only_matching': True,
238 'url': 'https://www.france.tv/documentaires/histoire/136517-argentine-les-500-bebes-voles-de-la-dictature.html',
239 'only_matching': True,
241 'url': 'https://www.france.tv/jeux-et-divertissements/divertissements/133965-le-web-contre-attaque.html',
242 'only_matching': True,
244 'url': 'https://mobile.france.tv/france-5/c-dans-l-air/137347-emission-du-vendredi-12-mai-2017.html',
245 'only_matching': True,
247 'url': 'https://www.france.tv/142749-rouge-sang.html',
248 'only_matching': True,
251 def _real_extract(self, url):
252 display_id = self._match_id(url)
254 webpage = self._download_webpage(url, display_id)
257 video_id = self._search_regex(
258 r'data-main-video=(["\'])(?P<id>(?:(?!\1).)+)\1',
259 webpage, 'video id', default=None, group='id')
262 video_id, catalogue = self._html_search_regex(
263 r'(?:href=|player\.setVideo\(\s*)"http://videos?\.francetv\.fr/video/([^@]+@[^"]+)"',
264 webpage, 'video ID').split('@')
266 return self._make_url_result(video_id, catalogue)
269 class FranceTVEmbedIE(FranceTVBaseInfoExtractor):
270 _VALID_URL = r'https?://embed\.francetv\.fr/*\?.*?\bue=(?P<id>[^&]+)'
273 'url': 'http://embed.francetv.fr/?ue=7fd581a2ccf59d2fc5719c5c13cf6961',
277 'title': 'Le Pen Reims',
278 'upload_date': '20170505',
279 'timestamp': 1493981780,
283 'skip_download': True,
285 'add_ie': [FranceTVIE.ie_key()],
288 def _real_extract(self, url):
289 video_id = self._match_id(url)
291 video = self._download_json(
292 'http://api-embed.webservices.francetelevisions.fr/key/%s' % video_id,
295 return self._make_url_result(video['video_id'], video.get('catalog'))
298 class FranceTVInfoIE(FranceTVBaseInfoExtractor):
299 IE_NAME = 'francetvinfo.fr'
300 _VALID_URL = r'https?://(?:www|mobile|france3-regions)\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&.]+)'
303 'url': 'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
308 'upload_date': '20130826',
309 'timestamp': 1377548400,
315 'skip_download': True,
317 'add_ie': [FranceTVIE.ie_key()],
319 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
320 'only_matching': True,
322 'url': 'http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html',
323 'only_matching': True,
325 'url': 'http://france3-regions.francetvinfo.fr/bretagne/cotes-d-armor/thalassa-echappee-breizh-ce-venredi-dans-les-cotes-d-armor-954961.html',
326 'only_matching': True,
329 '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',
330 'md5': 'ee7f1828f25a648addc90cb2687b1f12',
334 'title': 'NDDL, référendum, Brexit : Cécile Duflot répond à Patrick Cohen',
335 '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',
336 'timestamp': 1467011958,
337 'upload_date': '20160627',
338 'uploader': 'France Inter',
339 'uploader_id': 'x2q2ez',
341 'add_ie': ['Dailymotion'],
343 'url': 'http://france3-regions.francetvinfo.fr/limousin/emissions/jt-1213-limousin',
344 'only_matching': True,
347 def _real_extract(self, url):
348 display_id = self._match_id(url)
350 webpage = self._download_webpage(url, display_id)
352 dailymotion_urls = DailymotionIE._extract_urls(webpage)
354 return self.playlist_result([
355 self.url_result(dailymotion_url, DailymotionIE.ie_key())
356 for dailymotion_url in dailymotion_urls])
358 video_id, catalogue = self._search_regex(
359 (r'id-video=([^@]+@[^"]+)',
360 r'<a[^>]+href="(?:https?:)?//videos\.francetv\.fr/video/([^@]+@[^"]+)"'),
361 webpage, 'video id').split('@')
363 return self._make_url_result(video_id, catalogue)
366 class GenerationWhatIE(InfoExtractor):
367 IE_NAME = 'france2.fr:generation-what'
368 _VALID_URL = r'https?://generation-what\.francetv\.fr/[^/]+/video/(?P<id>[^/?#&]+)'
371 'url': 'http://generation-what.francetv.fr/portrait/video/present-arms',
375 'title': 'Generation What - Garde à vous - FRA',
376 'uploader': 'Generation What',
377 'uploader_id': 'UCHH9p1eetWCgt4kXBYCb3_w',
378 'upload_date': '20160411',
381 'skip_download': True,
383 'add_ie': ['Youtube'],
385 'url': 'http://generation-what.francetv.fr/europe/video/present-arms',
386 'only_matching': True,
389 def _real_extract(self, url):
390 display_id = self._match_id(url)
392 webpage = self._download_webpage(url, display_id)
394 youtube_id = self._search_regex(
395 r"window\.videoURL\s*=\s*'([0-9A-Za-z_-]{11})';",
396 webpage, 'youtube id')
398 return self.url_result(youtube_id, ie='Youtube', video_id=youtube_id)
401 class CultureboxIE(FranceTVBaseInfoExtractor):
402 _VALID_URL = r'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&]+)'
405 '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',
409 'title': 'Cantates BWV 4, 106 et 131 de Bach par Raphaël Pichon 5/7',
410 'description': 'md5:19c44af004b88219f4daa50fa9a351d4',
411 'upload_date': '20180206',
412 'timestamp': 1517945220,
416 'skip_download': True,
418 'add_ie': [FranceTVIE.ie_key()],
421 def _real_extract(self, url):
422 display_id = self._match_id(url)
424 webpage = self._download_webpage(url, display_id)
426 if ">Ce live n'est plus disponible en replay<" in webpage:
427 raise ExtractorError(
428 'Video %s is not available' % display_id, expected=True)
430 video_id, catalogue = self._search_regex(
431 r'["\'>]https?://videos\.francetv\.fr/video/([^@]+@.+?)["\'<]',
432 webpage, 'video id').split('@')
434 return self._make_url_result(video_id, catalogue)
437 class FranceTVJeunesseIE(FranceTVBaseInfoExtractor):
438 _VALID_URL = r'(?P<url>https?://(?:www\.)?(?:zouzous|ludo)\.fr/heros/(?P<id>[^/?#&]+))'
441 'url': 'https://www.zouzous.fr/heros/simon',
447 'url': 'https://www.ludo.fr/heros/ninjago',
451 'playlist_count': 10,
453 'url': 'https://www.zouzous.fr/heros/simon?abc',
454 'only_matching': True,
457 def _real_extract(self, url):
458 mobj = re.match(self._VALID_URL, url)
459 playlist_id = mobj.group('id')
461 playlist = self._download_json(
462 '%s/%s' % (mobj.group('url'), 'playlist'), playlist_id)
464 if not playlist.get('count'):
465 raise ExtractorError(
466 '%s is not available' % playlist_id, expected=True)
469 for item in playlist['items']:
470 identity = item.get('identity')
471 if identity and isinstance(identity, compat_str):
472 entries.append(self._make_url_result(identity))
474 return self.playlist_result(entries, playlist_id)