mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 12:12:34 +01:00
allow filtering '--list-extractors' results
with blacklist/whitelist syntax, e.g. --list-extractors pixiv --list-extractors pixiv:user pixiv:work --list-extractors :search
This commit is contained in:
parent
0db3c11ab0
commit
4da3347d18
@ -49,7 +49,8 @@
|
||||
values for the given URLs
|
||||
-e, --error-file FILE Add input URLs which returned an error to FILE
|
||||
--list-modules Print a list of available extractor modules
|
||||
--list-extractors Print a list of extractor classes with
|
||||
--list-extractors CATEGORIES
|
||||
Print a list of extractor classes with
|
||||
description, (sub)category and example URL
|
||||
--write-log FILE Write logging output to FILE
|
||||
--write-unsupported FILE Write URLs, which get emitted by other
|
||||
|
@ -202,12 +202,18 @@ def main():
|
||||
extractor.modules.append("")
|
||||
sys.stdout.write("\n".join(extractor.modules))
|
||||
|
||||
elif args.list_extractors:
|
||||
elif args.list_extractors is not None:
|
||||
write = sys.stdout.write
|
||||
fmt = ("{}{}\nCategory: {} - Subcategory: {}"
|
||||
"\nExample : {}\n\n").format
|
||||
|
||||
for extr in extractor.extractors():
|
||||
extractors = extractor.extractors()
|
||||
if args.list_extractors:
|
||||
fltr = util.build_extractor_filter(
|
||||
args.list_extractors, negate=False)
|
||||
extractors = filter(fltr, extractors)
|
||||
|
||||
for extr in extractors:
|
||||
write(fmt(
|
||||
extr.__name__,
|
||||
"\n" + extr.__doc__ if extr.__doc__ else "",
|
||||
|
@ -344,7 +344,7 @@ def build_parser():
|
||||
)
|
||||
output.add_argument(
|
||||
"--list-extractors",
|
||||
dest="list_extractors", action="store_true",
|
||||
dest="list_extractors", metavar="CATEGORIES", nargs="*",
|
||||
help=("Print a list of extractor classes "
|
||||
"with description, (sub)category and example URL"),
|
||||
)
|
||||
|
@ -760,8 +760,9 @@ def build_extractor_filter(categories, negate=True, special=None):
|
||||
if catsub:
|
||||
def test(extr):
|
||||
for category, subcategory in catsub:
|
||||
if category in (extr.category, extr.basecategory) and \
|
||||
subcategory == extr.subcategory:
|
||||
if subcategory == extr.subcategory and (
|
||||
category == extr.category or
|
||||
category == extr.basecategory):
|
||||
return not negate
|
||||
return negate
|
||||
tests.append(test)
|
||||
|
Loading…
Reference in New Issue
Block a user