From 34215326bf36e3e08b70717ed09a1ec244fdf178 Mon Sep 17 00:00:00 2001 From: Khang Nguyen Date: Sat, 22 Jul 2017 22:45:49 +0700 Subject: [PATCH] Don't raise "requested format not available" when just dumping JSON --- youtube_dl/YoutubeDL.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index f94836d06..064e0b5b3 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1571,7 +1571,7 @@ class YoutubeDL(object): } formats_to_download = list(format_selector(ctx)) - if not formats_to_download: + if download and not formats_to_download: raise ExtractorError('requested format not available', expected=True) @@ -1583,7 +1583,8 @@ class YoutubeDL(object): new_info.update(format) self.process_info(new_info) # We update the info dict with the best quality format (backwards compatibility) - info_dict.update(formats_to_download[-1]) + if formats_to_download: + info_dict.update(formats_to_download[-1]) return info_dict def process_subtitles(self, video_id, normal_subtitles, automatic_captions):