add '--list-extractors' argument
This commit is contained in:
@@ -24,9 +24,8 @@ def build_cmdline_parser():
|
|||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Download images from various sources')
|
description='Download images from various sources')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c", "--config",
|
"-g", "--get-urls", dest="list_urls", action="store_true",
|
||||||
metavar="CFG", dest="cfgfiles", action="append",
|
help="print download urls",
|
||||||
help="additional configuration files",
|
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-d", "--dest",
|
"-d", "--dest",
|
||||||
@@ -41,23 +40,28 @@ def build_cmdline_parser():
|
|||||||
"-p", "--password",
|
"-p", "--password",
|
||||||
metavar="PASS"
|
metavar="PASS"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-c", "--config",
|
||||||
|
metavar="CFG", dest="cfgfiles", action="append",
|
||||||
|
help="additional configuration files",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-o", "--option",
|
"-o", "--option",
|
||||||
metavar="OPT", action="append", default=[],
|
metavar="OPT", action="append", default=[],
|
||||||
help="additional 'key=value' option values",
|
help="additional 'key=value' option values",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-g", "--get-urls", dest="list_urls", action="store_true",
|
"--list-extractors", dest="list_extractors", action="store_true",
|
||||||
help="print download urls",
|
help="print a list of extractor classes with description and example URL",
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--list-modules", dest="list_modules", action="store_true",
|
|
||||||
help="print a list of available modules/supported sites",
|
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--list-keywords", dest="list_keywords", action="store_true",
|
"--list-keywords", dest="list_keywords", action="store_true",
|
||||||
help="print a list of available keywords for the given URLs",
|
help="print a list of available keywords for the given URLs",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--list-modules", dest="list_modules", action="store_true",
|
||||||
|
help="print a list of available modules/supported sites",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--version", action="version", version=__version__,
|
"--version", action="version", version=__version__,
|
||||||
help="print program version and exit"
|
help="print program version and exit"
|
||||||
@@ -103,6 +107,14 @@ def main():
|
|||||||
if args.list_modules:
|
if args.list_modules:
|
||||||
for module_name in extractor.modules:
|
for module_name in extractor.modules:
|
||||||
print(module_name)
|
print(module_name)
|
||||||
|
elif args.list_extractors:
|
||||||
|
for extr in extractor.extractors():
|
||||||
|
print(extr.__name__)
|
||||||
|
if extr.__doc__:
|
||||||
|
print(extr.__doc__)
|
||||||
|
if hasattr(extr, "test") and extr.test:
|
||||||
|
print("Example:", extr.test[0][0])
|
||||||
|
print()
|
||||||
else:
|
else:
|
||||||
if not args.urls:
|
if not args.urls:
|
||||||
parser.error("the following arguments are required: URL")
|
parser.error("the following arguments are required: URL")
|
||||||
|
|||||||
Reference in New Issue
Block a user