diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 3643a5c2..806b2292 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -122,7 +122,9 @@ def main(): if args.yamlfiles: config.load(args.yamlfiles, strict=True, fmt="yaml") if args.postprocessors: - config.set(("postprocessors", ), args.postprocessors) + config.set(("postprocessors",), args.postprocessors) + if args.abort: + config.set(("skip",), "abort:" + str(args.abort)) for key, value in args.options: config.set(key, value) diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 4b35098a..8877e080 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -11,6 +11,7 @@ import argparse import logging import json +import sys from . import job, version @@ -26,6 +27,14 @@ class ConfigConstAction(argparse.Action): namespace.options.append(((self.dest,), self.const)) +class DeprecatedConfigConstAction(argparse.Action): + """Set argparse const values as config values + deprecation warning""" + def __call__(self, parser, namespace, values, option_string=None): + print("warning: {} is deprecated. Use {} instead.".format( + "/".join(self.option_strings), self.choices), file=sys.stderr) + namespace.options.append(((self.dest,), self.const)) + + class ParseAction(argparse.Action): """Parse = options and set them as config values""" def __call__(self, parser, namespace, values, option_string=None): @@ -167,6 +176,13 @@ def build_parser(): dest="retries", metavar="RETRIES", type=int, action=ConfigAction, help="Number of retries (default: 5)", ) + downloader.add_argument( + "-A", "--abort", + dest="abort", metavar="N", type=int, + help=("Abort extractor run after N consecutive file downloads have " + "been skipped, e.g. if files with the same filename already " + "exist"), + ) downloader.add_argument( "--http-timeout", dest="timeout", metavar="SECONDS", type=float, action=ConfigAction, @@ -195,9 +211,9 @@ def build_parser(): ) downloader.add_argument( "--abort-on-skip", - dest="skip", nargs=0, action=ConfigConstAction, const="abort", - help=("Abort extractor run if a file download would normally be " - "skipped, i.e. if a file with the same filename already exists"), + action=DeprecatedConfigConstAction, + dest="skip", nargs=0, const="abort", choices="-A/--abort", + help=argparse.SUPPRESS, ) configuration = parser.add_argument_group("Configuration Options")