From 3afd362e2e47dd852183906371d31db5d324ab6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 12 Sep 2020 21:04:47 +0200 Subject: [PATCH] add 'sleep-extractor' option (closes #964) (would have been nice if this were possible without code duplication) --- docs/configuration.rst | 10 ++++++++++ gallery_dl/job.py | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/docs/configuration.rst b/docs/configuration.rst index 668a774c..f19f7a96 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -208,6 +208,16 @@ Description Number of seconds to sleep before each download. =========== ===== +extractor.*.sleep-extractor +--------------------------- +=========== ===== +Type ``float`` +Default ``0`` +Description Number of seconds to sleep before handling an input URL, + i.e. before starting a new extractor. +=========== ===== + + extractor.*.username & .password -------------------------------- =========== ===== diff --git a/gallery_dl/job.py b/gallery_dl/job.py index c9f89319..8d1849ca 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -59,6 +59,9 @@ class Job(): def run(self): """Execute or run the job""" + sleep = self.extractor.config("sleep-extractor") + if sleep: + time.sleep(sleep) try: log = self.extractor.log for msg in self.extractor: @@ -586,6 +589,10 @@ class DataJob(Job): self.filter = (lambda x: x) if private else util.filter_dict def run(self): + sleep = self.extractor.config("sleep-extractor") + if sleep: + time.sleep(sleep) + # collect data try: for msg in self.extractor: