aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/__init__.py8
-rw-r--r--youtube_dl/downloader/common.py4
2 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 962aedbff..6daed5365 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -354,6 +354,8 @@ def parseOpts(overrideArguments=None):
downloader.add_option('-r', '--rate-limit',
dest='ratelimit', metavar='LIMIT', help='maximum download rate in bytes per second (e.g. 50K or 4.2M)')
+ downloader.add_option('--sleep-interval',
+ dest='sleepinterval', metavar='SLEEPINTERVAL', help='number of seconds to sleep between downloads (default is %default)', default="0")
downloader.add_option('-R', '--retries',
dest='retries', metavar='RETRIES', help='number of retries (default is %default)', default=10)
downloader.add_option('--buffer-size',
@@ -674,6 +676,11 @@ def _real_main(argv=None):
if numeric_limit is None:
parser.error(u'invalid rate limit specified')
opts.ratelimit = numeric_limit
+ if opts.sleepinterval is not None:
+ try:
+ opts.sleepinterval = abs(int(opts.sleepinterval))
+ except ValueError:
+ parser.error(u'invalid sleep interval specified')
if opts.min_filesize is not None:
numeric_limit = FileDownloader.parse_bytes(opts.min_filesize)
if numeric_limit is None:
@@ -770,6 +777,7 @@ def _real_main(argv=None):
'restrictfilenames': opts.restrictfilenames,
'ignoreerrors': opts.ignoreerrors,
'ratelimit': opts.ratelimit,
+ 'sleepinterval': opts.sleepinterval,
'nooverwrites': opts.nooverwrites,
'retries': opts.retries,
'buffersize': opts.buffersize,
diff --git a/youtube_dl/downloader/common.py b/youtube_dl/downloader/common.py
index 9ce97f5fe..c1da065b5 100644
--- a/youtube_dl/downloader/common.py
+++ b/youtube_dl/downloader/common.py
@@ -278,6 +278,10 @@ class FileDownloader(object):
"""Download to a filename using the info from info_dict
Return True on success and False otherwise
"""
+ sleep_interval = self.params.get('sleepinterval', 0)
+ if sleep_interval > 0:
+ self.to_screen(u'[download] Sleeping %d seconds...' %sleep_interval)
+ time.sleep(sleep_interval)
# Check file already present
if self.params.get('continuedl', False) and os.path.isfile(encodeFilename(filename)) and not self.params.get('nopart', False):
self.report_file_already_downloaded(filename)