add '--rename' and '--rename-to' command-line options (#5846, #6044)

pull/5071/merge
Mike Fährmann 3 weeks ago
parent 17f5ba43a8
commit 60b655429f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -146,7 +146,12 @@
--mtime NAME Set file modification times according to
metadata selected by NAME. Examples: 'date' or
'status[date]'
--ugoira FORMAT Convert Pixiv Ugoira to FORMAT using FFmpeg.
--rename FORMAT Rename previously downloaded files from FORMAT
to the current filename format
--rename-to FORMAT Rename previously downloaded files from the
current filename format to FORMAT (disables
downloads)
--ugoira FMT Convert Pixiv Ugoira to FMT using FFmpeg.
Supported formats are 'webm', 'mp4', 'gif',
'vp8', 'vp9', 'vp9-lossless', 'copy'.
--exec CMD Execute CMD for each downloaded file. Supported

@ -74,6 +74,22 @@ class MtimeAction(argparse.Action):
})
class RenameAction(argparse.Action):
"""Configure rename post processors"""
def __call__(self, parser, namespace, value, option_string=None):
if self.const:
namespace.options.append(((), "download", False))
namespace.postprocessors.append({
"name": "rename",
"to" : value,
})
else:
namespace.postprocessors.append({
"name": "rename",
"from": value,
})
class UgoiraAction(argparse.Action):
"""Configure ugoira post processors"""
def __call__(self, parser, namespace, value, option_string=None):
@ -661,10 +677,22 @@ def build_parser():
const="date|status[date]",
help=argparse.SUPPRESS,
)
postprocessor.add_argument(
"--rename",
dest="postprocessors", metavar="FORMAT", action=RenameAction, const=0,
help=("Rename previously downloaded files from FORMAT "
"to the current filename format"),
)
postprocessor.add_argument(
"--rename-to",
dest="postprocessors", metavar="FORMAT", action=RenameAction, const=1,
help=("Rename previously downloaded files from the current filename "
"format to FORMAT (disables downloads)"),
)
postprocessor.add_argument(
"--ugoira",
dest="postprocessors", metavar="FORMAT", action=UgoiraAction,
help=("Convert Pixiv Ugoira to FORMAT using FFmpeg. "
dest="postprocessors", metavar="FMT", action=UgoiraAction,
help=("Convert Pixiv Ugoira to FMT using FFmpeg. "
"Supported formats are 'webm', 'mp4', 'gif', "
"'vp8', 'vp9', 'vp9-lossless', 'copy'."),
)

Loading…
Cancel
Save