1 from .common
import InfoExtractor
9 from .dailymotion
import DailymotionIE
12 class FranceTVBaseInfoExtractor(InfoExtractor
):
13 def _make_url_result(self
, video_or_full_id
, catalog
=None):
14 full_id
= 'francetv:%s' % video_or_full_id
15 if '@' not in video_or_full_id
and catalog
:
16 full_id
+= '@%s' % catalog
17 return self
.url_result(
18 full_id
, ie
=FranceTVIE
.ie_key(),
19 video_id
=video_or_full_id
.split('@')[0])
22 class FranceTVIE(InfoExtractor
):
26 sivideo\.webservices\.francetelevisions\.fr/tools/getInfosOeuvre/v2/\?
27 .*?\bidDiffusion=[^&]+|
29 https?://videos\.francetv\.fr/video/|
32 (?P<id>[^@]+)(?:@(?P<catalog>.+))?
38 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=162311093&callback=_jsonp_loader_callback_request_0',
39 'md5': 'c2248a8de38c4e65ea8fae7b5df2d84f',
43 'title': '13h15, le dimanche... - Les mystères de Jésus',
44 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42',
45 'timestamp': 1502623500,
46 'upload_date': '20170813',
50 'url': 'https://sivideo.webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=NI_1004933&catalogue=Zouzous&callback=_jsonp_loader_callback_request_4',
51 'only_matching': True,
53 'url': 'http://videos.francetv.fr/video/NI_657393@Regions',
54 'only_matching': True,
56 'url': 'francetv:162311093',
57 'only_matching': True,
59 'url': 'francetv:NI_1004933@Zouzous',
60 'only_matching': True,
62 'url': 'francetv:NI_983319@Info-web',
63 'only_matching': True,
65 'url': 'francetv:NI_983319',
66 'only_matching': True,
68 'url': 'francetv:NI_657393@Regions',
69 'only_matching': True,
72 'url': 'francetv:SIM_France3',
73 'only_matching': True,
76 def _extract_video(self
, video_id
, catalogue
=None):
77 # Videos are identified by idDiffusion so catalogue part is optional.
78 # However when provided, some extra formats may be returned so we pass
89 for device_type
in ('desktop', 'mobile'):
90 dinfo
= self
._download
_json
(
91 'https://player.webservices.francetelevisions.fr/v1/videos/%s' % video_id
,
92 video_id
, 'Downloading %s video JSON' % device_type
, query
={
93 'device_type': device_type
,
100 video
= dinfo
.get('video')
104 duration
= video
.get('duration')
106 is_live
= video
.get('is_live')
107 if spritesheets
is None:
108 spritesheets
= video
.get('spritesheets')
110 meta
= dinfo
.get('meta')
113 title
= meta
.get('title')
114 # XXX: what is meta['pre_title']?
116 subtitle
= meta
.get('additional_title')
118 image
= meta
.get('image_url')
119 if timestamp
is None:
120 timestamp
= parse_iso8601(meta
.get('broadcasted_at'))
125 format_id
= video
.get('format')
128 if video
.get('workflow') == 'token-akamai':
129 token_url
= video
.get('token')
131 token_json
= self
._download
_json
(
133 'Downloading signed %s manifest URL' % format_id
)
135 video_url
= token_json
.get('url')
137 video_url
= video
.get('url')
139 ext
= determine_ext(video_url
)
141 formats
.extend(self
._extract
_f
4m
_formats
(
142 video_url
, video_id
, f4m_id
=format_id
, fatal
=False))
144 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
145 video_url
, video_id
, 'mp4',
146 entry_protocol
='m3u8_native', m3u8_id
=format_id
,
149 self
._merge
_subtitles
(subs
, target
=subtitles
)
151 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(
152 video_url
, video_id
, mpd_id
=format_id
, fatal
=False)
154 self
._merge
_subtitles
(subs
, target
=subtitles
)
155 elif video_url
.startswith('rtmp'):
158 'format_id': 'rtmp-%s' % format_id
,
162 if self
._is
_valid
_url
(video_url
, video_id
, format_id
):
165 'format_id': format_id
,
168 # XXX: what is video['captions']?
171 if f
.get('acodec') != 'none' and f
.get('language') in ('qtz', 'qad'):
172 f
['language_preference'] = -10
173 f
['format_note'] = 'audio description%s' % format_field(f
, 'format_note', ', %s')
177 'format_id': 'spritesheets',
178 'format_note': 'storyboard',
183 'url': 'about:invalid',
186 # XXX: not entirely accurate; each spritesheet seems to be
187 # a 10×10 grid of thumbnails corresponding to approximately
188 # 2 seconds of the video; the last spritesheet may be shorter
190 } for sheet
in spritesheets
]
193 self
._sort
_formats
(formats
)
196 title
+= ' - %s' % subtitle
197 title
= title
.strip()
203 'duration': duration
,
204 'timestamp': timestamp
,
207 'subtitles': subtitles
,
210 def _real_extract(self
, url
):
211 mobj
= self
._match
_valid
_url
(url
)
212 video_id
= mobj
.group('id')
213 catalog
= mobj
.group('catalog')
217 video_id
= qs
.get('idDiffusion', [None])[0]
218 catalog
= qs
.get('catalogue', [None])[0]
220 raise ExtractorError('Invalid URL', expected
=True)
222 return self
._extract
_video
(video_id
, catalog
)
225 class FranceTVSiteIE(FranceTVBaseInfoExtractor
):
226 _VALID_URL
= r
'https?://(?:(?:www\.)?france\.tv|mobile\.france\.tv)/(?:[^/]+/)*(?P<id>[^/]+)\.html'
229 'url': 'https://www.france.tv/france-2/13h15-le-dimanche/140921-les-mysteres-de-jesus.html',
231 'id': 'ec217ecc-0733-48cf-ac06-af1347b849d1',
233 'title': '13h15, le dimanche... - Les mystères de Jésus',
234 'description': 'md5:75efe8d4c0a8205e5904498ffe1e1a42',
235 'timestamp': 1502623500,
236 'upload_date': '20170813',
239 'skip_download': True,
241 'add_ie': [FranceTVIE
.ie_key()],
244 'url': 'https://www.france.tv/france-3/des-chiffres-et-des-lettres/139063-emission-du-mardi-9-mai-2017.html',
245 'only_matching': True,
248 'url': 'https://www.france.tv/france-4/hero-corp/saison-1/134151-apres-le-calme.html',
249 'only_matching': True,
252 'url': 'https://www.france.tv/france-5/c-a-dire/saison-10/137013-c-a-dire.html',
253 'only_matching': True,
256 'url': 'https://www.france.tv/france-o/archipels/132249-mon-ancetre-l-esclave.html',
257 'only_matching': True,
260 'url': 'https://www.france.tv/france-2/direct.html',
261 'only_matching': True,
263 'url': 'https://www.france.tv/documentaires/histoire/136517-argentine-les-500-bebes-voles-de-la-dictature.html',
264 'only_matching': True,
266 'url': 'https://www.france.tv/jeux-et-divertissements/divertissements/133965-le-web-contre-attaque.html',
267 'only_matching': True,
269 'url': 'https://mobile.france.tv/france-5/c-dans-l-air/137347-emission-du-vendredi-12-mai-2017.html',
270 'only_matching': True,
272 'url': 'https://www.france.tv/142749-rouge-sang.html',
273 'only_matching': True,
276 'url': 'https://www.france.tv/france-3/direct.html',
277 'only_matching': True,
280 def _real_extract(self
, url
):
281 display_id
= self
._match
_id
(url
)
283 webpage
= self
._download
_webpage
(url
, display_id
)
286 video_id
= self
._search
_regex
(
287 r
'(?:data-main-video\s*=|videoId["\']?\s
*[:=])\s
*(["\'])(?P<id>(?:(?!\1).)+)\1',
288 webpage, 'video id', default=None, group='id')
291 video_id, catalogue = self._html_search_regex(
292 r'(?:href=|player\.setVideo\(\s*)"http
://videos?\
.francetv\
.fr
/video
/([^
@]+@[^
"]+)"',
293 webpage, 'video ID
').split('@')
295 return self._make_url_result(video_id, catalogue)
298 class FranceTVInfoIE(FranceTVBaseInfoExtractor):
299 IE_NAME = 'francetvinfo
.fr
'
300 _VALID_URL = r'https?
://(?
:www|mobile|france3
-regions
)\
.francetvinfo\
.fr
/(?
:[^
/]+/)*(?P
<id>[^
/?
#&.]+)'
303 'url': 'https://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-jeudi-22-aout-2019_3561461.html',
305 'id': 'd12458ee-5062-48fe-bfdd-a30d6a01b793',
308 'upload_date': '20190822',
309 'timestamp': 1566510900,
310 'description': 'md5:72d167097237701d6e8452ff03b83c00',
316 'skip_download': True,
318 'add_ie': [FranceTVIE
.ie_key()],
320 'note': 'Only an image exists in initial webpage instead of the video',
321 'url': 'https://www.francetvinfo.fr/sante/maladie/coronavirus/covid-19-en-inde-une-situation-catastrophique-a-new-dehli_4381095.html',
323 'id': '7d204c9e-a2d3-11eb-9e4c-000d3a23d482',
325 'title': 'Covid-19 : une situation catastrophique à New Dehli',
328 'timestamp': 1619028518,
329 'upload_date': '20210421',
332 'skip_download': True,
334 'add_ie': [FranceTVIE
.ie_key()],
336 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
337 'only_matching': True,
339 'url': 'http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html',
340 'only_matching': True,
342 'url': 'http://france3-regions.francetvinfo.fr/bretagne/cotes-d-armor/thalassa-echappee-breizh-ce-venredi-dans-les-cotes-d-armor-954961.html',
343 'only_matching': True,
346 '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',
347 'md5': 'ee7f1828f25a648addc90cb2687b1f12',
351 'title': 'NDDL, référendum, Brexit : Cécile Duflot répond à Patrick Cohen',
352 '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',
353 'timestamp': 1467011958,
354 'upload_date': '20160627',
355 'uploader': 'France Inter',
356 'uploader_id': 'x2q2ez',
358 'add_ie': ['Dailymotion'],
360 'url': 'http://france3-regions.francetvinfo.fr/limousin/emissions/jt-1213-limousin',
361 'only_matching': True,
363 # "<figure id=" pattern (#28792)
364 'url': 'https://www.francetvinfo.fr/culture/patrimoine/incendie-de-notre-dame-de-paris/notre-dame-de-paris-de-l-incendie-de-la-cathedrale-a-sa-reconstruction_4372291.html',
365 'only_matching': True,
368 def _real_extract(self
, url
):
369 display_id
= self
._match
_id
(url
)
371 webpage
= self
._download
_webpage
(url
, display_id
)
373 dailymotion_urls
= DailymotionIE
._extract
_urls
(webpage
)
375 return self
.playlist_result([
376 self
.url_result(dailymotion_url
, DailymotionIE
.ie_key())
377 for dailymotion_url
in dailymotion_urls
])
379 video_id
= self
._search
_regex
(
380 (r
'player\.load[^;]+src:\s*["\']([^
"\']+)',
381 r'id-video=([^@]+@[^"]+)',
382 r'<a
[^
>]+href
="(?:https?:)?//videos\.francetv\.fr/video/([^@]+@[^"]+)"',
383 r'(?:data-id|<figure[^<]+\bid)=["\']([\da
-f
]{8}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{12}
)'),
386 return self._make_url_result(video_id)