- def _extract_video(self, video_id):
- xml_desc = self._download_webpage(
- 'http://www.francetvinfo.fr/appftv/webservices/video/'
- 'getInfosOeuvre.php?id-diffusion='
- + video_id, video_id, 'Downloading XML config')
- info = xml.etree.ElementTree.fromstring(xml_desc.encode('utf-8'))
-
- manifest_url = info.find('videos/video/url').text
- video_url = manifest_url.replace('manifest.f4m', 'index_2_av.m3u8')
- video_url = video_url.replace('/z/', '/i/')
- thumbnail_path = info.find('image').text
-
- return {'id': video_id,
- 'ext': 'mp4',
- 'url': video_url,
- 'title': info.find('titre').text,
- 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', thumbnail_path),
- 'description': info.find('synopsis').text,
- }
+ def _extract_video(self, video_id, catalogue):
+ info = self._download_json(
+ 'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=%s&catalogue=%s'
+ % (video_id, catalogue),
+ video_id, 'Downloading video JSON')
+
+ if info.get('status') == 'NOK':
+ raise ExtractorError(
+ '%s returned error: %s' % (self.IE_NAME, info['message']), expected=True)
+ allowed_countries = info['videos'][0].get('geoblocage')
+ if allowed_countries:
+ georestricted = True
+ geo_info = self._download_json(
+ 'http://geo.francetv.fr/ws/edgescape.json', video_id,
+ 'Downloading geo restriction info')
+ country = geo_info['reponse']['geo_info']['country_code']
+ if country not in allowed_countries:
+ raise ExtractorError(
+ 'The video is not available from your location',
+ expected=True)
+ else:
+ 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)
+
+ return {
+ 'id': video_id,
+ 'title': info['titre'],
+ 'description': clean_html(info['synopsis']),
+ 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', info['image']),
+ 'duration': int_or_none(info.get('real_duration')) or parse_duration(info['duree']),
+ 'timestamp': int_or_none(info['diffusion']['timestamp']),
+ 'formats': formats,
+ }