[YoutubeIE] Sort formats by resolution
authorrzhxeo <rzhxeot7z81b4700@mailcatch.com>
Wed, 18 Dec 2013 20:22:37 +0000 (21:22 +0100)
committerrzhxeo <rzhxeot7z81b4700@mailcatch.com>
Wed, 18 Dec 2013 20:22:37 +0000 (21:22 +0100)
youtube_dl/extractor/youtube.py

index 793df4881db14d14bcdbfd94356862df8901aad5..58d27497002de5467ab08ebb9a2b0188177943e9 100644 (file)
@@ -1432,6 +1432,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
                 'height':      height,
                 'format_note': note,
             })
+        def _formats_key(f):
+            return (f.get('height') if f.get('height') is not None else -1,
+                    f.get('width') if f.get('width') is not None else -1)
+        formats = sorted(formats, key=_formats_key)
 
         return {
             'id':           video_id,