aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/downloader/common.py
diff options
context:
space:
mode:
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)