From e01d6aa4352ea76059f4dfcd06637311dc8a8389 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 10 Apr 2021 22:29:58 +0530 Subject: [PATCH] Fix `mergeall` when requested formats are unavailable --- yt_dlp/YoutubeDL.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 83acf4647..600ba6ee1 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1637,7 +1637,7 @@ class YoutubeDL(object): return [] elif selector.type == SINGLE: # atom - format_spec = (selector.selector if selector.selector is not None else 'best').lower() + format_spec = (selector.selector or 'best').lower() # TODO: Add allvideo, allaudio etc by generalizing the code with best/worst selector if format_spec == 'all': @@ -1649,6 +1649,8 @@ class YoutubeDL(object): elif format_spec == 'mergeall': def selector_function(ctx): formats = list(ctx['formats']) + if not formats: + return merged_format = formats[0] for f in formats[1:]: merged_format = _merge((merged_format, f))