]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/nuevo.py
[nbc] remove unused imports and extract permalink from modified urls
[yt-dlp.git] / youtube_dl / extractor / nuevo.py
CommitLineData
dcdb292f 1# coding: utf-8
d570746e
AAA
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5
6from ..utils import (
7 float_or_none,
8 xpath_text
9)
10
11
12class NuevoBaseIE(InfoExtractor):
13 def _extract_nuevo(self, config_url, video_id):
10677ece
S
14 config = self._download_xml(
15 config_url, video_id, transform_source=lambda s: s.strip())
d570746e 16
10677ece
S
17 title = xpath_text(config, './title', 'title', fatal=True).strip()
18 video_id = xpath_text(config, './mediaid', default=video_id)
ea178204 19 thumbnail = xpath_text(config, ['./image', './thumb'])
10677ece 20 duration = float_or_none(xpath_text(config, './duration'))
d570746e
AAA
21
22 formats = []
23 for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
10677ece
S
24 video_url = xpath_text(config, element_name)
25 if video_url:
26 formats.append({
27 'url': video_url,
28 'format_id': format_id,
29 })
30 self._check_formats(formats, video_id)
d570746e
AAA
31
32 return {
33 'id': video_id,
34 'title': title,
35 'thumbnail': thumbnail,
36 'duration': duration,
37 'formats': formats
38 }