[options] add '--sleep-skip' option (#6582)
https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3677460485
This commit is contained in:
@@ -464,6 +464,18 @@ Description
|
|||||||
Number of seconds to sleep before each download.
|
Number of seconds to sleep before each download.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.*.sleep-skip
|
||||||
|
----------------------
|
||||||
|
Type
|
||||||
|
|Duration|_
|
||||||
|
Default
|
||||||
|
``0``
|
||||||
|
Description
|
||||||
|
Number of seconds to sleep after
|
||||||
|
`skipping <extractor.*.skip_>`__
|
||||||
|
a file download.
|
||||||
|
|
||||||
|
|
||||||
extractor.*.sleep-extractor
|
extractor.*.sleep-extractor
|
||||||
---------------------------
|
---------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
"metadata-version" : null,
|
"metadata-version" : null,
|
||||||
|
|
||||||
"sleep" : 0,
|
"sleep" : 0,
|
||||||
|
"sleep-skip" : 0,
|
||||||
"sleep-request" : 0,
|
"sleep-request" : 0,
|
||||||
"sleep-extractor": 0,
|
"sleep-extractor": 0,
|
||||||
"sleep-429" : 60.0,
|
"sleep-429" : 60.0,
|
||||||
|
|||||||
@@ -90,6 +90,8 @@
|
|||||||
--sleep SECONDS Number of seconds to wait before each download.
|
--sleep SECONDS Number of seconds to wait before each download.
|
||||||
This can be either a constant value or a range
|
This can be either a constant value or a range
|
||||||
(e.g. 2.7 or 2.0-3.5)
|
(e.g. 2.7 or 2.0-3.5)
|
||||||
|
--sleep-skip SECONDS Number of seconds to wait after skipping a file
|
||||||
|
download
|
||||||
--sleep-request SECONDS Number of seconds to wait between HTTP requests
|
--sleep-request SECONDS Number of seconds to wait between HTTP requests
|
||||||
during data extraction
|
during data extraction
|
||||||
--sleep-429 SECONDS Number of seconds to wait when receiving a '429
|
--sleep-429 SECONDS Number of seconds to wait when receiving a '429
|
||||||
|
|||||||
@@ -533,12 +533,15 @@ class DownloadJob(Job):
|
|||||||
callback(pathfmt)
|
callback(pathfmt)
|
||||||
self.out.skip(pathfmt.path)
|
self.out.skip(pathfmt.path)
|
||||||
|
|
||||||
if self._skipexc:
|
if self._skipexc is not None:
|
||||||
if self._skipftr is None or self._skipftr(pathfmt.kwdict):
|
if self._skipftr is None or self._skipftr(pathfmt.kwdict):
|
||||||
self._skipcnt += 1
|
self._skipcnt += 1
|
||||||
if self._skipcnt >= self._skipmax:
|
if self._skipcnt >= self._skipmax:
|
||||||
raise self._skipexc
|
raise self._skipexc
|
||||||
|
|
||||||
|
if self.sleep_skip is not None:
|
||||||
|
self.extractor.sleep(self.sleep_skip(), "skip")
|
||||||
|
|
||||||
def download(self, url):
|
def download(self, url):
|
||||||
"""Download 'url'"""
|
"""Download 'url'"""
|
||||||
if downloader := self.get_downloader(url[:url.find(":")]):
|
if downloader := self.get_downloader(url[:url.find(":")]):
|
||||||
@@ -582,6 +585,7 @@ class DownloadJob(Job):
|
|||||||
pathfmt.set_directory(kwdict)
|
pathfmt.set_directory(kwdict)
|
||||||
|
|
||||||
self.sleep = util.build_duration_func(cfg("sleep"))
|
self.sleep = util.build_duration_func(cfg("sleep"))
|
||||||
|
self.sleep_skip = util.build_duration_func(cfg("sleep-skip"))
|
||||||
self.fallback = cfg("fallback", True)
|
self.fallback = cfg("fallback", True)
|
||||||
if not cfg("download", True):
|
if not cfg("download", True):
|
||||||
# monkey-patch method to do nothing and always return True
|
# monkey-patch method to do nothing and always return True
|
||||||
|
|||||||
@@ -528,6 +528,11 @@ def build_parser():
|
|||||||
"This can be either a constant value or a range "
|
"This can be either a constant value or a range "
|
||||||
"(e.g. 2.7 or 2.0-3.5)"),
|
"(e.g. 2.7 or 2.0-3.5)"),
|
||||||
)
|
)
|
||||||
|
downloader.add_argument(
|
||||||
|
"--sleep-skip",
|
||||||
|
dest="sleep-skip", metavar="SECONDS", action=ConfigAction,
|
||||||
|
help=("Number of seconds to wait after skipping a file download"),
|
||||||
|
)
|
||||||
downloader.add_argument(
|
downloader.add_argument(
|
||||||
"--sleep-request",
|
"--sleep-request",
|
||||||
dest="sleep-request", metavar="SECONDS", action=ConfigAction,
|
dest="sleep-request", metavar="SECONDS", action=ConfigAction,
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
__version__ = "1.31.1"
|
__version__ = "1.31.2-dev"
|
||||||
__variant__ = None
|
__variant__ = None
|
||||||
|
|||||||
Reference in New Issue
Block a user