1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

update extractor blacklist to also allow classes

This commit is contained in:
Mike Fährmann 2018-01-14 18:47:22 +01:00
parent b6797032e3
commit f10ffc0839
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
4 changed files with 12 additions and 8 deletions

View File

@ -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)

View File

@ -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):

View File

@ -183,7 +183,7 @@ CODES = {
"zh": "Chinese",
}
SPECIAL_EXTRACTORS = ("oauth", "recursive", "test")
SPECIAL_EXTRACTORS = {"oauth", "recursive", "test"}
def build_predicate(predicates):

View File

@ -20,7 +20,7 @@ SKIP = {
# temporary issues
"batoto", # R.I.P.
"imgyt", # server maintenance
"luscious",
"gelbooru",
}