Don't raise "requested format not available" when just dumping JSON

This commit is contained in:
Khang Nguyen 2017-07-22 22:45:49 +07:00
parent 327c8364f1
commit 34215326bf

View File

@ -1571,7 +1571,7 @@ class YoutubeDL(object):
} }
formats_to_download = list(format_selector(ctx)) 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', raise ExtractorError('requested format not available',
expected=True) expected=True)
@ -1583,7 +1583,8 @@ class YoutubeDL(object):
new_info.update(format) new_info.update(format)
self.process_info(new_info) self.process_info(new_info)
# We update the info dict with the best quality format (backwards compatibility) # 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 return info_dict
def process_subtitles(self, video_id, normal_subtitles, automatic_captions): def process_subtitles(self, video_id, normal_subtitles, automatic_captions):