logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

defense.py (1242B)


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