3 from __future__
import unicode_literals
8 from .common
import InfoExtractor
10 compat_urllib_parse_urlparse
,
21 from .dailymotion
import DailymotionCloudIE
24 class FranceTVBaseInfoExtractor(InfoExtractor
):
25 def _extract_video(self
, video_id
, catalogue
):
26 info
= self
._download
_json
(
27 'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=%s&catalogue=%s'
28 % (video_id
, catalogue
),
29 video_id
, 'Downloading video JSON')
31 if info
.get('status') == 'NOK':
33 '%s returned error: %s' % (self
.IE_NAME
, info
['message']), expected
=True)
34 allowed_countries
= info
['videos'][0].get('geoblocage')
37 geo_info
= self
._download
_json
(
38 'http://geo.francetv.fr/ws/edgescape.json', video_id
,
39 'Downloading geo restriction info')
40 country
= geo_info
['reponse']['geo_info']['country_code']
41 if country
not in allowed_countries
:
43 'The video is not available from your location',
49 for video
in info
['videos']:
50 if video
['statut'] != 'ONLINE':
52 video_url
= video
['url']
55 format_id
= video
['format']
56 ext
= determine_ext(video_url
)
59 # See https://github.com/rg3/youtube-dl/issues/3963
62 video_url_parsed
= compat_urllib_parse_urlparse(video_url
)
63 f4m_url
= self
._download
_webpage
(
64 'http://hdfauth.francetv.fr/esi/TA?url=%s' % video_url_parsed
.path
,
65 video_id
, 'Downloading f4m manifest token', fatal
=False)
67 formats
.extend(self
._extract
_f
4m
_formats
(f4m_url
, video_id
, 1, format_id
))
69 formats
.extend(self
._extract
_m
3u8_formats
(video_url
, video_id
, 'mp4', m3u8_id
=format_id
))
70 elif video_url
.startswith('rtmp'):
73 'format_id': 'rtmp-%s' % format_id
,
80 'format_id': format_id
,
83 self
._sort
_formats
(formats
)
87 'title': info
['titre'],
88 'description': clean_html(info
['synopsis']),
89 'thumbnail': compat_urlparse
.urljoin('http://pluzz.francetv.fr', info
['image']),
90 'duration': float_or_none(info
.get('real_duration'), 1000) or parse_duration(info
['duree']),
91 'timestamp': int_or_none(info
['diffusion']['timestamp']),
96 class PluzzIE(FranceTVBaseInfoExtractor
):
97 IE_NAME
= 'pluzz.francetv.fr'
98 _VALID_URL
= r
'https?://pluzz\.francetv\.fr/videos/(.*?)\.html'
100 # Can't use tests, videos expire in 7 days
102 def _real_extract(self
, url
):
103 title
= re
.match(self
._VALID
_URL
, url
).group(1)
104 webpage
= self
._download
_webpage
(url
, title
)
105 video_id
= self
._search
_regex
(
106 r
'data-diffusion="(\d+)"', webpage
, 'ID')
107 return self
._extract
_video
(video_id
, 'Pluzz')
110 class FranceTvInfoIE(FranceTVBaseInfoExtractor
):
111 IE_NAME
= 'francetvinfo.fr'
112 _VALID_URL
= r
'https?://(?:www|mobile)\.francetvinfo\.fr/.*/(?P<title>.+)\.html'
115 'url': 'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
120 'upload_date': '20130826',
121 'timestamp': 1377548400,
124 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
128 'title': 'Débat des candidats à la Commission européenne',
129 'description': 'Débat des candidats à la Commission européenne',
132 'skip_download': 'HLS (reqires ffmpeg)'
134 'skip': 'Ce direct est terminé et sera disponible en rattrapage dans quelques minutes.',
136 'url': 'http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html',
137 'md5': 'f485bda6e185e7d15dbc69b72bae993e',
139 'id': '556e03339473995ee145930c',
141 'title': 'Les entreprises familiales : le secret de la réussite',
142 'thumbnail': 're:^https?://.*\.jpe?g$',
146 def _real_extract(self
, url
):
147 mobj
= re
.match(self
._VALID
_URL
, url
)
148 page_title
= mobj
.group('title')
149 webpage
= self
._download
_webpage
(url
, page_title
)
151 dmcloud_url
= DailymotionCloudIE
._extract
_dmcloud
_url
(webpage
)
153 return self
.url_result(dmcloud_url
, 'DailymotionCloud')
155 video_id
, catalogue
= self
._search
_regex
(
156 r
'id-video=([^@]+@[^"]+)', webpage
, 'video id').split('@')
157 return self
._extract
_video
(video_id
, catalogue
)
160 class FranceTVIE(FranceTVBaseInfoExtractor
):
162 IE_DESC
= 'France 2, 3, 4, 5 and Ô'
163 _VALID_URL
= r
'''(?x)
166 (?:www\.)?france[2345o]\.fr/
168 emissions/[^/]+/(?:videos|diffusions)?|
172 embed\.francetv\.fr/\?ue=
180 'url': 'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
181 'md5': 'c03fc87cb85429ffd55df32b9fc05523',
185 'title': '13h15, le dimanche...',
186 'description': 'md5:9a0932bb465f22d377a449be9d1a0ff7',
187 'upload_date': '20140914',
188 'timestamp': 1410693600,
193 'url': 'http://www.france3.fr/emissions/pieces-a-conviction/diffusions/13-11-2013_145575',
194 'md5': '679bb8f8921f8623bd658fa2f8364da0',
196 'id': '000702326_CAPP_PicesconvictionExtrait313022013_120220131722_Au',
198 'title': 'Le scandale du prix des médicaments',
199 'description': 'md5:1384089fbee2f04fc6c9de025ee2e9ce',
200 'upload_date': '20131113',
201 'timestamp': 1384380000,
206 'url': 'http://www.france4.fr/emissions/hero-corp/videos/rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
207 'md5': 'a182bf8d2c43d88d46ec48fbdd260c1c',
209 'id': 'rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
211 'title': 'Hero Corp Making of - Extrait 1',
212 'description': 'md5:c87d54871b1790679aec1197e73d650a',
213 'upload_date': '20131106',
214 'timestamp': 1383766500,
219 'url': 'http://www.france5.fr/emissions/c-a-dire/videos/92837968',
220 'md5': '78f0f4064f9074438e660785bbf2c5d9',
224 'title': 'C à dire ?!',
225 'description': 'md5:1a4aeab476eb657bf57c4ff122129f81',
226 'upload_date': '20140915',
227 'timestamp': 1410795000,
232 'url': 'http://www.franceo.fr/jt/info-afrique/04-12-2013',
233 'md5': '52f0bfe202848b15915a2f39aaa8981b',
237 'title': 'Infô Afrique',
238 'description': 'md5:ebf346da789428841bee0fd2a935ea55',
239 'upload_date': '20140915',
240 'timestamp': 1410822000,
245 'url': 'http://embed.francetv.fr/?ue=8d7d3da1e3047c42ade5a5d7dfd3fc87',
249 'title': 'Alcaline, le concert avec Calogero',
250 'description': 'md5:',
251 'upload_date': '20150226',
252 'timestamp': 1424989860,
256 'url': 'http://www.france4.fr/emission/highlander/diffusion-du-17-07-2015-04h05',
257 'only_matching': True,
260 'url': 'http://www.franceo.fr/videos/125377617',
261 'only_matching': True,
265 def _real_extract(self
, url
):
266 video_id
= self
._match
_id
(url
)
267 webpage
= self
._download
_webpage
(url
, video_id
)
268 video_id
, catalogue
= self
._html
_search
_regex
(
269 r
'href="http://videos?\.francetv\.fr/video/([^@]+@[^"]+)"',
270 webpage
, 'video ID').split('@')
271 return self
._extract
_video
(video_id
, catalogue
)
274 class GenerationQuoiIE(InfoExtractor
):
275 IE_NAME
= 'france2.fr:generation-quoi'
276 _VALID_URL
= r
'https?://generation-quoi\.france2\.fr/portrait/(?P<id>[^/?#]+)'
279 'url': 'http://generation-quoi.france2.fr/portrait/garde-a-vous',
281 'id': 'k7FJX8VBcvvLmX4wA5Q',
283 'title': 'Génération Quoi - Garde à Vous',
284 'uploader': 'Génération Quoi',
287 # It uses Dailymotion
288 'skip_download': True,
292 def _real_extract(self
, url
):
293 display_id
= self
._match
_id
(url
)
294 info_url
= compat_urlparse
.urljoin(url
, '/medias/video/%s.json' % display_id
)
295 info_json
= self
._download
_webpage
(info_url
, display_id
)
296 info
= json
.loads(info_json
)
297 return self
.url_result('http://www.dailymotion.com/video/%s' % info
['id'],
301 class CultureboxIE(FranceTVBaseInfoExtractor
):
302 IE_NAME
= 'culturebox.francetvinfo.fr'
303 _VALID_URL
= r
'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?P<name>.*?)(\?|$)'
306 'url': 'http://culturebox.francetvinfo.fr/live/musique/musique-classique/le-livre-vermeil-de-montserrat-a-la-cathedrale-delne-214511',
307 'md5': '9b88dc156781c4dbebd4c3e066e0b1d6',
311 'title': "Le Livre Vermeil de Montserrat à la Cathédrale d'Elne",
312 'description': 'md5:f8a4ad202e8fe533e2c493cc12e739d9',
313 'upload_date': '20150320',
314 'timestamp': 1426892400,
319 def _real_extract(self
, url
):
320 mobj
= re
.match(self
._VALID
_URL
, url
)
321 name
= mobj
.group('name')
323 webpage
= self
._download
_webpage
(url
, name
)
325 if ">Ce live n'est plus disponible en replay<" in webpage
:
326 raise ExtractorError('Video %s is not available' % name
, expected
=True)
328 video_id
, catalogue
= self
._search
_regex
(
329 r
'"http://videos\.francetv\.fr/video/([^@]+@[^"]+)"', webpage
, 'video id').split('@')
331 return self
._extract
_video
(video_id
, catalogue
)