aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/downloader/common.py
diff options
context:
space:
mode:
authorsingh-pratyush96 <singh.pratyush96@gmail.com>2016-08-04 15:47:22 +0530
committerSergey M․ <dstftw@gmail.com>2016-08-09 03:32:42 +0700
commit065bc354894f1d35592529455d9eb685470124b9 (patch)
treeea4686d4649cac08f87a4980b4a8a645f431545a /youtube_dl/downloader/common.py
parent3a380766d1d6abd83213319b41cdf9a18977a69c (diff)
Add --max-sleep-interval (Closes #9930)
Diffstat (limited to 'youtube_dl/downloader/common.py')
-rw-r--r--youtube_dl/downloader/common.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/youtube_dl/downloader/common.py b/youtube_dl/downloader/common.py
index 1dba9f49a..8e377c72c 100644
--- a/youtube_dl/downloader/common.py
+++ b/youtube_dl/downloader/common.py
@@ -4,6 +4,7 @@ import os
import re
import sys
import time
+import random
from ..compat import compat_os_name
from ..utils import (
@@ -342,8 +343,10 @@ class FileDownloader(object):
})
return True
- sleep_interval = self.params.get('sleep_interval')
- if sleep_interval:
+ sleep_lower_bound = self.params.get('sleep_interval')
+ if sleep_lower_bound:
+ sleep_upper_bound = self.params.get('max_sleep_interval', sleep_lower_bound)
+ sleep_interval = random.uniform(sleep_lower_bound, sleep_upper_bound)
self.to_screen('[download] Sleeping %s seconds...' % sleep_interval)
time.sleep(sleep_interval)