scanner.py
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
# core/scanner.py
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
VALID_EXTENSIONS = {".cbr", ".cbz"}
|
||||||
|
|
||||||
|
def find_comic_files(base_path):
|
||||||
|
"""
|
||||||
|
Recorre recursivamente un directorio y devuelve una lista
|
||||||
|
con todos los archivos .cbr y .cbz encontrados.
|
||||||
|
"""
|
||||||
|
comic_files = []
|
||||||
|
|
||||||
|
for root, _, files in os.walk(base_path):
|
||||||
|
for file in files:
|
||||||
|
ext = os.path.splitext(file)[1].lower()
|
||||||
|
if ext in VALID_EXTENSIONS:
|
||||||
|
full_path = os.path.join(root, file)
|
||||||
|
comic_files.append(full_path)
|
||||||
|
|
||||||
|
return comic_files
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# main.py
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from core.scanner import find_comic_files
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Obtener ruta desde argumentos o pedirla
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
base_path = sys.argv[1]
|
||||||
|
else:
|
||||||
|
base_path = input("Introduce la ruta de la colección: ").strip()
|
||||||
|
|
||||||
|
print(f"Buscando archivos CBR/CBZ en: {base_path}\n")
|
||||||
|
|
||||||
|
comic_files = find_comic_files(base_path)
|
||||||
|
|
||||||
|
if not comic_files:
|
||||||
|
print("No se encontraron archivos .cbr o .cbz")
|
||||||
|
return
|
||||||
|
|
||||||
|
print("Archivos encontrados:")
|
||||||
|
for f in comic_files:
|
||||||
|
print(f" - {f}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user