From 8a35863e869a4cfb64964598ea067e8f7309720c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 20 Jun 2025 16:32:48 +0200 Subject: [PATCH] [options] add '--Print' command-line option --- docs/options.md | 2 ++ gallery_dl/option.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/options.md b/docs/options.md index df7bb5bd..08a58d07 100644 --- a/docs/options.md +++ b/docs/options.md @@ -51,6 +51,8 @@ -N, --print [EVENT:]FORMAT Write FORMAT during EVENT (default 'prepare') to standard output. Examples: 'id' or 'post:{md5[:8]}' + --Print [EVENT:]FORMAT Like --print, but also sets --no-download, + --no-skip, and disables other output to stdout --print-to-file [EVENT:]FORMAT FILE Append FORMAT during EVENT to FILE --list-modules Print a list of available extractor modules diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 1dd1a148..297d44d9 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -156,7 +156,11 @@ class UgoiraAction(argparse.Action): class PrintAction(argparse.Action): def __call__(self, parser, namespace, value, option_string=None): if self.const: - filename = self.const + if self.const == "+": + namespace.options.append(((), "skip", False)) + namespace.options.append(((), "download", False)) + namespace.options.append((("output",), "mode", False)) + filename = "-" base = None mode = "w" else: @@ -397,6 +401,13 @@ def build_parser(): help=("Write FORMAT during EVENT (default 'prepare') to standard " "output. Examples: 'id' or 'post:{md5[:8]}'"), ) + output.add_argument( + "--Print", + dest="postprocessors", metavar="[EVENT:]FORMAT", + action=PrintAction, const="+", + help=("Like --print, but also sets --no-download, --no-skip, " + "and disables other output to stdout"), + ) output.add_argument( "--print-to-file", dest="postprocessors", metavar="[EVENT:]FORMAT FILE",