diff --git a/karaokatalog/instructions/MoveInstruction.py b/karaokatalog/instructions/MoveInstruction.py new file mode 100644 index 0000000..cf2a157 --- /dev/null +++ b/karaokatalog/instructions/MoveInstruction.py @@ -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 diff --git a/karaokatalog/organize/__main__.py b/karaokatalog/organize/__main__.py index 31b63be..c9f1600 100644 --- a/karaokatalog/organize/__main__.py +++ b/karaokatalog/organize/__main__.py @@ -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") diff --git a/karaokatalog/organize/move.py b/karaokatalog/organize/move.py new file mode 100644 index 0000000..7f9f1a6 --- /dev/null +++ b/karaokatalog/organize/move.py @@ -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