]>
Commit | Line | Data |
---|---|---|
52afe996 PR |
1 | import re |
2 | import json | |
3 | ||
4 | from .common import InfoExtractor | |
5 | ||
6 | ||
7 | class DefenseGouvFrIE(InfoExtractor): | |
52afe996 PR |
8 | _IE_NAME = 'defense.gouv.fr' |
9 | _VALID_URL = (r'http://.*?\.defense\.gouv\.fr/layout/set/' | |
025171c4 | 10 | r'ligthboxvideo/base-de-medias/webtv/(.*)') |
52afe996 PR |
11 | |
12 | _TEST = { | |
025171c4 PR |
13 | u'url': (u'http://www.defense.gouv.fr/layout/set/ligthboxvideo/' |
14 | u'base-de-medias/webtv/attaque-chimique-syrienne-du-21-aout-2013-1'), | |
15 | u'file': u'11213.mp4', | |
16 | u'md5': u'75bba6124da7e63d2d60b5244ec9430c', | |
17 | "info_dict": { | |
18 | "title": "attaque-chimique-syrienne-du-21-aout-2013-1" | |
19 | } | |
52afe996 PR |
20 | } |
21 | ||
22 | def _real_extract(self, url): | |
23 | title = re.match(self._VALID_URL, url).group(1) | |
24 | webpage = self._download_webpage(url, title) | |
25 | video_id = self._search_regex( | |
26 | r"flashvars.pvg_id=\"(\d+)\";", | |
27 | webpage, 'ID') | |
28 | ||
29 | json_url = ('http://static.videos.gouv.fr/brightcovehub/export/json/' | |
30 | + video_id) | |
31 | info = self._download_webpage(json_url, title, | |
32 | 'Downloading JSON config') | |
33 | video_url = json.loads(info)['renditions'][0]['url'] | |
34 | ||
35 | return {'id': video_id, | |
36 | 'ext': 'mp4', | |
37 | 'url': video_url, | |
38 | 'title': title, | |
39 | } |