You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

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