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.

38 lines
1.1 KiB

  1. # encoding: 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):
  10. config = self._download_xml(
  11. config_url, video_id, transform_source=lambda s: s.strip())
  12. title = xpath_text(config, './title', 'title', fatal=True).strip()
  13. video_id = xpath_text(config, './mediaid', default=video_id)
  14. thumbnail = xpath_text(config, ['./image', './thumb'])
  15. duration = float_or_none(xpath_text(config, './duration'))
  16. formats = []
  17. for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
  18. video_url = xpath_text(config, element_name)
  19. if video_url:
  20. formats.append({
  21. 'url': video_url,
  22. 'format_id': format_id,
  23. })
  24. self._check_formats(formats, video_id)
  25. return {
  26. 'id': video_id,
  27. 'title': title,
  28. 'thumbnail': thumbnail,
  29. 'duration': duration,
  30. 'formats': formats
  31. }