1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

Fix for '--max-downloads' to stop immediately when reaching the limit.

Currently, the specifying a limit with `--max-downloads` doesn't cause **youtube-dl** to stop right after it has successfully downloaded that number of files.

Instead, it keeps iterating the playlist until another candidate file is found to download, only to then discovers that the limit was previously met. This unnecessary activity can actually take quite a while when a large playlist is already mostly downloaded.

This fix adds an additional tail-check on the `_num_downloads` condition so that it terminates immediately after finishing the last eligible file.
This commit is contained in:
Glenn Slayden 2020-09-20 03:45:10 -07:00 committed by GitHub
parent b55715934b
commit eccee557b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2002,6 +2002,9 @@ class YoutubeDL(object):
self.report_error('postprocessing: %s' % str(err))
return
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."""