Compare commits

...

2 Commits

Author SHA1 Message Date
e4f7172f88
Just log errors for now 2025-06-01 14:23:28 +02:00
2ffae9ceda
Strip trailing dots, document those measures 2025-06-01 14:18:29 +02:00
2 changed files with 12 additions and 2 deletions

View File

@ -27,7 +27,10 @@ if __name__ == "__main__":
logging.warning(f"Moving {len(move_instructions)} songs!")
for instruction in tqdm(move_instructions, unit=" songs"):
instruction()
try:
instruction()
except FileExistsError:
logging.error(f"Could not move {instruction.old_path} -> {instruction.new_path}")
logging.info("Moving done")
logging.info("Karaokatalog Organization done")

View File

@ -7,7 +7,11 @@ from tqdm import tqdm
from karaokatalog.instructions.MoveInstruction import MoveInstruction
from karaokatalog.Song import Song
FORBIDDEN_CHARACTERS = re.compile(r'[\/<>:"\\|?*]')
# Those characters are forbidden on Linux (few) or on Windows (many), so we strip them from filenames
# https://stackoverflow.com/a/31976060/
# Apparently, trailing dots are also prohibited, so we strip those as well:
# https://lkml.iu.edu/hypermail/linux/kernel/2203.2/01877.html
FORBIDDEN_CHARACTERS = re.compile(r'[\/<>:"\\|?*]|\.$')
def _get_canonical_song_dir(song: Song, variant: int = 0) -> Path:
@ -28,6 +32,9 @@ 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.
"""
# We lower case all the song directories, because Windows filesystems are often
# case-insensitive, so we have to ignore casing when finding duplicates
song_dir_strs_lower = set(
str(song.dir.relative_to(base_dir)).lower() for song in songs
)