diff options
Diffstat (limited to 'gallery_dl/option.py')
| -rw-r--r-- | gallery_dl/option.py | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/gallery_dl/option.py b/gallery_dl/option.py index f23b79d..af70fc8 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 <key>=<value> options and set them as config values""" def __call__(self, parser, namespace, values, option_string=None): @@ -164,8 +173,16 @@ def build_parser(): ) downloader.add_argument( "-R", "--retries", - dest="retries", metavar="RETRIES", type=int, action=ConfigAction, - help="Number of retries (default: 5)", + dest="retries", metavar="N", type=int, action=ConfigAction, + help=("Maximum number of retries for failed HTTP requests " + "or -1 for infinite retries (default: 4)"), + ) + 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", @@ -183,15 +200,26 @@ def build_parser(): help="Do not use .part files", ) downloader.add_argument( + "--no-mtime", + dest="mtime", nargs=0, action=ConfigConstAction, const=False, + help=("Do not set file modification times according to " + "Last-Modified HTTP response headers") + ) + downloader.add_argument( + "--no-download", + dest="download", nargs=0, action=ConfigConstAction, const=False, + help=("Do not download any files") + ) + downloader.add_argument( "--no-check-certificate", dest="verify", nargs=0, action=ConfigConstAction, const=False, help="Disable HTTPS certificate validation", ) 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") @@ -294,6 +322,12 @@ def build_parser(): action="append_const", const={"name": "metadata", "mode": "tags"}, help="Write image tags to separate text files", ) + postprocessor.add_argument( + "--mtime-from-date", + dest="postprocessors", + action="append_const", const={"name": "mtime"}, + help="Set file modification times according to 'date' metadata", + ) parser.add_argument( "urls", |
