Files
am-downloader/am_deduper/cli.py
T

19 lines
765 B
Python

from __future__ import annotations
import argparse
from pathlib import Path
from .exact import exact_dedupe
from .scanner import scan
from .l2 import acoustic_dedupe
from .watcher import watch
def main():
p=argparse.ArgumentParser(prog='am-deduper'); sub=p.add_subparsers(dest='cmd',required=True)
for name in ('scan','dedupe','reconcile','watch'):
sp=sub.add_parser(name); sp.add_argument('root',type=Path); sp.add_argument('--db',type=Path,default=None)
a=p.parse_args(); db=a.db or a.root/'.dedupe'/'dedupe.db'
if a.cmd=='watch': watch(a.root,db); return
print(f'indexed={scan(a.root,db)} db={db}')
if a.cmd in ('dedupe','reconcile'):
ex=exact_dedupe(db,a.root); print(f'exact_hardlinked={len(ex)}')
l2=acoustic_dedupe(db,a.root); print(f'l2={l2}')