nuevo.py 1.1 KB

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