3 from .common
import InfoExtractor
4 from .dailymotion
import DailymotionIE
5 from ..networking
import HEADRequest
19 from ..utils
.traversal
import traverse_obj
22 class FranceTVBaseInfoExtractor(InfoExtractor
):
23 def _make_url_result(self
, video_or_full_id
, catalog
=None, url
=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
28 full_id
= smuggle_url(full_id
, {'hostname': urllib.parse.urlparse(url).hostname}
)
29 return self
.url_result(
30 full_id
, ie
=FranceTVIE
.ie_key(),
31 video_id
=video_or_full_id
.split('@')[0])
34 class FranceTVIE(InfoExtractor
):
38 sivideo\.webservices\.francetelevisions\.fr/tools/getInfosOeuvre/v2/\?
39 .*?\bidDiffusion=[^&]+|
41 https?://videos\.francetv\.fr/video/|
44 (?P<id>[^@]+)(?:@(?P<catalog>.+))?
47 _EMBED_REGEX
= [r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
://)?embed\
.francetv\
.fr
/\?ue
=.+?
)\
1']
48 _GEO_COUNTRIES = ['FR
']
53 'url
': 'https
://sivideo
.webservices
.francetelevisions
.fr
/tools
/getInfosOeuvre
/v2
/?idDiffusion
=162311093&callback
=_jsonp_loader_callback_request_0
',
54 'md5
': 'c2248a8de38c4e65ea8fae7b5df2d84f
',
58 'title
': '13h15
, le dimanche
... - Les mystères de Jésus
',
59 'description
': 'md5
:75efe8d4c0a8205e5904498ffe1e1a42
',
60 'timestamp
': 1502623500,
61 'upload_date
': '20170813',
65 'url
': 'https
://sivideo
.webservices
.francetelevisions
.fr
/tools
/getInfosOeuvre
/v2
/?idDiffusion
=NI_1004933
&catalogue
=Zouzous
&callback
=_jsonp_loader_callback_request_4
',
66 'only_matching
': True,
68 'url
': 'http
://videos
.francetv
.fr
/video
/NI_657393
@Regions',
69 'only_matching
': True,
71 'url
': 'francetv
:162311093',
72 'only_matching
': True,
74 'url
': 'francetv
:NI_1004933
@Zouzous',
75 'only_matching
': True,
77 'url
': 'francetv
:NI_983319
@Info-web
',
78 'only_matching
': True,
80 'url
': 'francetv
:NI_983319
',
81 'only_matching
': True,
83 'url
': 'francetv
:NI_657393
@Regions',
84 'only_matching
': True,
87 'url
': 'francetv
:SIM_France3
',
88 'only_matching
': True,
91 def _extract_video(self, video_id, catalogue=None, hostname=None):
92 # TODO: Investigate/remove 'catalogue
'/'catalog
'; it has not been used since 2021
104 for device_type in ('desktop
', 'mobile
'):
105 dinfo = self._download_json(
106 'https
://player
.webservices
.francetelevisions
.fr
/v1
/videos
/%s' % video_id,
107 video_id, f'Downloading {device_type} video JSON
', query=filter_dict({
108 'device_type
': device_type,
116 video = traverse_obj(dinfo, ('video
', {dict}))
120 duration = video.get('duration
')
122 is_live = video.get('is_live
')
123 if spritesheets is None:
124 spritesheets = video.get('spritesheets
')
126 meta = traverse_obj(dinfo, ('meta
', {dict}))
129 title = meta.get('title
')
130 # meta['pre_title
'] contains season and episode number for series in format "S<ID> E<ID>"
131 season_number, episode_number = self._search_regex(
132 r'S(\d
+)\s
*E(\d
+)', meta.get('pre_title
'), 'episode info
', group=(1, 2), default=(None, None))
134 subtitle = meta.get('additional_title
')
136 image = meta.get('image_url
')
137 if timestamp is None:
138 timestamp = parse_iso8601(meta.get('broadcasted_at
'))
140 formats, subtitles, video_url = [], {}, None
141 for video in traverse_obj(videos, lambda _, v: url_or_none(v['url
'])):
142 video_url = video['url
']
143 format_id = video.get('format
')
145 token_url = url_or_none(video.get('token
'))
146 if token_url and video.get('workflow
') == 'token
-akamai
':
147 tokenized_url = traverse_obj(self._download_json(
148 token_url, video_id, f'Downloading signed {format_id} manifest URL
',
152 }), ('url
', {url_or_none}))
154 video_url = tokenized_url
156 ext = determine_ext(video_url)
158 formats.extend(self._extract_f4m_formats(
159 video_url, video_id, f4m_id=format_id, fatal=False))
161 fmts, subs = self._extract_m3u8_formats_and_subtitles(
162 video_url, video_id, 'mp4
',
163 entry_protocol='m3u8_native
', m3u8_id=format_id,
166 self._merge_subtitles(subs, target=subtitles)
168 fmts, subs = self._extract_mpd_formats_and_subtitles(
169 video_url, video_id, mpd_id=format_id, fatal=False)
171 self._merge_subtitles(subs, target=subtitles)
172 elif video_url.startswith('rtmp
'):
175 'format_id
': 'rtmp
-%s' % format_id,
179 if self._is_valid_url(video_url, video_id, format_id):
182 'format_id
': format_id,
185 # XXX: what is video['captions
']?
187 if not formats and video_url:
188 urlh = self._request_webpage(
189 HEADRequest(video_url), video_id, 'Checking
for geo
-restriction
',
190 fatal=False, expected_status=403)
191 if urlh and urlh.headers.get('x
-errortype
') == 'geo
':
192 self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
195 if f.get('acodec
') != 'none
' and f.get('language
') in ('qtz
', 'qad
'):
196 f['language_preference
'] = -10
197 f['format_note
'] = 'audio description
%s' % format_field(f, 'format_note
', ', %s')
201 'format_id
': 'spritesheets
',
202 'format_note
': 'storyboard
',
207 'url
': 'about
:invalid
',
210 # XXX: not entirely accurate; each spritesheet seems to be
211 # a 10×10 grid of thumbnails corresponding to approximately
212 # 2 seconds of the video; the last spritesheet may be shorter
214 } for sheet in spritesheets]
219 'title
': join_nonempty(title, subtitle, delim=' - ').strip(),
221 'duration
': duration,
222 'timestamp
': timestamp,
225 'subtitles
': subtitles,
226 'episode
': subtitle if episode_number else None,
227 'series
': title if episode_number else None,
228 'episode_number
': int_or_none(episode_number),
229 'season_number
': int_or_none(season_number),
232 def _real_extract(self, url):
233 url, smuggled_data = unsmuggle_url(url, {})
234 mobj = self._match_valid_url(url)
235 video_id = mobj.group('id')
236 catalog = mobj.group('catalog
')
240 video_id = qs.get('idDiffusion
', [None])[0]
241 catalog = qs.get('catalogue
', [None])[0]
243 raise ExtractorError('Invalid URL
', expected=True)
245 return self._extract_video(video_id, catalog, hostname=smuggled_data.get('hostname
'))
248 class FranceTVSiteIE(FranceTVBaseInfoExtractor):
249 _VALID_URL = r'https?
://(?
:(?
:www\
.)?france\
.tv|mobile\
.france\
.tv
)/(?
:[^
/]+/)*(?P
<id>[^
/]+)\
.html
'
252 'url
': 'https
://www
.france
.tv
/france
-2/13h15
-le
-dimanche
/140921-les
-mysteres
-de
-jesus
.html
',
254 'id': 'ec217ecc
-0733-48cf
-ac06
-af1347b849d1
',
256 'title
': '13h15
, le dimanche
... - Les mystères de Jésus
',
257 'timestamp
': 1502623500,
259 'thumbnail
': r're
:^https?
://.*\
.jpg$
',
260 'upload_date
': '20170813',
263 'skip_download
': True,
265 'add_ie
': [FranceTVIE.ie_key()],
267 'url
': 'https
://www
.france
.tv
/enfants
/six
-huit
-ans
/foot2rue
/saison
-1/3066387-duel
-au
-vieux
-port
.html
',
269 'id': 'a9050959
-eedd
-4b4a
-9b0d
-de6eeaa73e44
',
271 'title
': 'Foot2Rue
- Duel au vieux port
',
272 'episode
': 'Duel au vieux port
',
273 'series
': 'Foot2Rue
',
276 'timestamp
': 1642761360,
277 'upload_date
': '20220121',
278 'season
': 'Season
1',
279 'thumbnail
': r're
:^https?
://.*\
.jpg$
',
284 'url
': 'https
://www
.france
.tv
/france
-3/des
-chiffres
-et
-des
-lettres
/139063-emission
-du
-mardi
-9-mai
-2017.html
',
285 'only_matching
': True,
288 'url
': 'https
://www
.france
.tv
/france
-4/hero
-corp
/saison
-1/134151-apres
-le
-calme
.html
',
289 'only_matching
': True,
292 'url
': 'https
://www
.france
.tv
/france
-5/c
-a
-dire
/saison
-10/137013-c
-a
-dire
.html
',
293 'only_matching
': True,
296 'url
': 'https
://www
.france
.tv
/france
-o
/archipels
/132249-mon
-ancetre
-l
-esclave
.html
',
297 'only_matching
': True,
300 'url
': 'https
://www
.france
.tv
/france
-2/direct
.html
',
301 'only_matching
': True,
303 'url
': 'https
://www
.france
.tv
/documentaires
/histoire
/136517-argentine
-les
-500-bebes
-voles
-de
-la
-dictature
.html
',
304 'only_matching
': True,
306 'url
': 'https
://www
.france
.tv
/jeux
-et
-divertissements
/divertissements
/133965-le
-web
-contre
-attaque
.html
',
307 'only_matching
': True,
309 'url
': 'https
://mobile
.france
.tv
/france
-5/c
-dans
-l
-air
/137347-emission
-du
-vendredi
-12-mai
-2017.html
',
310 'only_matching
': True,
312 'url
': 'https
://www
.france
.tv
/142749-rouge
-sang
.html
',
313 'only_matching
': True,
316 'url
': 'https
://www
.france
.tv
/france
-3/direct
.html
',
317 'only_matching
': True,
320 def _real_extract(self, url):
321 display_id = self._match_id(url)
323 webpage = self._download_webpage(url, display_id)
326 video_id = self._search_regex(
327 r'(?
:data
-main
-video\s
*=|videoId
["\']?\s*[:=])\s*(["\'])(?P
<id>(?
:(?
!\
1).)+)\
1',
328 webpage, 'video
id', default=None, group='id')
331 video_id, catalogue = self._html_search_regex(
332 r'(?
:href
=|player\
.setVideo\
(\s
*)"http://videos?\.francetv\.fr/video/([^@]+@[^"]+)"',
333 webpage, 'video ID').split('@')
335 return self._make_url_result(video_id, catalogue, url=url)
338 class FranceTVInfoIE(FranceTVBaseInfoExtractor):
339 IE_NAME = 'francetvinfo.fr'
340 _VALID_URL = r'https?://(?:www|mobile|france3-regions)\.francetvinfo\.fr/(?:[^/]+/)*(?P<id>[^/?#&.]+)'
343 'url': 'https://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-jeudi-22-aout-2019_3561461.html',
345 'id': 'd12458ee-5062-48fe-bfdd-a30d6a01b793',
348 'upload_date': '20190822',
349 'timestamp': 1566510900,
350 'description': 'md5:72d167097237701d6e8452ff03b83c00',
356 'skip_download': True,
358 'add_ie': [FranceTVIE.ie_key()],
360 'note': 'Only an image exists in initial webpage instead of the video',
361 'url': 'https://www.francetvinfo.fr/sante/maladie/coronavirus/covid-19-en-inde-une-situation-catastrophique-a-new-dehli_4381095.html',
363 'id': '7d204c9e-a2d3-11eb-9e4c-000d3a23d482',
365 'title': 'Covid-19 : une situation catastrophique à New Dehli',
368 'timestamp': 1619028518,
369 'upload_date': '20210421',
372 'skip_download': True,
374 'add_ie': [FranceTVIE.ie_key()],
376 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
377 'only_matching': True,
379 'url': 'http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html',
380 'only_matching': True,
382 'url': 'http://france3-regions.francetvinfo.fr/bretagne/cotes-d-armor/thalassa-echappee-breizh-ce-venredi-dans-les-cotes-d-armor-954961.html',
383 'only_matching': True,
386 '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',
387 'md5': 'ee7f1828f25a648addc90cb2687b1f12',
391 'title': 'NDDL, référendum, Brexit : Cécile Duflot répond à Patrick Cohen',
392 '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',
393 'timestamp': 1467011958,
394 'upload_date': '20160627',
395 'uploader': 'France Inter',
396 'uploader_id': 'x2q2ez',
398 'add_ie': ['Dailymotion'],
400 'url': 'http://france3-regions.francetvinfo.fr/limousin/emissions/jt-1213-limousin',
401 'only_matching': True,
403 # "<figure
id=" pattern (#28792)
404 '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',
405 'only_matching': True,
408 def _real_extract(self, url):
409 display_id = self._match_id(url)
411 webpage = self._download_webpage(url, display_id)
413 dailymotion_urls = tuple(DailymotionIE._extract_embed_urls(url, webpage))
415 return self.playlist_result([
416 self.url_result(dailymotion_url, DailymotionIE.ie_key())
417 for dailymotion_url in dailymotion_urls])
419 video_id = self._search_regex(
420 (r'player\.load[^;]+src:\s*["\']([^
"\']+)',
421 r'id-video=([^@]+@[^"]+)',
422 r'<a
[^
>]+href
="(?:https?:)?//videos\.francetv\.fr/video/([^@]+@[^"]+)"',
423 r'(?:data-id|<figure[^<]+\bid)=["\']([\da
-f
]{8}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{12}
)'),
426 return self._make_url_result(video_id, url=url)