]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nuevo.py
New upstream version 2017.05.18.1
[youtubedl] / youtube_dl / extractor / nuevo.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6 from ..utils import (
7 float_or_none,
8 xpath_text
9 )
10
11
12 class NuevoBaseIE(InfoExtractor):
13 def _extract_nuevo(self, config_url, video_id, headers={}):
14 config = self._download_xml(
15 config_url, video_id, transform_source=lambda s: s.strip(),
16 headers=headers)
17
18 title = xpath_text(config, './title', 'title', fatal=True).strip()
19 video_id = xpath_text(config, './mediaid', default=video_id)
20 thumbnail = xpath_text(config, ['./image', './thumb'])
21 duration = float_or_none(xpath_text(config, './duration'))
22
23 formats = []
24 for element_name, format_id in (('file', 'sd'), ('filehd', 'hd')):
25 video_url = xpath_text(config, element_name)
26 if video_url:
27 formats.append({
28 'url': video_url,
29 'format_id': format_id,
30 })
31 self._check_formats(formats, video_id)
32
33 return {
34 'id': video_id,
35 'title': title,
36 'thumbnail': thumbnail,
37 'duration': duration,
38 'formats': formats
39 }