]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/defense.py
Prepate to upload
[youtubedl] / youtube_dl / extractor / defense.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class DefenseGouvFrIE(InfoExtractor):
7 IE_NAME = 'defense.gouv.fr'
8 _VALID_URL = r'https?://.*?\.defense\.gouv\.fr/layout/set/ligthboxvideo/base-de-medias/webtv/(?P<id>[^/?#]*)'
9
10 _TEST = {
11 'url': 'http://www.defense.gouv.fr/layout/set/ligthboxvideo/base-de-medias/webtv/attaque-chimique-syrienne-du-21-aout-2013-1',
12 'md5': '75bba6124da7e63d2d60b5244ec9430c',
13 'info_dict': {
14 'id': '11213',
15 'ext': 'mp4',
16 'title': 'attaque-chimique-syrienne-du-21-aout-2013-1'
17 }
18 }
19
20 def _real_extract(self, url):
21 title = self._match_id(url)
22 webpage = self._download_webpage(url, title)
23
24 video_id = self._search_regex(
25 r"flashvars.pvg_id=\"(\d+)\";",
26 webpage, 'ID')
27
28 json_url = (
29 'http://static.videos.gouv.fr/brightcovehub/export/json/%s' %
30 video_id)
31 info = self._download_json(json_url, title, 'Downloading JSON config')
32 video_url = info['renditions'][0]['url']
33
34 return {
35 'id': video_id,
36 'ext': 'mp4',
37 'url': video_url,
38 'title': title,
39 }