add '--abort-on-skip' option and ability to control skip behavior
the 'skip' config option controls skipping behavior:
true - skip download if file already exist (default)
false - download and overwrite files even if it exists
"abort" - abort extractor run if a download would be skipped
(same as '--abort-on-skip')
This commit is contained in:
@@ -22,6 +22,12 @@ class ConfigAction(argparse.Action):
|
||||
namespace.options.append(((self.dest,), values))
|
||||
|
||||
|
||||
class ConfigConstAction(argparse.Action):
|
||||
"""Set argparse const values as config values"""
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
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):
|
||||
@@ -98,6 +104,12 @@ def build_parser():
|
||||
metavar="ITEM-SPEC", action=ConfigAction, dest="chapters",
|
||||
help=("Same as '--images' except for chapters")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--abort-on-skip",
|
||||
action=ConfigConstAction, nargs=0, dest="skip", 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")
|
||||
)
|
||||
parser.add_argument(
|
||||
"-R", "--retries",
|
||||
metavar="RETRIES", action=ConfigAction, dest="retries", type=int,
|
||||
@@ -105,7 +117,7 @@ def build_parser():
|
||||
)
|
||||
parser.add_argument(
|
||||
"--http-timeout",
|
||||
metavar="SECONDS", action=ConfigAction, dest="timeout", type=int,
|
||||
metavar="SECONDS", action=ConfigAction, dest="timeout", type=float,
|
||||
help="Timeout for HTTP connections (defaut: no timeout)",
|
||||
)
|
||||
parser.add_argument(
|
||||
|
||||
Reference in New Issue
Block a user