aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2011-12-08 20:59:02 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2011-12-08 20:59:02 +0100
commit94fd3201b237b2a1d04e06dd7fb5ea4130bddded (patch)
treeb73752dd89d8ebd73e1e514197172cc97cdebd0b /youtube_dl
parent0b3f3e1ad99bb9f3f41589a30cf81a696ddd9332 (diff)
Abort when --max-downloads is reached.
Diffstat (limited to 'youtube_dl')
-rwxr-xr-xyoutube_dl/__init__.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index fe0fe987e..ecc000fb8 100755
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -317,6 +317,10 @@ class PostProcessingError(Exception):
"""
pass
+class MaxDownloadsReached(Exception):
+ """ --max-downloads limit has been reached. """
+ pass
+
class UnavailableVideoError(Exception):
"""Unavailable Format exception.
@@ -730,8 +734,7 @@ class FileDownloader(object):
max_downloads = self.params.get('max_downloads')
if max_downloads is not None:
if self._num_downloads > int(max_downloads):
- self.to_screen(u'[download] Maximum number of downloads reached. Skipping ' + info_dict['title'])
- return
+ raise MaxDownloadsReached()
filename = self.prepare_filename(info_dict)
@@ -4447,7 +4450,12 @@ def _real_main():
parser.error(u'you must provide at least one URL')
else:
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
if opts.cookiefile is not None: