3 from __future__ import unicode_literals
8 from .common import InfoExtractor
10 compat_urllib_parse_urlparse,
21 class FranceTVBaseInfoExtractor(InfoExtractor):
22 def _extract_video(self, video_id, catalogue):
23 info = self._download_json(
24 'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=%s&catalogue=%s'
25 % (video_id, catalogue),
26 video_id, 'Downloading video JSON')
28 if info.get('status') == 'NOK':
30 '%s returned error: %s' % (self.IE_NAME, info['message']), expected=True)
31 allowed_countries = info['videos'][0].get('geoblocage')
34 geo_info = self._download_json(
35 'http://geo.francetv.fr/ws/edgescape.json', video_id,
36 'Downloading geo restriction info')
37 country = geo_info['reponse']['geo_info']['country_code']
38 if country not in allowed_countries:
40 'The video is not available from your location',
46 for video in info['videos']:
47 if video['statut'] != 'ONLINE':
49 video_url = video['url']
52 format_id = video['format']
53 if video_url.endswith('.f4m'):
55 # See https://github.com/rg3/youtube-dl/issues/3963
58 video_url_parsed = compat_urllib_parse_urlparse(video_url)
59 f4m_url = self._download_webpage(
60 'http://hdfauth.francetv.fr/esi/urltokengen2.html?url=%s' % video_url_parsed.path,
61 video_id, 'Downloading f4m manifest token', fatal=False)
63 f4m_formats = self._extract_f4m_formats(f4m_url, video_id)
64 for f4m_format in f4m_formats:
65 f4m_format['preference'] = 1
66 formats.extend(f4m_formats)
67 elif video_url.endswith('.m3u8'):
68 formats.extend(self._extract_m3u8_formats(video_url, video_id, 'mp4'))
69 elif video_url.startswith('rtmp'):
72 'format_id': 'rtmp-%s' % format_id,
79 'format_id': format_id,
82 self._sort_formats(formats)
86 'title': info['titre'],
87 'description': clean_html(info['synopsis']),
88 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', info['image']),
89 'duration': parse_duration(info['duree']),
90 'timestamp': int_or_none(info['diffusion']['timestamp']),
95 class PluzzIE(FranceTVBaseInfoExtractor):
96 IE_NAME = 'pluzz.francetv.fr'
97 _VALID_URL = r'https?://pluzz\.francetv\.fr/videos/(.*?)\.html'
99 # Can't use tests, videos expire in 7 days
101 def _real_extract(self, url):
102 title = re.match(self._VALID_URL, url).group(1)
103 webpage = self._download_webpage(url, title)
104 video_id = self._search_regex(
105 r'data-diffusion="(\d+)"', webpage, 'ID')
106 return self._extract_video(video_id, 'Pluzz')
109 class FranceTvInfoIE(FranceTVBaseInfoExtractor):
110 IE_NAME = 'francetvinfo.fr'
111 _VALID_URL = r'https?://(?:www|mobile)\.francetvinfo\.fr/.*/(?P<title>.+)\.html'
114 'url': 'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
119 'upload_date': '20130826',
120 'timestamp': 1377548400,
123 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
127 'title': 'Débat des candidats à la Commission européenne',
128 'description': 'Débat des candidats à la Commission européenne',
131 'skip_download': 'HLS (reqires ffmpeg)'
133 'skip': 'Ce direct est terminé et sera disponible en rattrapage dans quelques minutes.',
136 def _real_extract(self, url):
137 mobj = re.match(self._VALID_URL, url)
138 page_title = mobj.group('title')
139 webpage = self._download_webpage(url, page_title)
140 video_id, catalogue = self._search_regex(
141 r'id-video=([^@]+@[^"]+)', webpage, 'video id').split('@')
142 return self._extract_video(video_id, catalogue)
145 class FranceTVIE(FranceTVBaseInfoExtractor):
147 IE_DESC = 'France 2, 3, 4, 5 and Ô'
148 _VALID_URL = r'''(?x)https?://www\.france[2345o]\.fr/
150 emissions/.*?/(videos|emissions)/(?P<id>[^/?]+)
151 | (emissions?|jt)/(?P<key>[^/?]+)
157 'url': 'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
158 'md5': 'c03fc87cb85429ffd55df32b9fc05523',
162 'title': '13h15, le dimanche...',
163 'description': 'md5:9a0932bb465f22d377a449be9d1a0ff7',
164 'upload_date': '20140914',
165 'timestamp': 1410693600,
170 'url': 'http://www.france3.fr/emissions/pieces-a-conviction/diffusions/13-11-2013_145575',
171 'md5': '679bb8f8921f8623bd658fa2f8364da0',
173 'id': '000702326_CAPP_PicesconvictionExtrait313022013_120220131722_Au',
175 'title': 'Le scandale du prix des médicaments',
176 'description': 'md5:1384089fbee2f04fc6c9de025ee2e9ce',
177 'upload_date': '20131113',
178 'timestamp': 1384380000,
183 'url': 'http://www.france4.fr/emissions/hero-corp/videos/rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
184 'md5': 'a182bf8d2c43d88d46ec48fbdd260c1c',
186 'id': 'rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
188 'title': 'Hero Corp Making of - Extrait 1',
189 'description': 'md5:c87d54871b1790679aec1197e73d650a',
190 'upload_date': '20131106',
191 'timestamp': 1383766500,
196 'url': 'http://www.france5.fr/emissions/c-a-dire/videos/92837968',
197 'md5': '78f0f4064f9074438e660785bbf2c5d9',
201 'title': 'C à dire ?!',
202 'description': 'md5:1a4aeab476eb657bf57c4ff122129f81',
203 'upload_date': '20140915',
204 'timestamp': 1410795000,
209 'url': 'http://www.franceo.fr/jt/info-afrique/04-12-2013',
210 'md5': '52f0bfe202848b15915a2f39aaa8981b',
214 'title': 'Infô Afrique',
215 'description': 'md5:ebf346da789428841bee0fd2a935ea55',
216 'upload_date': '20140915',
217 'timestamp': 1410822000,
222 def _real_extract(self, url):
223 mobj = re.match(self._VALID_URL, url)
224 webpage = self._download_webpage(url, mobj.group('key') or mobj.group('id'))
225 video_id, catalogue = self._html_search_regex(
226 r'href="http://videos\.francetv\.fr/video/([^@]+@[^"]+)"',
227 webpage, 'video ID').split('@')
228 return self._extract_video(video_id, catalogue)
231 class GenerationQuoiIE(InfoExtractor):
232 IE_NAME = 'france2.fr:generation-quoi'
233 _VALID_URL = r'https?://generation-quoi\.france2\.fr/portrait/(?P<name>.*)(\?|$)'
236 'url': 'http://generation-quoi.france2.fr/portrait/garde-a-vous',
237 'file': 'k7FJX8VBcvvLmX4wA5Q.mp4',
239 'title': 'Génération Quoi - Garde à Vous',
240 'uploader': 'Génération Quoi',
243 # It uses Dailymotion
244 'skip_download': True,
246 'skip': 'Only available from France',
249 def _real_extract(self, url):
250 mobj = re.match(self._VALID_URL, url)
251 name = mobj.group('name')
252 info_url = compat_urlparse.urljoin(url, '/medias/video/%s.json' % name)
253 info_json = self._download_webpage(info_url, name)
254 info = json.loads(info_json)
255 return self.url_result('http://www.dailymotion.com/video/%s' % info['id'],
259 class CultureboxIE(FranceTVBaseInfoExtractor):
260 IE_NAME = 'culturebox.francetvinfo.fr'
261 _VALID_URL = r'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?P<name>.*?)(\?|$)'
264 'url': 'http://culturebox.francetvinfo.fr/festivals/dans-les-jardins-de-william-christie/dans-les-jardins-de-william-christie-le-camus-162553',
265 'md5': '5ad6dec1ffb2a3fbcb20cc4b744be8d6',
269 'title': 'Dans les jardins de William Christie - Le Camus',
270 'description': 'md5:4710c82315c40f0c865ca8b9a68b5299',
271 'upload_date': '20140829',
272 'timestamp': 1409317200,
276 def _real_extract(self, url):
277 mobj = re.match(self._VALID_URL, url)
278 name = mobj.group('name')
279 webpage = self._download_webpage(url, name)
280 video_id, catalogue = self._search_regex(
281 r'"http://videos\.francetv\.fr/video/([^@]+@[^"]+)"', webpage, 'video id').split('@')
283 return self._extract_video(video_id, catalogue)