2017-03-23 16:29:40 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2021-03-02 23:59:34 +01:00
|
|
|
# Copyright 2017-2021 Mike Fährmann
|
2017-03-23 16:29:40 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
|
|
|
|
"""Command line option parsing"""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import json
|
2019-06-29 23:46:55 +02:00
|
|
|
import sys
|
2019-05-10 22:05:57 +02:00
|
|
|
from . import job, version
|
2017-03-23 16:29:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ConfigAction(argparse.Action):
|
|
|
|
"""Set argparse results as config values"""
|
|
|
|
def __call__(self, parser, namespace, values, option_string=None):
|
2019-11-23 23:50:16 +01:00
|
|
|
namespace.options.append(((), self.dest, values))
|
2017-03-23 16:29:40 +01:00
|
|
|
|
|
|
|
|
2017-05-03 15:17:08 +02:00
|
|
|
class ConfigConstAction(argparse.Action):
|
|
|
|
"""Set argparse const values as config values"""
|
|
|
|
def __call__(self, parser, namespace, values, option_string=None):
|
2019-11-23 23:50:16 +01:00
|
|
|
namespace.options.append(((), self.dest, self.const))
|
2017-05-03 15:17:08 +02:00
|
|
|
|
|
|
|
|
2019-10-05 23:33:51 +02:00
|
|
|
class AppendCommandAction(argparse.Action):
|
|
|
|
def __call__(self, parser, namespace, values, option_string=None):
|
|
|
|
items = getattr(namespace, self.dest, None) or []
|
|
|
|
val = self.const.copy()
|
|
|
|
val["command"] = values
|
|
|
|
items.append(val)
|
|
|
|
setattr(namespace, self.dest, items)
|
|
|
|
|
|
|
|
|
2019-06-29 23:46:55 +02:00
|
|
|
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)
|
2019-11-23 23:50:16 +01:00
|
|
|
namespace.options.append(((), self.dest, self.const))
|
2019-06-29 23:46:55 +02:00
|
|
|
|
|
|
|
|
2017-03-23 16:29:40 +01:00
|
|
|
class ParseAction(argparse.Action):
|
|
|
|
"""Parse <key>=<value> options and set them as config values"""
|
|
|
|
def __call__(self, parser, namespace, values, option_string=None):
|
2018-01-27 01:05:17 +01:00
|
|
|
key, _, value = values.partition("=")
|
2017-03-23 16:29:40 +01:00
|
|
|
try:
|
2018-01-27 01:05:17 +01:00
|
|
|
value = json.loads(value)
|
2017-03-23 16:29:40 +01:00
|
|
|
except ValueError:
|
2018-01-27 01:05:17 +01:00
|
|
|
pass
|
2019-11-23 23:50:16 +01:00
|
|
|
key = key.split(".") # splitting an empty string becomes [""]
|
|
|
|
namespace.options.append((key[:-1], key[-1], value))
|
2017-03-23 16:29:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Formatter(argparse.HelpFormatter):
|
|
|
|
"""Custom HelpFormatter class to customize help output"""
|
|
|
|
def __init__(self, *args, **kwargs):
|
2017-03-23 16:51:42 +01:00
|
|
|
super().__init__(max_help_position=50, *args, **kwargs)
|
2017-03-23 16:29:40 +01:00
|
|
|
|
|
|
|
def _format_action_invocation(self, action):
|
|
|
|
opts = action.option_strings[:]
|
|
|
|
if opts:
|
|
|
|
if action.nargs != 0:
|
|
|
|
args_string = self._format_args(action, "ARG")
|
|
|
|
opts[-1] += " " + args_string
|
|
|
|
return ', '.join(opts)
|
|
|
|
else:
|
|
|
|
return self._metavar_formatter(action, action.dest)(1)[0]
|
|
|
|
|
|
|
|
|
|
|
|
def build_parser():
|
|
|
|
"""Build and configure an ArgumentParser object"""
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
usage="%(prog)s [OPTION]... URL...",
|
|
|
|
formatter_class=Formatter,
|
2017-08-16 19:56:50 +02:00
|
|
|
add_help=False,
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
|
|
|
general = parser.add_argument_group("General Options")
|
|
|
|
general.add_argument(
|
|
|
|
"-h", "--help",
|
|
|
|
action="help",
|
2017-09-30 18:52:23 +02:00
|
|
|
help="Print this help message and exit",
|
2017-08-16 19:56:50 +02:00
|
|
|
)
|
|
|
|
general.add_argument(
|
|
|
|
"--version",
|
2019-05-10 22:05:57 +02:00
|
|
|
action="version", version=version.__version__,
|
2017-08-16 19:56:50 +02:00
|
|
|
help="Print program version and exit",
|
|
|
|
)
|
|
|
|
general.add_argument(
|
2017-03-23 16:29:40 +01:00
|
|
|
"-d", "--dest",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="base-directory", metavar="DEST", action=ConfigAction,
|
2017-03-23 16:29:40 +01:00
|
|
|
help="Destination directory",
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
general.add_argument(
|
|
|
|
"-i", "--input-file",
|
2021-03-04 21:37:26 +01:00
|
|
|
dest="inputfiles", metavar="FILE", action="append",
|
|
|
|
help=("Download URLs found in FILE ('-' for stdin). "
|
|
|
|
"More than one --input-file can be specified"),
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
general.add_argument(
|
|
|
|
"--cookies",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="cookies", metavar="FILE", action=ConfigAction,
|
2017-08-16 19:56:50 +02:00
|
|
|
help="File to load additional cookies from",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2018-02-19 18:24:56 +01:00
|
|
|
general.add_argument(
|
|
|
|
"--proxy",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="proxy", metavar="URL", action=ConfigAction,
|
2018-02-19 18:24:56 +01:00
|
|
|
help="Use the specified proxy",
|
|
|
|
)
|
2019-04-25 21:30:16 +02:00
|
|
|
general.add_argument(
|
|
|
|
"--clear-cache",
|
2021-05-03 22:24:15 +02:00
|
|
|
dest="clear_cache", metavar="MODULE", nargs="?", const="all",
|
2019-04-25 21:30:16 +02:00
|
|
|
help="Delete all cached login sessions, cookies, etc.",
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
|
|
|
output = parser.add_argument_group("Output Options")
|
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"-q", "--quiet",
|
|
|
|
dest="loglevel", default=logging.INFO,
|
|
|
|
action="store_const", const=logging.ERROR,
|
2017-08-16 19:56:50 +02:00
|
|
|
help="Activate quiet mode",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"-v", "--verbose",
|
|
|
|
dest="loglevel",
|
|
|
|
action="store_const", const=logging.DEBUG,
|
2017-08-16 19:56:50 +02:00
|
|
|
help="Print various debugging information",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"-g", "--get-urls",
|
|
|
|
dest="list_urls", action="count",
|
2017-08-16 19:56:50 +02:00
|
|
|
help="Print URLs instead of downloading",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2021-01-07 18:10:54 +01:00
|
|
|
output.add_argument(
|
2021-01-26 01:01:22 +01:00
|
|
|
"-G", "--resolve-urls",
|
2021-01-07 18:10:54 +01:00
|
|
|
dest="list_urls", action="store_const", const=128,
|
2021-01-26 01:01:22 +01:00
|
|
|
help="Print URLs instead of downloading; resolve intermediary URLs",
|
2021-01-07 18:10:54 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"-j", "--dump-json",
|
|
|
|
dest="jobtype", action="store_const", const=job.DataJob,
|
2017-08-16 19:56:50 +02:00
|
|
|
help="Print JSON information",
|
2017-05-03 15:17:08 +02:00
|
|
|
)
|
2018-05-25 16:07:18 +02:00
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"-s", "--simulate",
|
|
|
|
dest="jobtype", action="store_const", const=job.SimulationJob,
|
2018-05-25 16:07:18 +02:00
|
|
|
help="Simulate data extraction; do not download anything",
|
|
|
|
)
|
2021-03-02 23:59:34 +01:00
|
|
|
output.add_argument(
|
|
|
|
"-E", "--extractor-info",
|
|
|
|
dest="jobtype", action="store_const", const=job.InfoJob,
|
|
|
|
help="Print extractor defaults and settings",
|
|
|
|
)
|
2017-09-09 18:48:28 +02:00
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"-K", "--list-keywords",
|
|
|
|
dest="jobtype", action="store_const", const=job.KeywordJob,
|
2017-09-30 18:52:23 +02:00
|
|
|
help=("Print a list of available keywords and example values "
|
|
|
|
"for the given URLs"),
|
2017-09-09 18:48:28 +02:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"--list-modules",
|
|
|
|
dest="list_modules", action="store_true",
|
2017-08-16 19:56:50 +02:00
|
|
|
help="Print a list of available extractor modules",
|
|
|
|
)
|
|
|
|
output.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"--list-extractors",
|
|
|
|
dest="list_extractors", action="store_true",
|
2017-08-16 19:56:50 +02:00
|
|
|
help=("Print a list of extractor classes "
|
|
|
|
"with description, (sub)category and example URL"),
|
|
|
|
)
|
2018-01-26 18:51:51 +01:00
|
|
|
output.add_argument(
|
|
|
|
"--write-log",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="logfile", metavar="FILE", action=ConfigAction,
|
2018-10-07 21:34:25 +02:00
|
|
|
help="Write logging output to FILE",
|
2018-01-26 18:51:51 +01:00
|
|
|
)
|
|
|
|
output.add_argument(
|
|
|
|
"--write-unsupported",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="unsupportedfile", metavar="FILE", action=ConfigAction,
|
2018-01-26 18:51:51 +01:00
|
|
|
help=("Write URLs, which get emitted by other extractors but cannot "
|
|
|
|
"be handled, to FILE"),
|
|
|
|
)
|
2020-05-12 14:25:21 +02:00
|
|
|
output.add_argument(
|
|
|
|
"--write-pages",
|
2020-05-12 20:40:25 +02:00
|
|
|
dest="write-pages", nargs=0, action=ConfigConstAction, const=True,
|
2020-05-12 14:25:21 +02:00
|
|
|
help=("Write downloaded intermediary pages to files "
|
|
|
|
"in the current directory to debug problems"),
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
|
|
|
downloader = parser.add_argument_group("Downloader Options")
|
2017-12-02 01:47:26 +01:00
|
|
|
downloader.add_argument(
|
|
|
|
"-r", "--limit-rate",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="rate", metavar="RATE", action=ConfigAction,
|
2017-12-02 01:47:26 +01:00
|
|
|
help="Maximum download rate (e.g. 500k or 2.5M)",
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
downloader.add_argument(
|
2017-03-23 16:29:40 +01:00
|
|
|
"-R", "--retries",
|
2019-06-30 22:55:31 +02:00
|
|
|
dest="retries", metavar="N", type=int, action=ConfigAction,
|
|
|
|
help=("Maximum number of retries for failed HTTP requests "
|
|
|
|
"or -1 for infinite retries (default: 4)"),
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2019-06-29 23:46:55 +02:00
|
|
|
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"),
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
downloader.add_argument(
|
2017-03-23 16:29:40 +01:00
|
|
|
"--http-timeout",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="timeout", metavar="SECONDS", type=float, action=ConfigAction,
|
2020-05-14 23:37:15 +02:00
|
|
|
help="Timeout for HTTP connections (default: 30.0)",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-12-04 17:06:17 +01:00
|
|
|
downloader.add_argument(
|
|
|
|
"--sleep",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="sleep", metavar="SECONDS", type=float, action=ConfigAction,
|
2017-12-04 17:06:17 +01:00
|
|
|
help="Number of seconds to sleep before each download",
|
|
|
|
)
|
2020-09-01 22:05:17 +02:00
|
|
|
downloader.add_argument(
|
|
|
|
"--filesize-min",
|
|
|
|
dest="filesize-min", metavar="SIZE", action=ConfigAction,
|
|
|
|
help="Do not download files smaller than SIZE (e.g. 500k or 2.5M)",
|
|
|
|
)
|
|
|
|
downloader.add_argument(
|
|
|
|
"--filesize-max",
|
|
|
|
dest="filesize-max", metavar="SIZE", action=ConfigAction,
|
|
|
|
help="Do not download files larger than SIZE (e.g. 500k or 2.5M)",
|
|
|
|
)
|
2017-10-24 23:33:44 +02:00
|
|
|
downloader.add_argument(
|
|
|
|
"--no-part",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="part", nargs=0, action=ConfigConstAction, const=False,
|
2017-10-24 23:33:44 +02:00
|
|
|
help="Do not use .part files",
|
|
|
|
)
|
2020-09-10 22:15:51 +02:00
|
|
|
downloader.add_argument(
|
|
|
|
"--no-skip",
|
|
|
|
dest="skip", nargs=0, action=ConfigConstAction, const=False,
|
|
|
|
help="Do not skip downloads; overwrite existing files",
|
|
|
|
)
|
2019-06-20 17:19:44 +02:00
|
|
|
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")
|
|
|
|
)
|
2019-07-13 21:49:26 +02:00
|
|
|
downloader.add_argument(
|
|
|
|
"--no-download",
|
|
|
|
dest="download", nargs=0, action=ConfigConstAction, const=False,
|
|
|
|
help=("Do not download any files")
|
|
|
|
)
|
2018-10-07 21:46:00 +02:00
|
|
|
downloader.add_argument(
|
|
|
|
"--no-check-certificate",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="verify", nargs=0, action=ConfigConstAction, const=False,
|
2018-10-07 21:46:00 +02:00
|
|
|
help="Disable HTTPS certificate validation",
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
|
|
|
configuration = parser.add_argument_group("Configuration Options")
|
|
|
|
configuration.add_argument(
|
2017-03-23 16:29:40 +01:00
|
|
|
"-c", "--config",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="cfgfiles", metavar="FILE", action="append",
|
2017-03-23 16:29:40 +01:00
|
|
|
help="Additional configuration files",
|
|
|
|
)
|
2019-05-10 22:05:57 +02:00
|
|
|
configuration.add_argument(
|
|
|
|
"--config-yaml",
|
|
|
|
dest="yamlfiles", metavar="FILE", action="append",
|
|
|
|
help=argparse.SUPPRESS,
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
configuration.add_argument(
|
2018-10-07 21:34:25 +02:00
|
|
|
"-o", "--option",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="options", metavar="OPT", action=ParseAction, default=[],
|
2018-10-07 21:34:25 +02:00
|
|
|
help="Additional '<key>=<value>' option values",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
configuration.add_argument(
|
2019-05-10 22:05:57 +02:00
|
|
|
"--ignore-config",
|
|
|
|
dest="load_config", action="store_false",
|
2017-04-25 17:09:10 +02:00
|
|
|
help="Do not read the default configuration files",
|
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
|
|
|
authentication = parser.add_argument_group("Authentication Options")
|
|
|
|
authentication.add_argument(
|
|
|
|
"-u", "--username",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="username", metavar="USER", action=ConfigAction,
|
|
|
|
help="Username to login with",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
authentication.add_argument(
|
|
|
|
"-p", "--password",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="password", metavar="PASS", action=ConfigAction,
|
|
|
|
help="Password belonging to the given username",
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
authentication.add_argument(
|
|
|
|
"--netrc",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="netrc", nargs=0, action=ConfigConstAction, const=True,
|
2017-12-05 23:29:11 +01:00
|
|
|
help="Enable .netrc authentication data",
|
2017-04-26 11:33:19 +02:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
|
|
|
selection = parser.add_argument_group("Selection Options")
|
2018-02-01 22:00:44 +01:00
|
|
|
selection.add_argument(
|
|
|
|
"--download-archive",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="archive", metavar="FILE", action=ConfigAction,
|
2018-02-01 22:00:44 +01:00
|
|
|
help=("Record all downloaded files in the archive file and "
|
2019-05-10 22:05:57 +02:00
|
|
|
"skip downloading any file already in it."),
|
2018-02-01 22:00:44 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
selection.add_argument(
|
2017-09-23 17:31:40 +02:00
|
|
|
"--range",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="image-range", metavar="RANGE", action=ConfigAction,
|
|
|
|
help=("Index-range(s) specifying which images to download. "
|
|
|
|
"For example '5-10' or '1,3-5,10-'"),
|
2017-04-18 11:38:48 +02:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
selection.add_argument(
|
2017-09-23 17:31:40 +02:00
|
|
|
"--chapter-range",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="chapter-range", metavar="RANGE", action=ConfigAction,
|
2018-10-07 21:34:25 +02:00
|
|
|
help=("Like '--range', but applies to manga-chapters "
|
2017-10-09 23:20:17 +02:00
|
|
|
"and other delegated URLs"),
|
2017-09-08 17:52:00 +02:00
|
|
|
)
|
|
|
|
selection.add_argument(
|
|
|
|
"--filter",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="image-filter", metavar="EXPR", action=ConfigAction,
|
2018-10-07 21:34:25 +02:00
|
|
|
help=("Python expression controlling which images to download. "
|
|
|
|
"Files for which the expression evaluates to False are ignored. "
|
2017-12-05 23:29:11 +01:00
|
|
|
"Available keys are the filename-specific ones listed by '-K'. "
|
|
|
|
"Example: --filter \"image_width >= 1000 and "
|
2017-09-08 17:52:00 +02:00
|
|
|
"rating in ('s', 'q')\""),
|
|
|
|
)
|
|
|
|
selection.add_argument(
|
|
|
|
"--chapter-filter",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="chapter-filter", metavar="EXPR", action=ConfigAction,
|
2018-10-07 21:34:25 +02:00
|
|
|
help=("Like '--filter', but applies to manga-chapters "
|
2017-10-09 23:20:17 +02:00
|
|
|
"and other delegated URLs"),
|
2017-09-23 17:31:40 +02:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
2018-06-18 18:14:38 +02:00
|
|
|
postprocessor = parser.add_argument_group("Post-processing Options")
|
|
|
|
postprocessor.add_argument(
|
|
|
|
"--zip",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="postprocessors",
|
2021-06-05 01:37:47 +02:00
|
|
|
action="append_const", const="zip",
|
2018-06-18 18:14:38 +02:00
|
|
|
help="Store downloaded files in a ZIP archive",
|
|
|
|
)
|
|
|
|
postprocessor.add_argument(
|
|
|
|
"--ugoira-conv",
|
2019-10-26 00:32:19 +02:00
|
|
|
dest="postprocessors", action="append_const", const={
|
|
|
|
"name" : "ugoira",
|
|
|
|
"ffmpeg-args" : ("-c:v", "libvpx", "-crf", "4", "-b:v", "5000k"),
|
|
|
|
"ffmpeg-twopass": True,
|
|
|
|
"whitelist" : ("pixiv", "danbooru"),
|
|
|
|
},
|
2018-06-18 19:22:54 +02:00
|
|
|
help="Convert Pixiv Ugoira to WebM (requires FFmpeg)",
|
2018-06-18 18:14:38 +02:00
|
|
|
)
|
2019-10-26 00:32:19 +02:00
|
|
|
postprocessor.add_argument(
|
|
|
|
"--ugoira-conv-lossless",
|
|
|
|
dest="postprocessors", action="append_const", const={
|
|
|
|
"name" : "ugoira",
|
|
|
|
"ffmpeg-args" : ("-c:v", "libvpx-vp9", "-lossless", "1",
|
|
|
|
"-pix_fmt", "yuv420p"),
|
|
|
|
"ffmpeg-twopass": False,
|
|
|
|
"whitelist" : ("pixiv", "danbooru"),
|
|
|
|
},
|
|
|
|
help="Convert Pixiv Ugoira to WebM in VP9 lossless mode",
|
|
|
|
)
|
2019-01-05 16:39:05 +01:00
|
|
|
postprocessor.add_argument(
|
|
|
|
"--write-metadata",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="postprocessors",
|
2021-06-05 01:37:47 +02:00
|
|
|
action="append_const", const="metadata",
|
2019-01-05 16:39:05 +01:00
|
|
|
help="Write metadata to separate JSON files",
|
|
|
|
)
|
2019-01-23 21:43:22 +01:00
|
|
|
postprocessor.add_argument(
|
|
|
|
"--write-tags",
|
2019-05-10 22:05:57 +02:00
|
|
|
dest="postprocessors",
|
|
|
|
action="append_const", const={"name": "metadata", "mode": "tags"},
|
2019-01-23 21:43:22 +01:00
|
|
|
help="Write image tags to separate text files",
|
|
|
|
)
|
2019-07-14 22:37:28 +02:00
|
|
|
postprocessor.add_argument(
|
|
|
|
"--mtime-from-date",
|
|
|
|
dest="postprocessors",
|
2021-06-05 01:37:47 +02:00
|
|
|
action="append_const", const="mtime",
|
2019-07-14 22:37:28 +02:00
|
|
|
help="Set file modification times according to 'date' metadata",
|
|
|
|
)
|
2019-11-27 19:42:46 +01:00
|
|
|
postprocessor.add_argument(
|
|
|
|
"--exec",
|
|
|
|
dest="postprocessors", metavar="CMD",
|
|
|
|
action=AppendCommandAction, const={"name": "exec"},
|
|
|
|
help=("Execute CMD for each downloaded file. "
|
|
|
|
"Example: --exec 'convert {} {}.png && rm {}'"),
|
|
|
|
)
|
|
|
|
postprocessor.add_argument(
|
|
|
|
"--exec-after",
|
|
|
|
dest="postprocessors", metavar="CMD",
|
2020-11-19 01:31:52 +01:00
|
|
|
action=AppendCommandAction, const={
|
|
|
|
"name": "exec", "event": "finalize"},
|
2019-11-27 19:42:46 +01:00
|
|
|
help=("Execute CMD after all files were downloaded successfully. "
|
|
|
|
"Example: --exec-after 'cd {} && convert * ../doc.pdf'"),
|
|
|
|
)
|
2018-06-18 18:14:38 +02:00
|
|
|
|
2017-03-23 16:29:40 +01:00
|
|
|
parser.add_argument(
|
|
|
|
"urls",
|
2019-05-10 22:05:57 +02:00
|
|
|
metavar="URL", nargs="*",
|
2017-08-16 19:56:50 +02:00
|
|
|
help=argparse.SUPPRESS,
|
2017-03-23 16:29:40 +01:00
|
|
|
)
|
2017-08-16 19:56:50 +02:00
|
|
|
|
2017-03-23 16:29:40 +01:00
|
|
|
return parser
|