defense.py 1.2 KB

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