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_id, catalog=None):
24 full_id = 'francetv:%s' % video_id
26 full_id += '@%s' % catalog
27 return self.url_result(
28 full_id, ie=FranceTVIE.ie_key(), video_id=video_id)
31 class FranceTVIE(InfoExtractor):
35 sivideo\.webservices\.francetelevisions\.fr/tools/getInfosOeuvre/v2/\?
36 .*?\bidDiffusion=[^&]+|
38 https?://videos\.francetv\.fr/video/|
41 (?P<id>[^@]+)(?:@(?P<catalog>.+))?
47 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=162311093&callback=_jsonp_loader_callback_request_0',
48 'md5': 'c2248a8de38c4e65ea8fae7b5df2d84f',
52 'title': '13h15, le dimanche... - Les mystères de Jésus',
53 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42',
54 'timestamp': 1502623500,
55 'upload_date': '20170813',
59 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=NI_1004933&catalogue=Zouzous&callback=_jsonp_loader_callback_request_4',
60 'only_matching': True,
62 'url': 'http://videos.francetv.fr/video/NI_657393@Regions',
63 'only_matching': True,
65 'url': 'francetv:162311093',
66 'only_matching': True,
68 'url': 'francetv:NI_1004933@Zouzous',
69 'only_matching': True,
71 'url': 'francetv:NI_983319@Info-web',
72 'only_matching': True,
74 'url': 'francetv:NI_983319',
75 'only_matching': True,
77 'url': 'francetv:NI_657393@Regions',
78 'only_matching': True,
81 def _extract_video(self, video_id, catalogue=None):
82 # Videos are identified by idDiffusion so catalogue part is optional.
83 # However when provided, some extra formats may be returned so we pass
85 info = self._download_json(
86 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/',
87 video_id, 'Downloading video JSON', query={
88 'idDiffusion': video_id,
89 'catalogue': catalogue or '',
92 if info.get('status') == 'NOK':
94 '%s returned error: %s' % (self.IE_NAME, info['message']),
96 allowed_countries = info['videos'][0].get('geoblocage')
99 geo_info = self._download_json(
100 'http://geo.francetv.fr/ws/edgescape.json', video_id,
101 'Downloading geo restriction info')
102 country = geo_info['reponse']['geo_info']['country_code']
103 if country not in allowed_countries:
104 raise ExtractorError(
105 'The video is not available from your location',
108 georestricted = False
110 def sign(manifest_url, manifest_id):
111 for host in ('hdfauthftv-a.akamaihd.net', 'hdfauth.francetv.fr'):
112 signed_url = self._download_webpage(
113 'https://%s/esi/TA' % host, video_id,
114 'Downloading signed %s manifest URL' % manifest_id,
118 if (signed_url and isinstance(signed_url, compat_str) and
119 re.search(r'^(?:https?:)?//', signed_url)):
124 for video in info['videos']:
125 if video['statut'] != 'ONLINE':
127 video_url = video['url']
130 format_id = video['format']
131 ext = determine_ext(video_url)
134 # See https://github.com/rg3/youtube-dl/issues/3963
135 # m3u8 urls work fine
137 formats.extend(self._extract_f4m_formats(
138 sign(video_url, format_id) + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44',
139 video_id, f4m_id=format_id, fatal=False))
141 formats.extend(self._extract_m3u8_formats(
142 sign(video_url, format_id), video_id, 'mp4',
143 entry_protocol='m3u8_native', m3u8_id=format_id,
145 elif video_url.startswith('rtmp'):
148 'format_id': 'rtmp-%s' % format_id,
152 if self._is_valid_url(video_url, video_id, format_id):
155 'format_id': format_id,
157 self._sort_formats(formats)
159 title = info['titre']
160 subtitle = info.get('sous_titre')
162 title += ' - %s' % subtitle
163 title = title.strip()
167 'url': subformat['url'],
168 'ext': subformat.get('format'),
169 } for subformat in info.get('subtitles', []) if subformat.get('url')]
171 subtitles['fr'] = subtitles_list
176 'description': clean_html(info['synopsis']),
177 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', info['image']),
178 'duration': int_or_none(info.get('real_duration')) or parse_duration(info['duree']),
179 'timestamp': int_or_none(info['diffusion']['timestamp']),
181 'subtitles': subtitles,
184 def _real_extract(self, url):
185 mobj = re.match(self._VALID_URL, url)
186 video_id = mobj.group('id')
187 catalog = mobj.group('catalog')
190 qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
191 video_id = qs.get('idDiffusion', [None])[0]
192 catalog = qs.get('catalogue', [None])[0]
194 raise ExtractorError('Invalid URL', expected=True)
196 return self._extract_video(video_id, catalog)
199 class FranceTVSiteIE(FranceTVBaseInfoExtractor):
200 _VALID_URL = r'https?://(?:(?:www\.)?france\.tv|mobile\.france\.tv)/(?:[^/]+/)*(?P<id>[^/]+)\.html'
203 'url': 'https://www.france.tv/france-2/13h15-le-dimanche/140921-les-mysteres-de-jesus.html',
207 'title': '13h15, le dimanche... - Les mystères de Jésus',
208 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42',
209 'timestamp': 1502623500,
210 'upload_date': '20170813',
213 'skip_download': True,
215 'add_ie': [FranceTVIE.ie_key()],
218 'url': 'https://www.france.tv/france-3/des-chiffres-et-des-lettres/139063-emission-du-mardi-9-mai-2017.html',
219 'only_matching': True,
222 'url': 'https://www.france.tv/france-4/hero-corp/saison-1/134151-apres-le-calme.html',
223 'only_matching': True,
226 'url': 'https://www.france.tv/france-5/c-a-dire/saison-10/137013-c-a-dire.html',
227 'only_matching': True,
230 'url': 'https://www.france.tv/france-o/archipels/132249-mon-ancetre-l-esclave.html',
231 'only_matching': True,
234 'url': 'https://www.france.tv/france-2/direct.html',
235 'only_matching': True,
237 'url': 'https://www.france.tv/documentaires/histoire/136517-argentine-les-500-bebes-voles-de-la-dictature.html',
238 'only_matching': True,
240 'url': 'https://www.france.tv/jeux-et-divertissements/divertissements/133965-le-web-contre-attaque.html',
241 'only_matching': True,
243 'url': 'https://mobile.france.tv/france-5/c-dans-l-air/137347-emission-du-vendredi-12-mai-2017.html',
244 'only_matching': True,
246 'url': 'https://www.france.tv/142749-rouge-sang.html',
247 'only_matching': True,
250 def _real_extract(self, url):
251 display_id = self._match_id(url)
253 webpage = self._download_webpage(url, display_id)
256 video_id = self._search_regex(
257 r'data-main-video=(["\'])(?P<id>(?:(?!\1).)+)\1',
258 webpage, 'video id', default=None, group='id')
261 video_id, catalogue = self._html_search_regex(
262 r'(?:href=|player\.setVideo\(\s*)"http://videos?\.francetv\.fr/video/([^@]+@[^"]+)"',
263 webpage, 'video ID').split('@')
265 return self._make_url_result(video_id, catalogue)
268 class FranceTVEmbedIE(FranceTVBaseInfoExtractor):
269 _VALID_URL = r'https?://embed\.francetv\.fr/*\?.*?\bue=(?P<id>[^&]+)'
272 'url': 'http://embed.francetv.fr/?ue=7fd581a2ccf59d2fc5719c5c13cf6961',
276 'title': 'Le Pen Reims',
277 'upload_date': '20170505',
278 'timestamp': 1493981780,
282 'skip_download': True,
284 'add_ie': [FranceTVIE.ie_key()],
287 def _real_extract(self, url):
288 video_id = self._match_id(url)
290 video = self._download_json(
291 'http://api-embed.webservices.francetelevisions.fr/key/%s' % video_id,
294 return self._make_url_result(video['video_id'], video.get('catalog'))
297 class FranceTVInfoIE(FranceTVBaseInfoExtractor):
298 IE_NAME = 'francetvinfo.fr'
299 _VALID_URL = r'https?://(?:www|mobile|france3-regions)\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&.]+)'
302 'url': 'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
307 'upload_date': '20130826',
308 'timestamp': 1377548400,
314 'skip_download': True,
316 'add_ie': [FranceTVIE.ie_key()],
318 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
319 'only_matching': True,
321 'url': 'http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html',
322 'only_matching': True,
324 'url': 'http://france3-regions.francetvinfo.fr/bretagne/cotes-d-armor/thalassa-echappee-breizh-ce-venredi-dans-les-cotes-d-armor-954961.html',
325 'only_matching': True,
328 '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',
329 'md5': 'ee7f1828f25a648addc90cb2687b1f12',
333 'title': 'NDDL, référendum, Brexit : Cécile Duflot répond à Patrick Cohen',
334 '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',
335 'timestamp': 1467011958,
336 'upload_date': '20160627',
337 'uploader': 'France Inter',
338 'uploader_id': 'x2q2ez',
340 'add_ie': ['Dailymotion'],
342 'url': 'http://france3-regions.francetvinfo.fr/limousin/emissions/jt-1213-limousin',
343 'only_matching': True,
346 def _real_extract(self, url):
347 display_id = self._match_id(url)
349 webpage = self._download_webpage(url, display_id)
351 dailymotion_urls = DailymotionIE._extract_urls(webpage)
353 return self.playlist_result([
354 self.url_result(dailymotion_url, DailymotionIE.ie_key())
355 for dailymotion_url in dailymotion_urls])
357 video_id, catalogue = self._search_regex(
358 (r'id-video=([^@]+@[^"]+)',
359 r'<a[^>]+href="(?:https?:)?//videos\.francetv\.fr/video/([^@]+@[^"]+)"'),
360 webpage, 'video id').split('@')
362 return self._make_url_result(video_id, catalogue)
365 class GenerationWhatIE(InfoExtractor):
366 IE_NAME = 'france2.fr:generation-what'
367 _VALID_URL = r'https?://generation-what\.francetv\.fr/[^/]+/video/(?P<id>[^/?#&]+)'
370 'url': 'http://generation-what.francetv.fr/portrait/video/present-arms',
374 'title': 'Generation What - Garde à vous - FRA',
375 'uploader': 'Generation What',
376 'uploader_id': 'UCHH9p1eetWCgt4kXBYCb3_w',
377 'upload_date': '20160411',
380 'skip_download': True,
382 'add_ie': ['Youtube'],
384 'url': 'http://generation-what.francetv.fr/europe/video/present-arms',
385 'only_matching': True,
388 def _real_extract(self, url):
389 display_id = self._match_id(url)
391 webpage = self._download_webpage(url, display_id)
393 youtube_id = self._search_regex(
394 r"window\.videoURL\s*=\s*'([0-9A-Za-z_-]{11})';",
395 webpage, 'youtube id')
397 return self.url_result(youtube_id, ie='Youtube', video_id=youtube_id)
400 class CultureboxIE(FranceTVBaseInfoExtractor):
401 _VALID_URL = r'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&]+)'
404 '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',
408 'title': 'Cantates BWV 4, 106 et 131 de Bach par Raphaël Pichon 5/7',
409 'description': 'md5:19c44af004b88219f4daa50fa9a351d4',
410 'upload_date': '20180206',
411 'timestamp': 1517945220,
415 'skip_download': True,
417 'add_ie': [FranceTVIE.ie_key()],
420 def _real_extract(self, url):
421 display_id = self._match_id(url)
423 webpage = self._download_webpage(url, display_id)
425 if ">Ce live n'est plus disponible en replay<" in webpage:
426 raise ExtractorError(
427 'Video %s is not available' % display_id, expected=True)
429 video_id, catalogue = self._search_regex(
430 r'["\'>]https?://videos\.francetv\.fr/video/([^@]+@.+?)["\'<]',
431 webpage, 'video id').split('@')
433 return self._make_url_result(video_id, catalogue)