3 from __future__ import unicode_literals
8 from .common import InfoExtractor
9 from ..compat import compat_urlparse
17 from .dailymotion import DailymotionCloudIE
20 class FranceTVBaseInfoExtractor(InfoExtractor):
21 def _extract_video(self, video_id, catalogue):
22 info = self._download_json(
23 'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=%s&catalogue=%s'
24 % (video_id, catalogue),
25 video_id, 'Downloading video JSON')
27 if info.get('status') == 'NOK':
29 '%s returned error: %s' % (self.IE_NAME, info['message']), expected=True)
30 allowed_countries = info['videos'][0].get('geoblocage')
33 geo_info = self._download_json(
34 'http://geo.francetv.fr/ws/edgescape.json', video_id,
35 'Downloading geo restriction info')
36 country = geo_info['reponse']['geo_info']['country_code']
37 if country not in allowed_countries:
39 'The video is not available from your location',
45 for video in info['videos']:
46 if video['statut'] != 'ONLINE':
48 video_url = video['url']
51 format_id = video['format']
52 ext = determine_ext(video_url)
55 # See https://github.com/rg3/youtube-dl/issues/3963
58 f4m_url = self._download_webpage(
59 'http://hdfauth.francetv.fr/esi/TA?url=%s' % video_url,
60 video_id, 'Downloading f4m manifest token', fatal=False)
62 formats.extend(self._extract_f4m_formats(
63 f4m_url + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44', video_id, 1, format_id))
65 formats.extend(self._extract_m3u8_formats(video_url, video_id, 'mp4', m3u8_id=format_id))
66 elif video_url.startswith('rtmp'):
69 'format_id': 'rtmp-%s' % format_id,
76 'format_id': format_id,
79 self._sort_formats(formats)
82 subtitle = info.get('sous_titre')
84 title += ' - %s' % subtitle
88 'url': subtitle['url'],
89 'ext': subtitle.get('format'),
90 } for subtitle in info.get('subtitles', []) if subtitle.get('url')]
92 subtitles['fr'] = subtitles_list
97 'description': clean_html(info['synopsis']),
98 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', info['image']),
99 'duration': int_or_none(info.get('real_duration')) or parse_duration(info['duree']),
100 'timestamp': int_or_none(info['diffusion']['timestamp']),
102 'subtitles': subtitles,
106 class PluzzIE(FranceTVBaseInfoExtractor):
107 IE_NAME = 'pluzz.francetv.fr'
108 _VALID_URL = r'https?://pluzz\.francetv\.fr/videos/(.*?)\.html'
110 # Can't use tests, videos expire in 7 days
112 def _real_extract(self, url):
113 title = re.match(self._VALID_URL, url).group(1)
114 webpage = self._download_webpage(url, title)
115 video_id = self._search_regex(
116 r'data-diffusion="(\d+)"', webpage, 'ID')
117 return self._extract_video(video_id, 'Pluzz')
120 class FranceTvInfoIE(FranceTVBaseInfoExtractor):
121 IE_NAME = 'francetvinfo.fr'
122 _VALID_URL = r'https?://(?:www|mobile)\.francetvinfo\.fr/.*/(?P<title>.+)\.html'
125 'url': 'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
130 'upload_date': '20130826',
131 'timestamp': 1377548400,
134 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
138 'title': 'Débat des candidats à la Commission européenne',
139 'description': 'Débat des candidats à la Commission européenne',
142 'skip_download': 'HLS (reqires ffmpeg)'
144 'skip': 'Ce direct est terminé et sera disponible en rattrapage dans quelques minutes.',
146 'url': 'http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html',
147 'md5': 'f485bda6e185e7d15dbc69b72bae993e',
149 'id': '556e03339473995ee145930c',
151 'title': 'Les entreprises familiales : le secret de la réussite',
152 'thumbnail': 're:^https?://.*\.jpe?g$',
156 def _real_extract(self, url):
157 mobj = re.match(self._VALID_URL, url)
158 page_title = mobj.group('title')
159 webpage = self._download_webpage(url, page_title)
161 dmcloud_url = DailymotionCloudIE._extract_dmcloud_url(webpage)
163 return self.url_result(dmcloud_url, 'DailymotionCloud')
165 video_id, catalogue = self._search_regex(
166 r'id-video=([^@]+@[^"]+)', webpage, 'video id').split('@')
167 return self._extract_video(video_id, catalogue)
170 class FranceTVIE(FranceTVBaseInfoExtractor):
172 IE_DESC = 'France 2, 3, 4, 5 and Ô'
173 _VALID_URL = r'''(?x)
176 (?:www\.)?france[2345o]\.fr/
178 emissions/[^/]+/(?:videos|diffusions)|
184 embed\.francetv\.fr/\?ue=
192 'url': 'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
193 'md5': 'c03fc87cb85429ffd55df32b9fc05523',
197 'title': '13h15, le dimanche...',
198 'description': 'md5:9a0932bb465f22d377a449be9d1a0ff7',
199 'upload_date': '20140914',
200 'timestamp': 1410693600,
205 'url': 'http://www.france3.fr/emissions/pieces-a-conviction/diffusions/13-11-2013_145575',
206 'md5': '679bb8f8921f8623bd658fa2f8364da0',
208 'id': '000702326_CAPP_PicesconvictionExtrait313022013_120220131722_Au',
210 'title': 'Le scandale du prix des médicaments',
211 'description': 'md5:1384089fbee2f04fc6c9de025ee2e9ce',
212 'upload_date': '20131113',
213 'timestamp': 1384380000,
218 'url': 'http://www.france4.fr/emissions/hero-corp/videos/rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
219 'md5': 'a182bf8d2c43d88d46ec48fbdd260c1c',
221 'id': 'rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
223 'title': 'Hero Corp Making of - Extrait 1',
224 'description': 'md5:c87d54871b1790679aec1197e73d650a',
225 'upload_date': '20131106',
226 'timestamp': 1383766500,
231 'url': 'http://www.france5.fr/emissions/c-a-dire/videos/quels_sont_les_enjeux_de_cette_rentree_politique__31-08-2015_908948?onglet=tous&page=1',
232 'md5': 'f6c577df3806e26471b3d21631241fd0',
236 'title': 'C à dire ?! - Quels sont les enjeux de cette rentrée politique ?',
237 'description': 'md5:4a0d5cb5dce89d353522a84462bae5a4',
238 'upload_date': '20150831',
239 'timestamp': 1441035120,
244 'url': 'http://www.franceo.fr/jt/info-soir/18-07-2015',
245 'md5': '47d5816d3b24351cdce512ad7ab31da8',
249 'title': 'Infô soir',
250 'description': 'md5:01b8c6915a3d93d8bbbd692651714309',
251 'upload_date': '20150718',
252 'timestamp': 1437241200,
258 'url': 'http://embed.francetv.fr/?ue=8d7d3da1e3047c42ade5a5d7dfd3fc87',
262 'title': 'Alcaline, le concert avec Calogero',
263 'description': 'md5:61f08036dcc8f47e9cfc33aed08ffaff',
264 'upload_date': '20150226',
265 'timestamp': 1424989860,
270 'url': 'http://www.france4.fr/emission/highlander/diffusion-du-17-07-2015-04h05',
271 'only_matching': True,
274 'url': 'http://www.franceo.fr/videos/125377617',
275 'only_matching': True,
279 def _real_extract(self, url):
280 video_id = self._match_id(url)
281 webpage = self._download_webpage(url, video_id)
282 video_id, catalogue = self._html_search_regex(
283 r'href="http://videos?\.francetv\.fr/video/([^@]+@[^"]+)"',
284 webpage, 'video ID').split('@')
285 return self._extract_video(video_id, catalogue)
288 class GenerationQuoiIE(InfoExtractor):
289 IE_NAME = 'france2.fr:generation-quoi'
290 _VALID_URL = r'https?://generation-quoi\.france2\.fr/portrait/(?P<id>[^/?#]+)'
293 'url': 'http://generation-quoi.france2.fr/portrait/garde-a-vous',
295 'id': 'k7FJX8VBcvvLmX4wA5Q',
297 'title': 'Génération Quoi - Garde à Vous',
298 'uploader': 'Génération Quoi',
301 # It uses Dailymotion
302 'skip_download': True,
306 def _real_extract(self, url):
307 display_id = self._match_id(url)
308 info_url = compat_urlparse.urljoin(url, '/medias/video/%s.json' % display_id)
309 info_json = self._download_webpage(info_url, display_id)
310 info = json.loads(info_json)
311 return self.url_result('http://www.dailymotion.com/video/%s' % info['id'],
315 class CultureboxIE(FranceTVBaseInfoExtractor):
316 IE_NAME = 'culturebox.francetvinfo.fr'
317 _VALID_URL = r'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?P<name>.*?)(\?|$)'
320 'url': 'http://culturebox.francetvinfo.fr/live/musique/musique-classique/le-livre-vermeil-de-montserrat-a-la-cathedrale-delne-214511',
321 'md5': '9b88dc156781c4dbebd4c3e066e0b1d6',
325 'title': "Le Livre Vermeil de Montserrat à la Cathédrale d'Elne",
326 'description': 'md5:f8a4ad202e8fe533e2c493cc12e739d9',
327 'upload_date': '20150320',
328 'timestamp': 1426892400,
333 def _real_extract(self, url):
334 mobj = re.match(self._VALID_URL, url)
335 name = mobj.group('name')
337 webpage = self._download_webpage(url, name)
339 if ">Ce live n'est plus disponible en replay<" in webpage:
340 raise ExtractorError('Video %s is not available' % name, expected=True)
342 video_id, catalogue = self._search_regex(
343 r'"http://videos\.francetv\.fr/video/([^@]+@[^"]+)"', webpage, 'video id').split('@')
345 return self._extract_video(video_id, catalogue)