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