]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/nuevo.py
[misc] Add `hatch`, `ruff`, `pre-commit` and improve dev docs (#7409)
[yt-dlp.git] / yt_dlp / extractor / nuevo.py
CommitLineData
d570746e 1from .common import InfoExtractor
e897bd82 2from ..utils import float_or_none, xpath_text
d570746e
AAA
3
4
5class NuevoBaseIE(InfoExtractor):
3d40084b 6 def _extract_nuevo(self, config_url, video_id, headers={}):
10677ece 7 config = self._download_xml(
3d40084b
S
8 config_url, video_id, transform_source=lambda s: s.strip(),
9 headers=headers)
d570746e 10
10677ece
S
11 title = xpath_text(config, './title', 'title', fatal=True).strip()
12 video_id = xpath_text(config, './mediaid', default=video_id)
ea178204 13 thumbnail = xpath_text(config, ['./image', './thumb'])
10677ece 14 duration = float_or_none(xpath_text(config, './duration'))
d570746e
AAA
15
16 formats = []
17 for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
10677ece
S
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)
d570746e
AAA
25
26 return {
27 'id': video_id,
28 'title': title,
29 'thumbnail': thumbnail,
30 'duration': duration,
31 'formats': formats
32 }