|
1 |
| -import argparse, os, re, tempfile |
| 1 | +import argparse, os, re, shlex, tempfile |
2 | 2 | from collections import defaultdict
|
3 | 3 | from concurrent.futures import ThreadPoolExecutor
|
4 | 4 | from copy import deepcopy
|
|
10 | 10 | from xklb import db_media, usage
|
11 | 11 | from xklb.media import media_printer
|
12 | 12 | from xklb.scripts import sample_compare, sample_hash
|
13 |
| -from xklb.utils import consts, db_utils, devices, file_utils, iterables, objects, strings |
| 13 | +from xklb.utils import consts, db_utils, devices, file_utils, iterables, objects, processes, strings |
14 | 14 | from xklb.utils.consts import DBType
|
15 | 15 | from xklb.utils.log_utils import log
|
16 | 16 |
|
@@ -82,6 +82,7 @@ def parse_args() -> argparse.Namespace:
|
82 | 82 | profile.set_defaults(profile="audio")
|
83 | 83 |
|
84 | 84 | parser.add_argument("--only-soft-delete", action="store_true")
|
| 85 | + parser.add_argument("--dedupe-cmd", help=argparse.SUPPRESS) |
85 | 86 | parser.add_argument("--force", "-f", action="store_true")
|
86 | 87 | parser.add_argument("--limit", "-L", "-l", "-queue", "--queue", default=100)
|
87 | 88 | parser.add_argument("--include", "-s", "--search", nargs="+", action="extend", default=[], help=argparse.SUPPRESS)
|
@@ -553,7 +554,12 @@ def dedupe_media() -> None:
|
553 | 554 | for d in duplicates:
|
554 | 555 | path = d["duplicate_path"]
|
555 | 556 | if not path.startswith("http") and not args.only_soft_delete:
|
556 |
| - file_utils.trash(path, detach=False) |
| 557 | + if args.dedupe_cmd: |
| 558 | + processes.cmd( |
| 559 | + *shlex.split(args.dedupe_cmd), d["duplicate_path"], d["keep_path"] |
| 560 | + ) # follows rmlint interface |
| 561 | + else: |
| 562 | + file_utils.trash(path, detach=False) |
557 | 563 | db_media.mark_media_deleted(args, path)
|
558 | 564 |
|
559 | 565 |
|
|
0 commit comments