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