3 from __future__
import unicode_literals
8 from .common
import InfoExtractor
14 compat_urllib_parse_urlparse
,
19 class FranceTVBaseInfoExtractor(InfoExtractor
):
20 def _extract_video(self
, video_id
, catalogue
):
21 info
= self
._download
_json
(
22 'http://webservices.francetelevisions.fr/tools/getInfosOeuvre/v2/?idDiffusion=%s&catalogue=%s'
23 % (video_id
, catalogue
),
24 video_id
, 'Downloading video JSON')
26 if info
.get('status') == 'NOK':
28 '%s returned error: %s' % (self
.IE_NAME
, info
['message']), expected
=True)
29 allowed_countries
= info
['videos'][0].get('geoblocage')
32 geo_info
= self
._download
_json
(
33 'http://geo.francetv.fr/ws/edgescape.json', video_id
,
34 'Downloading geo restriction info')
35 country
= geo_info
['reponse']['geo_info']['country_code']
36 if country
not in allowed_countries
:
38 'The video is not available from your location',
44 for video
in info
['videos']:
45 if video
['statut'] != 'ONLINE':
47 video_url
= video
['url']
50 format_id
= video
['format']
51 if video_url
.endswith('.f4m'):
53 # See https://github.com/rg3/youtube-dl/issues/3963
56 video_url_parsed
= compat_urllib_parse_urlparse(video_url
)
57 f4m_url
= self
._download
_webpage
(
58 'http://hdfauth.francetv.fr/esi/urltokengen2.html?url=%s' % video_url_parsed
.path
,
59 video_id
, 'Downloading f4m manifest token', fatal
=False)
61 f4m_formats
= self
._extract
_f
4m
_formats
(f4m_url
, video_id
)
62 for f4m_format
in f4m_formats
:
63 f4m_format
['preference'] = 1
64 formats
.extend(f4m_formats
)
65 elif video_url
.endswith('.m3u8'):
66 formats
.extend(self
._extract
_m
3u8_formats
(video_url
, video_id
, 'mp4'))
67 elif video_url
.startswith('rtmp'):
70 'format_id': 'rtmp-%s' % format_id
,
77 'format_id': format_id
,
80 self
._sort
_formats
(formats
)
84 'title': info
['titre'],
85 'description': clean_html(info
['synopsis']),
86 'thumbnail': compat_urlparse
.urljoin('http://pluzz.francetv.fr', info
['image']),
87 'duration': parse_duration(info
['duree']),
88 'timestamp': int_or_none(info
['diffusion']['timestamp']),
93 class PluzzIE(FranceTVBaseInfoExtractor
):
94 IE_NAME
= 'pluzz.francetv.fr'
95 _VALID_URL
= r
'https?://pluzz\.francetv\.fr/videos/(.*?)\.html'
97 # Can't use tests, videos expire in 7 days
99 def _real_extract(self
, url
):
100 title
= re
.match(self
._VALID
_URL
, url
).group(1)
101 webpage
= self
._download
_webpage
(url
, title
)
102 video_id
= self
._search
_regex
(
103 r
'data-diffusion="(\d+)"', webpage
, 'ID')
104 return self
._extract
_video
(video_id
, 'Pluzz')
107 class FranceTvInfoIE(FranceTVBaseInfoExtractor
):
108 IE_NAME
= 'francetvinfo.fr'
109 _VALID_URL
= r
'https?://(?:www|mobile)\.francetvinfo\.fr/.*/(?P<title>.+)\.html'
112 'url': 'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
117 'upload_date': '20130826',
118 'timestamp': 1377548400,
121 'url': 'http://www.francetvinfo.fr/elections/europeennes/direct-europeennes-regardez-le-debat-entre-les-candidats-a-la-presidence-de-la-commission_600639.html',
125 'title': 'Débat des candidats à la Commission européenne',
126 'description': 'Débat des candidats à la Commission européenne',
129 'skip_download': 'HLS (reqires ffmpeg)'
131 'skip': 'Ce direct est terminé et sera disponible en rattrapage dans quelques minutes.',
134 def _real_extract(self
, url
):
135 mobj
= re
.match(self
._VALID
_URL
, url
)
136 page_title
= mobj
.group('title')
137 webpage
= self
._download
_webpage
(url
, page_title
)
138 video_id
, catalogue
= self
._search
_regex
(
139 r
'id-video=([^@]+@[^"]+)', webpage
, 'video id').split('@')
140 return self
._extract
_video
(video_id
, catalogue
)
143 class FranceTVIE(FranceTVBaseInfoExtractor
):
145 IE_DESC
= 'France 2, 3, 4, 5 and Ô'
146 _VALID_URL
= r
'''(?x)https?://www\.france[2345o]\.fr/
148 emissions/.*?/(videos|emissions)/(?P<id>[^/?]+)
149 | (emissions?|jt)/(?P<key>[^/?]+)
155 'url': 'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
156 'md5': 'c03fc87cb85429ffd55df32b9fc05523',
160 'title': '13h15, le dimanche...',
161 'description': 'md5:9a0932bb465f22d377a449be9d1a0ff7',
162 'upload_date': '20140914',
163 'timestamp': 1410693600,
168 'url': 'http://www.france3.fr/emissions/pieces-a-conviction/diffusions/13-11-2013_145575',
169 'md5': '679bb8f8921f8623bd658fa2f8364da0',
171 'id': '000702326_CAPP_PicesconvictionExtrait313022013_120220131722_Au',
173 'title': 'Le scandale du prix des médicaments',
174 'description': 'md5:1384089fbee2f04fc6c9de025ee2e9ce',
175 'upload_date': '20131113',
176 'timestamp': 1384380000,
181 'url': 'http://www.france4.fr/emissions/hero-corp/videos/rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
182 'md5': 'a182bf8d2c43d88d46ec48fbdd260c1c',
184 'id': 'rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
186 'title': 'Hero Corp Making of - Extrait 1',
187 'description': 'md5:c87d54871b1790679aec1197e73d650a',
188 'upload_date': '20131106',
189 'timestamp': 1383766500,
194 'url': 'http://www.france5.fr/emissions/c-a-dire/videos/92837968',
195 'md5': '78f0f4064f9074438e660785bbf2c5d9',
199 'title': 'C à dire ?!',
200 'description': 'md5:1a4aeab476eb657bf57c4ff122129f81',
201 'upload_date': '20140915',
202 'timestamp': 1410795000,
207 'url': 'http://www.franceo.fr/jt/info-afrique/04-12-2013',
208 'md5': '52f0bfe202848b15915a2f39aaa8981b',
212 'title': 'Infô Afrique',
213 'description': 'md5:ebf346da789428841bee0fd2a935ea55',
214 'upload_date': '20140915',
215 'timestamp': 1410822000,
220 def _real_extract(self
, url
):
221 mobj
= re
.match(self
._VALID
_URL
, url
)
222 webpage
= self
._download
_webpage
(url
, mobj
.group('key') or mobj
.group('id'))
223 video_id
, catalogue
= self
._html
_search
_regex
(
224 r
'href="http://videos\.francetv\.fr/video/([^@]+@[^"]+)"',
225 webpage
, 'video ID').split('@')
226 return self
._extract
_video
(video_id
, catalogue
)
229 class GenerationQuoiIE(InfoExtractor
):
230 IE_NAME
= 'france2.fr:generation-quoi'
231 _VALID_URL
= r
'https?://generation-quoi\.france2\.fr/portrait/(?P<name>.*)(\?|$)'
234 'url': 'http://generation-quoi.france2.fr/portrait/garde-a-vous',
235 'file': 'k7FJX8VBcvvLmX4wA5Q.mp4',
237 'title': 'Génération Quoi - Garde à Vous',
238 'uploader': 'Génération Quoi',
241 # It uses Dailymotion
242 'skip_download': True,
244 'skip': 'Only available from France',
247 def _real_extract(self
, url
):
248 mobj
= re
.match(self
._VALID
_URL
, url
)
249 name
= mobj
.group('name')
250 info_url
= compat_urlparse
.urljoin(url
, '/medias/video/%s.json' % name
)
251 info_json
= self
._download
_webpage
(info_url
, name
)
252 info
= json
.loads(info_json
)
253 return self
.url_result('http://www.dailymotion.com/video/%s' % info
['id'],
257 class CultureboxIE(FranceTVBaseInfoExtractor
):
258 IE_NAME
= 'culturebox.francetvinfo.fr'
259 _VALID_URL
= r
'https?://(?:m\.)?culturebox\.francetvinfo\.fr/(?P<name>.*?)(\?|$)'
262 'url': 'http://culturebox.francetvinfo.fr/festivals/dans-les-jardins-de-william-christie/dans-les-jardins-de-william-christie-le-camus-162553',
263 'md5': '5ad6dec1ffb2a3fbcb20cc4b744be8d6',
267 'title': 'Dans les jardins de William Christie - Le Camus',
268 'description': 'md5:4710c82315c40f0c865ca8b9a68b5299',
269 'upload_date': '20140829',
270 'timestamp': 1409317200,
274 def _real_extract(self
, url
):
275 mobj
= re
.match(self
._VALID
_URL
, url
)
276 name
= mobj
.group('name')
277 webpage
= self
._download
_webpage
(url
, name
)
278 video_id
, catalogue
= self
._search
_regex
(
279 r
'"http://videos\.francetv\.fr/video/([^@]+@[^"]+)"', webpage
, 'video id').split('@')
281 return self
._extract
_video
(video_id
, catalogue
)