Fix --simulate --max-downloads

Bug in c3e6ffba53
Closes #3815
This commit is contained in:
pukkandan 2022-05-20 21:55:26 +05:30
parent 1a8cc83735
commit ca6d59d2c1
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39

View File

@ -2877,8 +2877,13 @@ def process_info(self, info_dict):
# Forced printings # Forced printings
self.__forced_printings(info_dict, full_filename, incomplete=('format' not in info_dict)) self.__forced_printings(info_dict, full_filename, incomplete=('format' not in info_dict))
def check_max_downloads():
if self._num_downloads >= float(self.params.get('max_downloads') or 'inf'):
raise MaxDownloadsReached()
if self.params.get('simulate'): if self.params.get('simulate'):
info_dict['__write_download_archive'] = self.params.get('force_write_download_archive') info_dict['__write_download_archive'] = self.params.get('force_write_download_archive')
check_max_downloads()
return return
if full_filename is None: if full_filename is None:
@ -3221,10 +3226,7 @@ def ffmpeg_fixup(cndn, msg, cls):
# Make sure the info_dict was modified in-place # Make sure the info_dict was modified in-place
assert info_dict is original_infodict assert info_dict is original_infodict
check_max_downloads()
max_downloads = self.params.get('max_downloads')
if max_downloads is not None and self._num_downloads >= int(max_downloads):
raise MaxDownloadsReached()
def __download_wrapper(self, func): def __download_wrapper(self, func):
@functools.wraps(func) @functools.wraps(func)