mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 04:30:10 +09:00
Abort when --max-downloads is reached.
This commit is contained in:
parent
0b3f3e1ad9
commit
94fd3201b2
@ -317,6 +317,10 @@ class PostProcessingError(Exception):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class MaxDownloadsReached(Exception):
|
||||||
|
""" --max-downloads limit has been reached. """
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class UnavailableVideoError(Exception):
|
class UnavailableVideoError(Exception):
|
||||||
"""Unavailable Format exception.
|
"""Unavailable Format exception.
|
||||||
@ -730,8 +734,7 @@ class FileDownloader(object):
|
|||||||
max_downloads = self.params.get('max_downloads')
|
max_downloads = self.params.get('max_downloads')
|
||||||
if max_downloads is not None:
|
if max_downloads is not None:
|
||||||
if self._num_downloads > int(max_downloads):
|
if self._num_downloads > int(max_downloads):
|
||||||
self.to_screen(u'[download] Maximum number of downloads reached. Skipping ' + info_dict['title'])
|
raise MaxDownloadsReached()
|
||||||
return
|
|
||||||
|
|
||||||
filename = self.prepare_filename(info_dict)
|
filename = self.prepare_filename(info_dict)
|
||||||
|
|
||||||
@ -4447,7 +4450,12 @@ def _real_main():
|
|||||||
parser.error(u'you must provide at least one URL')
|
parser.error(u'you must provide at least one URL')
|
||||||
else:
|
else:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
retcode = fd.download(all_urls)
|
|
||||||
|
try:
|
||||||
|
retcode = fd.download(all_urls)
|
||||||
|
except MaxDownloadsReached:
|
||||||
|
fd.to_screen(u'--max-download limit reached, aborting.')
|
||||||
|
retcode = 101
|
||||||
|
|
||||||
# Dump cookie jar if requested
|
# Dump cookie jar if requested
|
||||||
if opts.cookiefile is not None:
|
if opts.cookiefile is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user