nuevo.py 1018 B

12345678910111213141516171819202122232425262728293031323334353637
  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. tree = self._download_xml(config_url, video_id, transform_source=lambda s: s.strip())
  11. title = xpath_text(tree, './title')
  12. if title:
  13. title = title.strip()
  14. thumbnail = xpath_text(tree, './image')
  15. duration = float_or_none(xpath_text(tree, './duration'))
  16. formats = []
  17. for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
  18. video_url = tree.find(element_name)
  19. video_url is None or formats.append({
  20. 'format_id': format_id,
  21. 'url': video_url.text
  22. })
  23. return {
  24. 'id': video_id,
  25. 'title': title,
  26. 'thumbnail': thumbnail,
  27. 'duration': duration,
  28. 'formats': formats
  29. }