metadata script

metadata remove genre: script to remove keywords ie audiobook from genre
rank from list: change pattern and separate author and title, rank is
str now
This commit is contained in:
Lucas Serverhost authored and Lucas Vivohost committed 2026-09-14 12:43:38 +02:00
1 parent 0dca4be1f3
commit fe68810e0f
2 files changed
+113 -8

No files matched your search

+10 -8
View File
@@ -70,9 +70,11 @@ def tag_file(path: Path, rank: int, year: str, dry_run: bool):
else:
tag = "grouping"
existing = ""
pattern = r"Top 100 SciFi Books #\d+"
# pattern = r"Enderverse"
replace = r"Top 100 SciFi Books"
#pattern = r"Top 100 SciFi Books #\d+(?:\.\d+)?"
pattern = r"Enderverse Publication #\d+(?:\.\d+)?"
#replace = r"Top 100 SciFi Books"
replace = r"Enderverse Publication"
if existing:
if re.search(pattern, existing):
new_group = re.sub(
@@ -142,9 +144,9 @@ def main():
parts = line.split(" - ")
if len(parts) == 4:
rank, author, title, year = parts
rank, title, author, year = parts
elif len(parts) == 3:
rank, author, title = parts
rank, title, author = parts
year = None
else:
raise ValueError(f"Invalid line: {line}")
@@ -186,7 +188,7 @@ def main():
found.add(rank)
print(f"{GREEN}FOUND{RESET} #{int(rank):3} {title} in {book_dir}")
print(f"{GREEN}FOUND{RESET} #{rank:3} {title} in {book_dir}")
if args.find_missing:
continue
@@ -195,10 +197,10 @@ def main():
if file.suffix.lower() not in AUDIO_EXTENSIONS:
continue
ret=tag_file(file, int(rank), year, args.dry_run)
ret=tag_file(file, rank, year, args.dry_run)
if ret == "skip":
break
# print("next")
#print("next")
if __name__ == "__main__":
main()