]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/defense.py
Imported Upstream version 2014.10.30
[youtubedl] / youtube_dl / extractor / defense.py
1 from __future__ import unicode_literals
2
3 import re
4 import json
5
6 from .common import InfoExtractor
7
8
9 class DefenseGouvFrIE(InfoExtractor):
10 IE_NAME = 'defense.gouv.fr'
11 _VALID_URL = (r'http://.*?\.defense\.gouv\.fr/layout/set/'
12 r'ligthboxvideo/base-de-medias/webtv/(.*)')
13
14 _TEST = {
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',
18 "info_dict": {
19 "title": "attaque-chimique-syrienne-du-21-aout-2013-1"
20 }
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')
29
30 json_url = ('http://static.videos.gouv.fr/brightcovehub/export/json/'
31 + video_id)
32 info = self._download_webpage(json_url, title,
33 'Downloading JSON config')
34 video_url = json.loads(info)['renditions'][0]['url']
35
36 return {'id': video_id,
37 'ext': 'mp4',
38 'url': video_url,
39 'title': title,
40 }