]> jfr.im git - yt-dlp.git/commitdiff
Fix `--simulate --max-downloads`
authorpukkandan <redacted>
Fri, 20 May 2022 16:25:26 +0000 (21:55 +0530)
committerpukkandan <redacted>
Fri, 20 May 2022 17:43:31 +0000 (23:13 +0530)
Bug in c3e6ffba536980e5e1af00e0ecb2275621b4db17
Closes #3815

yt_dlp/YoutubeDL.py

index 3dc11463c372007c630e137998d3dd4e61b7f2d0..037b24d008a4c182427fb662c57967b317f3b3bf 100644 (file)
@@ -2877,8 +2877,13 @@ def process_info(self, info_dict):
         # Forced printings
         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'):
             info_dict['__write_download_archive'] = self.params.get('force_write_download_archive')
+            check_max_downloads()
             return
 
         if full_filename is None:
@@ -3221,10 +3226,7 @@ def ffmpeg_fixup(cndn, msg, cls):
 
         # Make sure the info_dict was modified in-place
         assert info_dict is original_infodict
-
-        max_downloads = self.params.get('max_downloads')
-        if max_downloads is not None and self._num_downloads >= int(max_downloads):
-            raise MaxDownloadsReached()
+        check_max_downloads()
 
     def __download_wrapper(self, func):
         @functools.wraps(func)