diff --git a/docs/options.md b/docs/options.md index 4f7a1caa..358dd6c4 100644 --- a/docs/options.md +++ b/docs/options.md @@ -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 diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 663fe994..7a9e0bee 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -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 "", diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 0189c0e5..b704e03f 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -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"), ) diff --git a/gallery_dl/util.py b/gallery_dl/util.py index ecb496db..df2ec5ab 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -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)