X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fnuevo.py;h=be1e09d3752376c5f64c7563090dbee730d25317;hb=HEAD;hp=ccc697e4f45a9a9abff64c6db980f25b53028434;hpb=d570746e45cff3c0f89654bf748e44a5da75a924;p=youtube-dl diff --git a/youtube_dl/extractor/nuevo.py b/youtube_dl/extractor/nuevo.py index ccc697e4f..be1e09d37 100644 --- a/youtube_dl/extractor/nuevo.py +++ b/youtube_dl/extractor/nuevo.py @@ -1,4 +1,4 @@ -# encoding: utf-8 +# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor @@ -10,23 +10,25 @@ from ..utils import ( class NuevoBaseIE(InfoExtractor): - def _extract_nuevo(self, config_url, video_id): - tree = self._download_xml(config_url, video_id, transform_source=lambda s: s.strip()) + def _extract_nuevo(self, config_url, video_id, headers={}): + config = self._download_xml( + config_url, video_id, transform_source=lambda s: s.strip(), + headers=headers) - title = xpath_text(tree, './title') - if title: - title = title.strip() - - thumbnail = xpath_text(tree, './image') - duration = float_or_none(xpath_text(tree, './duration')) + title = xpath_text(config, './title', 'title', fatal=True).strip() + video_id = xpath_text(config, './mediaid', default=video_id) + 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 = tree.find(element_name) - video_url is None or formats.append({ - 'format_id': format_id, - 'url': video_url.text - }) + 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,