1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-23 00:54:31 +01:00
youtube-dl/youtube_dl/extractor/nuevo.py

40 lines
1.2 KiB
Python
Raw Normal View History

2016-10-02 13:39:18 +02:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
float_or_none,
xpath_text
)
class NuevoBaseIE(InfoExtractor):
2017-05-08 15:03:38 +02:00
def _extract_nuevo(self, config_url, video_id, headers={}):
config = self._download_xml(
2017-05-08 15:03:38 +02:00
config_url, video_id, transform_source=lambda s: s.strip(),
headers=headers)
title = xpath_text(config, './title', 'title', fatal=True).strip()
video_id = xpath_text(config, './mediaid', default=video_id)
2016-01-22 19:38:58 +01:00
thumbnail = xpath_text(config, ['./image', './thumb'])
duration = float_or_none(xpath_text(config, './duration'))
formats = []
for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
video_url = xpath_text(config, element_name)
if video_url:
formats.append({
'url': video_url,
'format_id': format_id,
})
self._check_formats(formats, video_id)
return {
'id': video_id,
'title': title,
'thumbnail': thumbnail,
'duration': duration,
'formats': formats
}