logo

youtube-dl

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

nuevo.py (1209B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. float_or_none,
  6. xpath_text
  7. )
  8. class NuevoBaseIE(InfoExtractor):
  9. def _extract_nuevo(self, config_url, video_id, headers={}):
  10. config = self._download_xml(
  11. config_url, video_id, transform_source=lambda s: s.strip(),
  12. headers=headers)
  13. title = xpath_text(config, './title', 'title', fatal=True).strip()
  14. video_id = xpath_text(config, './mediaid', default=video_id)
  15. thumbnail = xpath_text(config, ['./image', './thumb'])
  16. duration = float_or_none(xpath_text(config, './duration'))
  17. formats = []
  18. for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
  19. video_url = xpath_text(config, element_name)
  20. if video_url:
  21. formats.append({
  22. 'url': video_url,
  23. 'format_id': format_id,
  24. })
  25. self._check_formats(formats, video_id)
  26. return {
  27. 'id': video_id,
  28. 'title': title,
  29. 'thumbnail': thumbnail,
  30. 'duration': duration,
  31. 'formats': formats
  32. }