]> Raphaƫl G. Git Repositories - youtubedl/blobdiff - youtube_dl/downloader/common.py
debian/upstream/signing-key.asc: Add keys for both upstreams.
[youtubedl] / youtube_dl / downloader / common.py
index 1dba9f49a8b9b586b8428c6c7d65ca641de02c58..3dc144b4e19f208d4075d6423ce3278b3a614330 100644 (file)
@@ -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:
+        min_sleep_interval = self.params.get('sleep_interval')
+        if min_sleep_interval:
+            max_sleep_interval = self.params.get('max_sleep_interval', min_sleep_interval)
+            sleep_interval = random.uniform(min_sleep_interval, max_sleep_interval)
             self.to_screen('[download] Sleeping %s seconds...' % sleep_interval)
             time.sleep(sleep_interval)