mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-13 20:57:14 +01:00
[core] Make --max-downloads ...
stop immediately on reaching the limit
Based on and closes #26638.
This commit is contained in:
parent
deee741fb1
commit
e6a836d54c
@ -1779,9 +1779,8 @@ class YoutubeDL(object):
|
|||||||
|
|
||||||
assert info_dict.get('_type', 'video') == 'video'
|
assert info_dict.get('_type', 'video') == 'video'
|
||||||
|
|
||||||
max_downloads = self.params.get('max_downloads')
|
max_downloads = int_or_none(self.params.get('max_downloads')) or float('inf')
|
||||||
if max_downloads is not None:
|
if self._num_downloads >= max_downloads:
|
||||||
if self._num_downloads >= int(max_downloads):
|
|
||||||
raise MaxDownloadsReached()
|
raise MaxDownloadsReached()
|
||||||
|
|
||||||
# TODO: backward compatibility, to be removed
|
# TODO: backward compatibility, to be removed
|
||||||
@ -2062,6 +2061,9 @@ class YoutubeDL(object):
|
|||||||
self.report_error('postprocessing: %s' % str(err))
|
self.report_error('postprocessing: %s' % str(err))
|
||||||
return
|
return
|
||||||
self.record_download_archive(info_dict)
|
self.record_download_archive(info_dict)
|
||||||
|
# avoid possible nugatory search for further items (PR #26638)
|
||||||
|
if self._num_downloads >= max_downloads:
|
||||||
|
raise MaxDownloadsReached()
|
||||||
|
|
||||||
def download(self, url_list):
|
def download(self, url_list):
|
||||||
"""Download a given list of URLs."""
|
"""Download a given list of URLs."""
|
||||||
|
Loading…
Reference in New Issue
Block a user