From bef0bd3b495156e5751f23cb51c8d735107b5540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 20 Apr 2024 21:00:26 +0200 Subject: [PATCH] add '--no-colors' command-line option --- docs/options.md | 5 +++-- gallery_dl/__init__.py | 5 +++++ gallery_dl/option.py | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/options.md b/docs/options.md index 45ce7eca..5b2de40b 100644 --- a/docs/options.md +++ b/docs/options.md @@ -29,6 +29,7 @@ ## Output Options: -q, --quiet Activate quiet mode + -w, --warning Print only warnings and errors -v, --verbose Print various debugging information -g, --get-urls Print URLs instead of downloading -G, --resolve-urls Print URLs instead of downloading; resolve @@ -48,12 +49,12 @@ extractors but cannot be handled, to FILE --write-pages Write downloaded intermediary pages to files in 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) -R, --retries N Maximum number of retries for failed HTTP - requests or -1 for infinite retries (default: - 4) + requests or -1 for infinite retries (default: 4) --http-timeout SECONDS Timeout for HTTP connections (default: 30.0) --sleep SECONDS Number of seconds to wait before each download. This can be either a constant value or a range diff --git a/gallery_dl/__init__.py b/gallery_dl/__init__.py index 01a51904..c9439f43 100644 --- a/gallery_dl/__init__.py +++ b/gallery_dl/__init__.py @@ -38,6 +38,11 @@ def main(): except ImportError: import toml config.load(args.configs_toml, strict=True, loads=toml.loads) + if not args.colors: + output.ANSI = False + config.set((), "colors", False) + if util.WINDOWS: + config.set(("output",), "ansi", False) if args.filename: filename = args.filename if filename == "/O": diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 9ede0622..95165c22 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -325,6 +325,11 @@ def build_parser(): help=("Write downloaded intermediary pages to files " "in the current directory to debug problems"), ) + output.add_argument( + "--no-colors", + dest="colors", action="store_false", + help=("Do not emit ANSI color codes in output"), + ) downloader = parser.add_argument_group("Downloader Options") downloader.add_argument(