style(audiobooks_library): ruff changes

This commit is contained in:
Lucas Vivo committed 2026-11-16 19:48:09 +01:00
1 parent 9b79f1bd91
commit e934f0e70b
1 file changed
+9 -7
@@ -6,14 +6,14 @@ import logging
import re
import sqlite3
import subprocess
import requests
import sys
from typing import Any
import tempfile
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
from typing import Any
import requests
from mutagen import File
from mutagen.id3 import (
COMM,
@@ -35,11 +35,11 @@ from serverlibrary import (
CustomLogger,
blue_tag,
green_tag,
parser_add_loglevel,
red_tag,
score_match_jaccard,
setup_logging,
words,
parser_add_loglevel
)
ID3_FRAME_CLASSES = {
@@ -1359,20 +1359,21 @@ class AudiobookLibrary:
self.embed_metadata_for_book(item_id)
except Exception as e:
logger.error(f"Failed: {book_name}: {e}")
raise
def embed_metadata_from_file(self, filename: str) -> None:
filename = Path(filename).expanduser().resolve()
with open(filename, encoding="utf-8") as f:
resolved_path = Path(filename).expanduser().resolve()
with open(resolved_path, encoding="utf-8") as f:
item_ids = [
line.strip()
for line in f
if line.strip() and not line.startswith("#")
]
logger.info(f"Loaded {len(item_ids)} item IDs from {filename}")
logger.info(f"Loaded {len(item_ids)} item IDs from {resolved_path}")
for item_id in item_ids:
book = next(
books = next(
(b for b in self.books if b["id"] == item_id),
None
)
@@ -1380,6 +1381,7 @@ class AudiobookLibrary:
self.embed_metadata_for_book(item_id)
except Exception as e:
logger.error(f"Failed: {item_id}: {e}")
raise
def add(self, book: Audiobook):