implement --list-modules cmd-line option
This commit is contained in:
@@ -37,29 +37,39 @@ def parse_cmdline_options():
|
|||||||
metavar="OPT", action="append", default=[],
|
metavar="OPT", action="append", default=[],
|
||||||
help="option value",
|
help="option value",
|
||||||
)
|
)
|
||||||
|
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="keywords", action="store_true",
|
"--list-keywords", dest="keywords", action="store_true",
|
||||||
help="print a list of available keywords",
|
help="print a list of available keywords",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"urls",
|
"urls",
|
||||||
nargs="+", metavar="URL",
|
nargs="*", metavar="URL",
|
||||||
help="url to download images from"
|
help="url to download images from"
|
||||||
)
|
)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
config.load()
|
|
||||||
args = parse_cmdline_options()
|
|
||||||
for opt in args.option:
|
|
||||||
try:
|
|
||||||
key, value = opt.split("=", 1)
|
|
||||||
config.set(key.split("."), value)
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
jobtype = jobs.KeywordJob if args.keywords else jobs.DownloadJob
|
|
||||||
try:
|
try:
|
||||||
for url in args.urls:
|
config.load()
|
||||||
jobtype(url).run()
|
args = parse_cmdline_options()
|
||||||
|
|
||||||
|
for opt in args.option:
|
||||||
|
try:
|
||||||
|
key, value = opt.split("=", 1)
|
||||||
|
config.set(key.split("."), value)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if args.list_modules:
|
||||||
|
for module_name in extractor.modules:
|
||||||
|
print(module_name)
|
||||||
|
else:
|
||||||
|
jobtype = jobs.KeywordJob if args.keywords else jobs.DownloadJob
|
||||||
|
for url in args.urls:
|
||||||
|
jobtype(url).run()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\nKeyboardInterrupt")
|
print("\nKeyboardInterrupt")
|
||||||
|
|||||||
Reference in New Issue
Block a user