backup
This commit is contained in:
@@ -9,54 +9,15 @@ from processors.standardizer import standardize_comic
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Gestor de colección de cómics CBR/CBZ"
|
||||
)
|
||||
parser = argparse.ArgumentParser(description="Gestor de cómics CBR/CBZ")
|
||||
|
||||
parser.add_argument(
|
||||
"--ruta",
|
||||
type=str,
|
||||
required=True,
|
||||
help="Ruta base donde buscar los cómics"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--listar",
|
||||
action="store_true",
|
||||
help="Listar todos los archivos CBR/CBZ encontrados"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--validar",
|
||||
action="store_true",
|
||||
help="Validar los archivos encontrados"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--limpiar",
|
||||
action="store_true",
|
||||
help="Eliminar archivos basura y reconstruir CBZ limpios"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--convertir",
|
||||
action="store_true",
|
||||
help="Convertir los archivos al formato indicado con --formato"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--formato",
|
||||
type=str,
|
||||
choices=["cbz", "cbr"],
|
||||
default="cbz",
|
||||
help="Formato final deseado (por defecto: cbz)"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--estandarizar",
|
||||
action="store_true",
|
||||
help="Pipeline completo: limpiar, convertir y normalizar"
|
||||
)
|
||||
parser.add_argument("--ruta", required=True)
|
||||
parser.add_argument("--listar", action="store_true")
|
||||
parser.add_argument("--validar", action="store_true")
|
||||
parser.add_argument("--limpiar", action="store_true")
|
||||
parser.add_argument("--convertir", action="store_true")
|
||||
parser.add_argument("--estandarizar", action="store_true")
|
||||
parser.add_argument("--formato", choices=["cbz", "cbr"], default="cbz")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -64,74 +25,38 @@ def parse_args():
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
print(f"Buscando archivos CBR/CBZ en: {args.ruta}\n")
|
||||
comic_files = find_comic_files(args.ruta)
|
||||
|
||||
if not comic_files:
|
||||
print("No se encontraron archivos .cbr o .cbz")
|
||||
return
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# LISTAR
|
||||
# ------------------------------------------------------------
|
||||
if args.listar:
|
||||
print("Archivos encontrados:")
|
||||
for f in comic_files:
|
||||
print(f" - {f}")
|
||||
print()
|
||||
print(f)
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# VALIDAR
|
||||
# ------------------------------------------------------------
|
||||
if args.validar:
|
||||
print("Validando archivos...\n")
|
||||
for f in comic_files:
|
||||
result = validate_comic(f)
|
||||
print(result)
|
||||
|
||||
if result.errors:
|
||||
print(" Errores:")
|
||||
for e in result.errors:
|
||||
print(f" - {e}")
|
||||
|
||||
if result.warnings:
|
||||
print(" Avisos:")
|
||||
for w in result.warnings:
|
||||
print(f" - {w}")
|
||||
|
||||
print(f"Validando: {f}")
|
||||
print(validate_comic(f))
|
||||
print()
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# LIMPIAR
|
||||
# ------------------------------------------------------------
|
||||
if args.limpiar:
|
||||
print("Limpiando archivos...\n")
|
||||
for f in comic_files:
|
||||
result = clean_comic(f)
|
||||
print(result)
|
||||
print(f"Limpieza: {f}")
|
||||
print(clean_comic(f))
|
||||
print()
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# CONVERTIR
|
||||
# ------------------------------------------------------------
|
||||
if args.convertir:
|
||||
print(f"Convirtiendo archivos al formato {args.formato}...\n")
|
||||
for f in comic_files:
|
||||
print(f"Convirtiendo: {f}")
|
||||
info = convert_comic(f, args.formato)
|
||||
if info["needs_conversion"]:
|
||||
print(f"Convertido: {f} → {info['target_path']}")
|
||||
print(f" → Convertido a {args.formato.upper()}: {info['target_path']}")
|
||||
else:
|
||||
print(f"Sin cambios: {f}")
|
||||
print()
|
||||
print(f" → Sin cambios (ya era {args.formato.upper()})")
|
||||
print()
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# ESTANDARIZAR
|
||||
# ------------------------------------------------------------
|
||||
if args.estandarizar:
|
||||
print("Estandarizando archivos...\n")
|
||||
for f in comic_files:
|
||||
result = standardize_comic(f, args.formato)
|
||||
print(result)
|
||||
print(f"Estandarizando: {f}")
|
||||
print(standardize_comic(f, args.formato))
|
||||
print()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user