From c3e6ffba536980e5e1af00e0ecb2275621b4db17 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 9 Jan 2021 17:38:12 +0530 Subject: [PATCH] Stop immediately when reaching '--max-downloads' (https://github.com/ytdl-org/youtube-dl/pull/26638) Authored by: glenn-slayden --- youtube_dlc/YoutubeDL.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/youtube_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py index 3bae07764..2ecb137fc 100644 --- a/youtube_dlc/YoutubeDL.py +++ b/youtube_dlc/YoutubeDL.py @@ -2220,6 +2220,9 @@ class YoutubeDL(object): if must_record_download_archive or self.params.get('force_write_download_archive', False): self.record_download_archive(info_dict) + max_downloads = self.params.get('max_downloads') + if max_downloads is not None and self._num_downloads >= int(max_downloads): + raise MaxDownloadsReached() def download(self, url_list): """Download a given list of URLs."""