[spiegel] Use centralized sorting
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 24 Dec 2013 11:40:23 +0000 (12:40 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 24 Dec 2013 11:40:23 +0000 (12:40 +0100)
youtube_dl/extractor/common.py
youtube_dl/extractor/spiegel.py

index 280693d1d83312a00da78fa0852fd1a6cfa6be3a..0a90382de116bdffdb88edfc0ebe1a38fb758dd6 100644 (file)
@@ -438,6 +438,11 @@ class InfoExtractor(object):
 
     def _sort_formats(self, formats):
         def _formats_key(f):
+            # TODO remove the following workaround
+            from ..utils import determine_ext
+            if not f.get('ext') and 'url' in f:
+                f['ext'] = determine_ext(f['url'])
+
             preference = f.get('preference')
             if preference is None:
                 preference = 0 if f.get('url', '').startswith('http') else -0.1
index 6955205242dcbbba01cfac482d362b3ca292b6b6..051a34d5b8b048db9112ac2df5f3f04115447a87 100644 (file)
@@ -51,9 +51,10 @@ class SpiegelIE(InfoExtractor):
             # Blacklist type 6, it's extremely LQ and not available on the same server
             if n.tag.startswith('type') and n.tag != 'type6'
         ]
-        formats.sort(key=lambda f: f['vbr'])
         duration = float(idoc[0].findall('./duration')[0].text)
 
+        self._sort_formats(formats)
+
         info = {
             'id': video_id,
             'title': video_title,