mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 20:22:36 +01:00
add 'skip-filter' option (#5255)
This commit is contained in:
parent
fd734b9222
commit
d2f50ecf09
@ -337,6 +337,15 @@ Description
|
||||
filename extension (``file.1.ext``, ``file.2.ext``, etc.)
|
||||
|
||||
|
||||
extractor.*.skip-filter
|
||||
-----------------------
|
||||
Type
|
||||
``string``
|
||||
Description
|
||||
Python expression controlling which skipped files to count towards
|
||||
``"abort"`` / ``"terminate"`` / ``"exit"``.
|
||||
|
||||
|
||||
extractor.*.sleep
|
||||
-----------------
|
||||
Type
|
||||
|
@ -468,9 +468,12 @@ class DownloadJob(Job):
|
||||
for callback in self.hooks["skip"]:
|
||||
callback(pathfmt)
|
||||
if self._skipexc:
|
||||
self._skipcnt += 1
|
||||
if self._skipcnt >= self._skipmax:
|
||||
raise self._skipexc()
|
||||
if not self._skipftr or self._skipftr(pathfmt.kwdict):
|
||||
self._skipcnt += 1
|
||||
if self._skipcnt >= self._skipmax:
|
||||
raise self._skipexc()
|
||||
else:
|
||||
self._skipcnt = 0
|
||||
|
||||
def download(self, url):
|
||||
"""Download 'url'"""
|
||||
@ -559,6 +562,12 @@ class DownloadJob(Job):
|
||||
elif skip == "exit":
|
||||
self._skipexc = SystemExit
|
||||
self._skipmax = text.parse_int(smax)
|
||||
|
||||
skip_filter = cfg("skip-filter")
|
||||
if skip_filter:
|
||||
self._skipftr = util.compile_expression(skip_filter)
|
||||
else:
|
||||
self._skipftr = None
|
||||
else:
|
||||
# monkey-patch methods to always return False
|
||||
pathfmt.exists = lambda x=None: False
|
||||
|
Loading…
Reference in New Issue
Block a user