aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-01-23 12:05:01 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-01-23 12:05:01 +0100
commit5f0d813d9395848e92a1c6d83335360652d654c1 (patch)
tree4a7f8ec160f94293c9d5b30404b8cc8a56730e85
parent501f13fbf3d1f7225f91e3e0ad008df2cd3219f1 (diff)
parentca7a9c1bf7c57d1a5da9a24dd7618d95cb93102a (diff)
downloadyoutube-dl-5f0d813d9395848e92a1c6d83335360652d654c1.tar.xz
Merge remote-tracking branch 'rupertbaxter2/master'
Conflicts: youtube_dl/__init__.py youtube_dl/downloader/common.py
-rwxr-xr-xyoutube_dl/YoutubeDL.py1
-rw-r--r--youtube_dl/__init__.py7
-rw-r--r--youtube_dl/downloader/common.py6
-rw-r--r--youtube_dl/options.py4
4 files changed, 18 insertions, 0 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 8ef74e414..8f34b17b4 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -217,6 +217,7 @@ class YoutubeDL(object):
source_address: (Experimental) Client-side IP address to bind to.
call_home: Boolean, true iff we are allowed to contact the
youtube-dl servers for debugging.
+ sleep_interval: Number of seconds to sleep before each download.
The following parameters are not used by YoutubeDL itself, they are used by
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index ddf6260d1..ea1660452 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -132,6 +132,11 @@ def _real_main(argv=None):
if numeric_limit is None:
parser.error('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:
@@ -267,6 +272,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,
@@ -329,6 +335,7 @@ def _real_main(argv=None):
'fixup': opts.fixup,
'source_address': opts.source_address,
'call_home': opts.call_home,
+ 'sleep_interval': opts.sleep_interval,
}
with YoutubeDL(ydl_opts) as ydl:
diff --git a/youtube_dl/downloader/common.py b/youtube_dl/downloader/common.py
index de6b9311d..82c917d92 100644
--- a/youtube_dl/downloader/common.py
+++ b/youtube_dl/downloader/common.py
@@ -284,6 +284,7 @@ class FileDownloader(object):
"""Download to a filename using the info from info_dict
Return True on success and False otherwise
"""
+
nooverwrites_and_exists = (
self.params.get('nooverwrites', False)
and os.path.exists(encodeFilename(filename))
@@ -305,6 +306,11 @@ class FileDownloader(object):
})
return True
+ sleep_interval = self.params.get('sleep_interval')
+ if sleep_interval:
+ self.to_screen('[download] Sleeping %s seconds...' % sleep_interval)
+ time.sleep(sleep_interval)
+
return self.real_download(filename, info_dict)
def real_download(self, filename, info_dict):
diff --git a/youtube_dl/options.py b/youtube_dl/options.py
index fd7b400b2..12c9826f8 100644
--- a/youtube_dl/options.py
+++ b/youtube_dl/options.py
@@ -421,6 +421,10 @@ def parseOpts(overrideArguments=None):
'--bidi-workaround',
dest='bidi_workaround', action='store_true',
help='Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH')
+ workarounds.add_option(
+ '--sleep-interval', metavar='SECONDS',
+ dest='sleep_interval',
+ help='Number of seconds to sleep before each download.')
verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options')
verbosity.add_option(