2b90bf4fc2fcba04fe7e164602196586713d4225
[youtube-dl] / 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'http://.*?\.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 = ('http://static.videos.gouv.fr/brightcovehub/export/json/'
29                     + video_id)
30         info = self._download_json(json_url, title, 'Downloading JSON config')
31         video_url = info['renditions'][0]['url']
32
33         return {
34             'id': video_id,
35             'ext': 'mp4',
36             'url': video_url,
37             'title': title,
38         }