From: rzhxeo Date: Wed, 18 Dec 2013 20:22:37 +0000 (+0100) Subject: [YoutubeIE] Sort formats by resolution X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=e56f22ae203d10ab6d3715bc2dc1c9b927294e50;p=youtube-dl [YoutubeIE] Sort formats by resolution --- diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 793df4881..58d274970 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -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,