3 from __future__
import unicode_literals
8 from .common
import InfoExtractor
10 compat_urllib_parse_urlparse
,
23 class FranceTVBaseInfoExtractor(InfoExtractor
):
24 def _extract_video(self
, video_id
, catalogue
):
25 info
= self
._download
_json
(
26 'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=%s&catalogue=%s'
27 % (video_id
, catalogue
),
28 video_id
, 'Downloading video JSON')
30 if info
.get('status') == 'NOK':
32 '%s returned error: %s' % (self
.IE_NAME
, info
['message']), expected
=True)
33 allowed_countries
= info
['videos'][0].get('geoblocage')
36 geo_info
= self
._download
_json
(
37 'http://geo.francetv.fr/ws/edgescape.json', video_id
,
38 'Downloading geo restriction info')
39 country
= geo_info
['reponse']['geo_info']['country_code']
40 if country
not in allowed_countries
:
42 'The video is not available from your location',
48 for video
in info
['videos']:
49 if video
['statut'] != 'ONLINE':
51 video_url
= video
['url']
54 format_id
= video
['format']
55 ext
= determine_ext(video_url
)
58 # See https://github.com/rg3/youtube-dl/issues/3963
61 video_url_parsed
= compat_urllib_parse_urlparse(video_url
)
62 f4m_url
= self
._download
_webpage
(
63 'http://hdfauth.francetv.fr/esi/urltokengen2.html?url=%s' % video_url_parsed
.path
,
64 video_id
, 'Downloading f4m manifest token', fatal
=False)
66 formats
.extend(self
._extract
_f
4m
_formats
(f4m_url
, video_id
, 1, format_id
))
68 formats
.extend(self
._extract
_m
3u8_formats
(video_url
, video_id
, 'mp4', m3u8_id
=format_id
))
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': float_or_none(info
.get('real_duration'), 1000) or 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<id>[^/?#]+)'
236 'url': 'http://generation-quoi.france2.fr/portrait/garde-a-vous',
238 'id': 'k7FJX8VBcvvLmX4wA5Q',
240 'title': 'Génération Quoi - Garde à Vous',
241 'uploader': 'Génération Quoi',
244 # It uses Dailymotion
245 'skip_download': True,
249 def _real_extract(self
, url
):
250 display_id
= self
._match
_id
(url
)
251 info_url
= compat_urlparse
.urljoin(url
, '/medias/video/%s.json' % display_id
)
252 info_json
= self
._download
_webpage
(info_url
, display_id
)
253 info
= json
.loads(info_json
)
254 return self
.url_result('http://www.dailymotion.com/video/%s' % info
['id'],
258 class CultureboxIE(FranceTVBaseInfoExtractor
):
259 IE_NAME
= 'culturebox.francetvinfo.fr'
260 _VALID_URL
= r
'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?P<name>.*?)(\?|$)'
263 'url': 'http://culturebox.francetvinfo.fr/live/musique/musique-classique/le-livre-vermeil-de-montserrat-a-la-cathedrale-delne-214511',
264 'md5': '9b88dc156781c4dbebd4c3e066e0b1d6',
268 'title': "Le Livre Vermeil de Montserrat à la Cathédrale d'Elne",
269 'description': 'md5:f8a4ad202e8fe533e2c493cc12e739d9',
270 'upload_date': '20150320',
271 'timestamp': 1426892400,
276 def _real_extract(self
, url
):
277 mobj
= re
.match(self
._VALID
_URL
, url
)
278 name
= mobj
.group('name')
280 webpage
= self
._download
_webpage
(url
, name
)
282 if ">Ce live n'est plus disponible en replay<" in webpage
:
283 raise ExtractorError('Video %s is not available' % name
, expected
=True)
285 video_id
, catalogue
= self
._search
_regex
(
286 r
'"http://videos\.francetv\.fr/video/([^@]+@[^"]+)"', webpage
, 'video id').split('@')
288 return self
._extract
_video
(video_id
, catalogue
)