From 10677ece81b7ed05bb84a0dbaf5bd237107eeb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Sat, 23 Jan 2016 00:04:33 +0600 Subject: [nuevo] Simplify nuevo extractors (Closes #7728) --- youtube_dl/extractor/nuevo.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'youtube_dl/extractor/nuevo.py') diff --git a/youtube_dl/extractor/nuevo.py b/youtube_dl/extractor/nuevo.py index ccc697e4f..225da033c 100644 --- a/youtube_dl/extractor/nuevo.py +++ b/youtube_dl/extractor/nuevo.py @@ -11,22 +11,23 @@ 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()) + config = self._download_xml( + config_url, video_id, transform_source=lambda s: s.strip()) - 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') + 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, -- cgit v1.2.3