- formats = []
- available_formats = self._search_regex(r'/[^,]*,(.*?),k\.mp4', manifest_url, 'available formats')
- for index, format_descr in enumerate(available_formats.split(',')):
- format_info = {
- 'url': manifest_url.replace('manifest.f4m', 'index_%d_av.m3u8' % index),
- 'ext': 'mp4',
- }
- m_resolution = re.search(r'(?P<width>\d+)x(?P<height>\d+)', format_descr)
- if m_resolution is not None:
- format_info.update({
- 'width': int(m_resolution.group('width')),
- 'height': int(m_resolution.group('height')),
- })
- formats.append(format_info)
-
- thumbnail_path = info.find('image').text
+ georestricted = False
+
+ formats = []
+ for video in info['videos']:
+ if video['statut'] != 'ONLINE':
+ continue
+ video_url = video['url']
+ if not video_url:
+ continue
+ format_id = video['format']
+ ext = determine_ext(video_url)
+ if ext == 'f4m':
+ if georestricted:
+ # See https://github.com/rg3/youtube-dl/issues/3963
+ # m3u8 urls work fine
+ continue
+ f4m_url = self._download_webpage(
+ 'http://hdfauth.francetv.fr/esi/TA?url=%s' % video_url,
+ video_id, 'Downloading f4m manifest token', fatal=False)
+ if f4m_url:
+ formats.extend(self._extract_f4m_formats(
+ f4m_url + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id, 1, format_id))
+ elif ext == 'm3u8':
+ formats.extend(self._extract_m3u8_formats(video_url, video_id, 'mp4', m3u8_id=format_id))
+ elif video_url.startswith('rtmp'):
+ formats.append({
+ 'url': video_url,
+ 'format_id': 'rtmp-%s' % format_id,
+ 'ext': 'flv',
+ 'preference': 1,
+ })
+ else:
+ formats.append({
+ 'url': video_url,
+ 'format_id': format_id,
+ 'preference': -1,
+ })
+ self._sort_formats(formats)
+
+ title = info['titre']
+ subtitle = info.get('sous_titre')
+ if subtitle:
+ title += ' - %s' % subtitle
+
+ subtitles = {}
+ subtitles_list = [{
+ 'url': subformat['url'],
+ 'ext': subformat.get('format'),
+ } for subformat in info.get('subtitles', []) if subformat.get('url')]
+ if subtitles_list:
+ subtitles['fr'] = subtitles_list