From 76385f5f188782502be790dc92391083375087df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 15 Jun 2024 23:29:09 +0200 Subject: [PATCH] re-categorize some command-line options in --help --- docs/options.md | 37 ++++++----- gallery_dl/option.py | 147 ++++++++++++++++++++++--------------------- 2 files changed, 97 insertions(+), 87 deletions(-) diff --git a/docs/options.md b/docs/options.md index c356926c..77c81ed0 100644 --- a/docs/options.md +++ b/docs/options.md @@ -6,20 +6,21 @@ ## General Options: -h, --help Print this help message and exit --version Print program version and exit - -U, --update Update to the latest version - --update-to [CHANNEL@]TAG Upgrade/downgrade to a specific version - --update-check Check if a newer version is available -f, --filename FORMAT Filename format string for downloaded files ('/O' for "original" filenames) -d, --destination PATH Target location for file downloads -D, --directory PATH Exact location for file downloads -X, --extractors PATH Load external extractors from PATH - --proxy URL Use the specified proxy - --source-address IP Client-side IP address to bind to --user-agent UA User-Agent request header --clear-cache MODULE Delete cached login sessions, cookies, etc. for MODULE (ALL to delete everything) +## Update Options: + -U, --update Update to the latest version + --update-to CHANNEL[@TAG] Switch to a dfferent release channel (stable or + dev) or upgrade/downgrade to a specific version + --update-check Check if a newer version is available + ## Input Options: -i, --input-file FILE Download URLs found in FILE ('-' for stdin). More than one --input-file can be specified @@ -54,11 +55,17 @@ the current directory to debug problems --no-colors Do not emit ANSI color codes in output -## Downloader Options: - -r, --limit-rate RATE Maximum download rate (e.g. 500k or 2.5M) +## Networking Options: -R, --retries N Maximum number of retries for failed HTTP requests or -1 for infinite retries (default: 4) --http-timeout SECONDS Timeout for HTTP connections (default: 30.0) + --proxy URL Use the specified proxy + --source-address IP Client-side IP address to bind to + --no-check-certificate Disable HTTPS certificate validation + +## Downloader Options: + -r, --limit-rate RATE Maximum download rate (e.g. 500k or 2.5M) + --chunk-size SIZE Size of in-memory data chunks (default: 32k) --sleep SECONDS Number of seconds to wait before each download. This can be either a constant value or a range (e.g. 2.7 or 2.0-3.5) @@ -66,18 +73,11 @@ during data extraction --sleep-extractor SECONDS Number of seconds to wait before starting data extraction for an input URL - --filesize-min SIZE Do not download files smaller than SIZE (e.g. - 500k or 2.5M) - --filesize-max SIZE Do not download files larger than SIZE (e.g. - 500k or 2.5M) - --chunk-size SIZE Size of in-memory data chunks (default: 32k) --no-part Do not use .part files --no-skip Do not skip downloads; overwrite existing files --no-mtime Do not set file modification times according to Last-Modified HTTP response headers --no-download Do not download any files - --no-postprocessors Do not run any post processors - --no-check-certificate Disable HTTPS certificate validation ## Configuration Options: -o, --option KEY=VALUE Additional options. Example: -o browser=firefox @@ -105,12 +105,16 @@ container) ## Selection Options: - --download-archive FILE Record all downloaded or skipped files in FILE - and skip downloading any file already in it -A, --abort N Stop current extractor run after N consecutive file downloads were skipped -T, --terminate N Stop current and parent extractor runs after N consecutive file downloads were skipped + --filesize-min SIZE Do not download files smaller than SIZE (e.g. + 500k or 2.5M) + --filesize-max SIZE Do not download files larger than SIZE (e.g. + 500k or 2.5M) + --download-archive FILE Record all downloaded or skipped files in FILE + and skip downloading any file already in it --range RANGE Index range(s) specifying which files to download. These can be either a constant value, range, or slice (e.g. '5', '8-20', or '1:24:3') @@ -127,6 +131,7 @@ ## Post-processing Options: -P, --postprocessor NAME Activate the specified post processor + --no-postprocessors Do not run any post processors -O, --postprocessor-option KEY=VALUE Additional post processor options --write-metadata Write metadata to separate JSON files diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 2165b25b..387a0678 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -173,28 +173,6 @@ def build_parser(): action="version", version=version.__version__, help="Print program version and exit", ) - if util.EXECUTABLE: - general.add_argument( - "-U", "--update", - dest="update", action="store_const", const="latest", - help="Update to the latest version", - ) - general.add_argument( - "--update-to", - dest="update", metavar="[CHANNEL@]TAG", - help="Upgrade/downgrade to a specific version", - ) - general.add_argument( - "--update-check", - dest="update", action="store_const", const="check", - help="Check if a newer version is available", - ) - else: - general.add_argument( - "-U", "--update-check", - dest="update", action="store_const", const="check", - help="Check if a newer version is available", - ) general.add_argument( "-f", "--filename", dest="filename", metavar="FORMAT", @@ -216,16 +194,6 @@ def build_parser(): dest="extractor_sources", metavar="PATH", action="append", help="Load external extractors from PATH", ) - general.add_argument( - "--proxy", - dest="proxy", metavar="URL", action=ConfigAction, - help="Use the specified proxy", - ) - general.add_argument( - "--source-address", - dest="source-address", metavar="IP", action=ConfigAction, - help="Client-side IP address to bind to", - ) general.add_argument( "--user-agent", dest="user-agent", metavar="UA", action=ConfigAction, @@ -238,6 +206,31 @@ def build_parser(): "(ALL to delete everything)", ) + update = parser.add_argument_group("Update Options") + if util.EXECUTABLE or 1: + update.add_argument( + "-U", "--update", + dest="update", action="store_const", const="latest", + help="Update to the latest version", + ) + update.add_argument( + "--update-to", + dest="update", metavar="CHANNEL[@TAG]", + help=("Switch to a dfferent release channel (stable or dev) " + "or upgrade/downgrade to a specific version"), + ) + update.add_argument( + "--update-check", + dest="update", action="store_const", const="check", + help="Check if a newer version is available", + ) + else: + update.add_argument( + "-U", "--update-check", + dest="update", action="store_const", const="check", + help="Check if a newer version is available", + ) + input = parser.add_argument_group("Input Options") input.add_argument( "urls", @@ -353,23 +346,45 @@ def build_parser(): help=("Do not emit ANSI color codes in output"), ) - downloader = parser.add_argument_group("Downloader Options") - downloader.add_argument( - "-r", "--limit-rate", - dest="rate", metavar="RATE", action=ConfigAction, - help="Maximum download rate (e.g. 500k or 2.5M)", - ) - downloader.add_argument( + networking = parser.add_argument_group("Networking Options") + networking.add_argument( "-R", "--retries", 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( + networking.add_argument( "--http-timeout", dest="timeout", metavar="SECONDS", type=float, action=ConfigAction, help="Timeout for HTTP connections (default: 30.0)", ) + networking.add_argument( + "--proxy", + dest="proxy", metavar="URL", action=ConfigAction, + help="Use the specified proxy", + ) + networking.add_argument( + "--source-address", + dest="source-address", metavar="IP", action=ConfigAction, + help="Client-side IP address to bind to", + ) + networking.add_argument( + "--no-check-certificate", + dest="verify", nargs=0, action=ConfigConstAction, const=False, + help="Disable HTTPS certificate validation", + ) + + downloader = parser.add_argument_group("Downloader Options") + downloader.add_argument( + "-r", "--limit-rate", + dest="rate", metavar="RATE", action=ConfigAction, + help="Maximum download rate (e.g. 500k or 2.5M)", + ) + downloader.add_argument( + "--chunk-size", + dest="chunk-size", metavar="SIZE", action=ConfigAction, + help="Size of in-memory data chunks (default: 32k)", + ) downloader.add_argument( "--sleep", dest="sleep", metavar="SECONDS", action=ConfigAction, @@ -389,21 +404,6 @@ def build_parser(): help=("Number of seconds to wait before starting data extraction " "for an input URL"), ) - 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)", - ) - downloader.add_argument( - "--chunk-size", - dest="chunk-size", metavar="SIZE", action=ConfigAction, - help="Size of in-memory data chunks (default: 32k)", - ) downloader.add_argument( "--no-part", dest="part", nargs=0, action=ConfigConstAction, const=False, @@ -425,16 +425,6 @@ def build_parser(): dest="download", nargs=0, action=ConfigConstAction, const=False, help=("Do not download any files") ) - downloader.add_argument( - "--no-postprocessors", - dest="postprocess", nargs=0, action=ConfigConstAction, const=False, - help=("Do not run any post processors") - ) - downloader.add_argument( - "--no-check-certificate", - dest="verify", nargs=0, action=ConfigConstAction, const=False, - help="Disable HTTPS certificate validation", - ) configuration = parser.add_argument_group("Configuration Options") configuration.add_argument( @@ -525,12 +515,6 @@ def build_parser(): ) selection = parser.add_argument_group("Selection Options") - selection.add_argument( - "--download-archive", - dest="archive", metavar="FILE", action=ConfigAction, - help=("Record all downloaded or skipped files in FILE and " - "skip downloading any file already in it"), - ) selection.add_argument( "-A", "--abort", dest="abort", metavar="N", type=int, @@ -543,6 +527,22 @@ def build_parser(): help=("Stop current and parent extractor runs " "after N consecutive file downloads were skipped"), ) + selection.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)", + ) + selection.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)", + ) + selection.add_argument( + "--download-archive", + dest="archive", metavar="FILE", action=ConfigAction, + help=("Record all downloaded or skipped files in FILE and " + "skip downloading any file already in it"), + ) selection.add_argument( "--range", dest="image-range", metavar="RANGE", action=ConfigAction, @@ -583,6 +583,11 @@ def build_parser(): dest="postprocessors", metavar="NAME", action="append", default=[], help="Activate the specified post processor", ) + postprocessor.add_argument( + "--no-postprocessors", + dest="postprocess", nargs=0, action=ConfigConstAction, const=False, + help=("Do not run any post processors") + ) postprocessor.add_argument( "-O", "--postprocessor-option", dest="options_pp", metavar="KEY=VALUE",