From 9903d36ca61fe3a76a4a9e7d6b94a3a77ee3864b Mon Sep 17 00:00:00 2001 From: shan3k Date: Fri, 1 Jul 2016 22:14:49 +0100 Subject: [PATCH] Added random number generation for sleep-interval --- youtube_dl/YoutubeDL.py | 3 ++- youtube_dl/downloader/common.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 5036289b0..96e59a4c9 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -248,7 +248,8 @@ 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. + sleep_interval: A random number of seconds to sleep before each download. + The script will choose a random number below sleep_interval. listformats: Print an overview of available video formats and exit. list_thumbnails: Print a table of all thumbnails and exit. match_filter: A function that gets called with the info_dict of diff --git a/youtube_dl/downloader/common.py b/youtube_dl/downloader/common.py index 1dba9f49a..9dcb103b7 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,7 +343,7 @@ class FileDownloader(object): }) return True - sleep_interval = self.params.get('sleep_interval') + sleep_interval = random.randrange(self.params.get('sleep_interval')) if sleep_interval: self.to_screen('[download] Sleeping %s seconds...' % sleep_interval) time.sleep(sleep_interval)