1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

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

This commit is contained in:
Mike Fährmann 2024-08-30 18:22:46 +02:00
parent 17f5ba43a8
commit 60b655429f
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 36 additions and 3 deletions

View File

@ -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

View File

@ -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'."),
)