Import skeleton of organization

This commit is contained in:
Jakob Moser 2025-06-01 10:16:37 +02:00
parent b731339806
commit f2c0e5a4f7
Signed by: jakob
GPG Key ID: 3EF2BA2851B3F53C
3 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,18 @@
from dataclasses import dataclass
from pathlib import Path
from karaokatalog.instructions.Instruction import Instruction
@dataclass(frozen=True)
class MoveInstruction(Instruction):
"""
Move the old path (might point to a file, a folder or a link) to the new path, no questions asked.
Does not override existing paths.
"""
old_path: Path
new_path: Path
def __call__(self) -> None:
raise NotImplementedError() # TODO

View File

@ -1,7 +1,10 @@
import logging
from tqdm import tqdm
from karaokatalog.get_parser import get_parser
from karaokatalog.Library import Library
from karaokatalog.organize.move import move
logging.basicConfig(
format="%(asctime)s [%(levelname)s] %(message)s", level=logging.INFO
@ -18,6 +21,13 @@ if __name__ == "__main__":
library = Library.from_dir(args.library_path)
logging.info("Library loaded")
# TODO
logging.info("Generating move instructions")
move_instructions = move(library.songs, args.library_path)
logging.info(f"{len(move_instructions)} move instructions generated")
logging.warning(f"Moving {len(move_instructions)} songs!")
for instruction in tqdm(move_instructions, unit=" songs"):
instruction()
logging.info("Moving done")
logging.info("Karaokatalog Organization done")

View File

@ -0,0 +1,13 @@
from collections.abc import Sequence
from pathlib import Path
from karaokatalog.instructions.MoveInstruction import MoveInstruction
from karaokatalog.Song import Song
def move(songs: Sequence[Song], base_dir: Path) -> Sequence[MoveInstruction]:
"""
Create move instructions to move every song into the proper song directory
within the given base_dir.
"""
raise NotImplementedError() # TODO