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.

40 lines
1.3 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. class DefenseGouvFrIE(InfoExtractor):
  6. IE_NAME = 'defense.gouv.fr'
  7. _VALID_URL = (r'http://.*?\.defense\.gouv\.fr/layout/set/'
  8. r'ligthboxvideo/base-de-medias/webtv/(.*)')
  9. _TEST = {
  10. 'url': 'http://www.defense.gouv.fr/layout/set/ligthboxvideo/base-de-medias/webtv/attaque-chimique-syrienne-du-21-aout-2013-1',
  11. 'file': '11213.mp4',
  12. 'md5': '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. }