Skip to content

Commit

Permalink
Limit the "filtered" event to image-filter and chapter-filter...
Browse files Browse the repository at this point in the history
and not range/unique filters.
  • Loading branch information
WyohKnott committed Jan 4, 2025
1 parent f457615 commit 981b762
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions gallery_dl/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def dispatch(self, msg):
if self.pred_url(url, kwdict):
self.update_kwdict(kwdict)
self.handle_url(url, kwdict)
else:
if not self.pred_filter_url(url, kwdict):
if "filtered" in hooks:
for callback in hooks["filtered"]:
callback(pathfmt)
Expand All @@ -218,7 +218,7 @@ def dispatch(self, msg):
kwdict[self.metadata_url] = url
if self.pred_queue(url, kwdict):
self.handle_queue(url, kwdict)
else:
if not self.pred_filter_queue(url, kwdict):
if "filtered" in hooks:
for callback in hooks["filtered"]:
callback(pathfmt)
Expand Down Expand Up @@ -254,6 +254,23 @@ def _init(self):
self.extractor.initialize()
self.pred_url = self._prepare_predicates("image", True)
self.pred_queue = self._prepare_predicates("chapter", False)
self.pred_filter_url = self._prepare_filter_predicates("image", True)
self.pred_filter_queue = self._prepare_filter_predicates(
"chapter", False)

def _prepare_filter_predicates(self, target, skip=True):
predicates = []

pfilter = self.extractor.config(target + "-filter")
if pfilter:
try:
pred = util.FilterPredicate(pfilter, target)
except (SyntaxError, ValueError, TypeError) as exc:
self.extractor.log.warning(exc)
else:
predicates.append(pred)

return util.build_predicate(predicates)

def _prepare_predicates(self, target, skip=True):
predicates = []
Expand Down

0 comments on commit 981b762

Please sign in to comment.