From bf5b0a1bfb3d875cb3ccd2fc834efd7343885bd2 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Thu, 26 Dec 2013 18:40:09 +0100 Subject: [PATCH] [ivi] Use centralized format sorting --- youtube_dl/extractor/ivi.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/ivi.py b/youtube_dl/extractor/ivi.py index 4bdf55f934..98d1d272a6 100644 --- a/youtube_dl/extractor/ivi.py +++ b/youtube_dl/extractor/ivi.py @@ -84,14 +84,16 @@ def _real_extract(self, url): result = video_json[u'result'] - formats = [{'url': x[u'url'], - 'format_id': x[u'content_format'] - } for x in result[u'files'] if x[u'content_format'] in self._known_formats] - formats.sort(key=lambda fmt: self._known_formats.index(fmt['format_id'])) + formats = [{ + 'url': x[u'url'], + 'format_id': x[u'content_format'], + 'preference': self._known_formats.index(x[u'content_format']), + } for x in result[u'files'] if x[u'content_format'] in self._known_formats] - if len(formats) == 0: - self._downloader.report_warning(u'No media links available for %s' % video_id) - return + self._sort_formats(formats) + + if not formats: + raise ExtractorError(u'No media links available for %s' % video_id) duration = result[u'duration'] compilation = result[u'compilation']