diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2015-04-30 23:33:49 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2015-04-30 23:33:49 +0800 |
commit | ffbc3901d276a4fafc9423c51dc2c6aa5d108d91 (patch) | |
tree | 5664b7378b212560710f76cc0c6ed2897787e7e1 /youtube_dl/YoutubeDL.py | |
parent | 482a1258de6af0a15b6e7859d244f9125cadef47 (diff) | |
parent | 7a03280df4555998fc99399907062b62383db2c4 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'youtube_dl/YoutubeDL.py')
-rwxr-xr-x | youtube_dl/YoutubeDL.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 827c88e0d..9d4a2dce8 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -914,15 +914,16 @@ class YoutubeDL(object): if not available_formats: return None - if format_spec == 'best' or format_spec is None: - return available_formats[-1] - elif format_spec == 'worst': + if format_spec in ['best', 'worst', None]: + format_idx = 0 if format_spec == 'worst' else -1 audiovideo_formats = [ f for f in available_formats if f.get('vcodec') != 'none' and f.get('acodec') != 'none'] if audiovideo_formats: - return audiovideo_formats[0] - return available_formats[0] + return audiovideo_formats[format_idx] + # for audio only urls, select the best/worst audio format + elif all(f.get('acodec') != 'none' for f in available_formats): + return available_formats[format_idx] elif format_spec == 'bestaudio': audio_formats = [ f for f in available_formats |