diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index 784313a2..13ed78c9 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -98,7 +98,7 @@ def find(url): """Find suitable extractor for the given url""" for pattern, klass in _list_patterns(): match = pattern.match(url) - if match and klass.category not in _blacklist: + if match and klass not in _blacklist: return klass(match) return None @@ -113,11 +113,15 @@ def extractors(): class blacklist(): """Context Manager to blacklist extractor modules""" - def __init__(self, categories): - self.categories = categories + def __init__(self, categories, extractors=None): + self.extractors = extractors or [] + for _, klass in _list_patterns(): + if klass.category in categories: + self.extractors.append(klass) + print(self.extractors) def __enter__(self): - _blacklist.extend(self.categories) + _blacklist.update(self.extractors) def __exit__(self, etype, value, traceback): _blacklist.clear() @@ -127,7 +131,7 @@ class blacklist(): # internals _cache = [] -_blacklist = [] +_blacklist = set() _module_iter = iter(modules) diff --git a/gallery_dl/extractor/recursive.py b/gallery_dl/extractor/recursive.py index 4b1b404b..f3e61ca0 100644 --- a/gallery_dl/extractor/recursive.py +++ b/gallery_dl/extractor/recursive.py @@ -28,7 +28,7 @@ class RecursiveExtractor(Extractor): def items(self): blist = self.config( - "blacklist", ("directlink",) + util.SPECIAL_EXTRACTORS) + "blacklist", {"directlink"} | util.SPECIAL_EXTRACTORS) page = self.request(self.url).text yield Message.Version, 1 with extractor.blacklist(blist): diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 6d7aea42..de2af227 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -183,7 +183,7 @@ CODES = { "zh": "Chinese", } -SPECIAL_EXTRACTORS = ("oauth", "recursive", "test") +SPECIAL_EXTRACTORS = {"oauth", "recursive", "test"} def build_predicate(predicates): diff --git a/test/test_extractors.py b/test/test_extractors.py index a16baf85..3b49a562 100644 --- a/test/test_extractors.py +++ b/test/test_extractors.py @@ -20,7 +20,7 @@ SKIP = { # temporary issues "batoto", # R.I.P. "imgyt", # server maintenance - "luscious", + "gelbooru", }