]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/defense.py
424d960da95fc54ed7759e89a941f87b3da59801
[youtubedl] / youtube_dl / extractor / defense.py
1 import re
2 import json
3
4 from .common import InfoExtractor
5
6
7 class DefenseGouvFrIE(InfoExtractor):
8 _IE_NAME = 'defense.gouv.fr'
9 _VALID_URL = (r'http://.*?\.defense\.gouv\.fr/layout/set/'
10 r'ligthboxvideo/base-de-medias/webtv/(.*)')
11
12 _TEST = {
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 }
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 }