nuevo.py 1.1 KB

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