This commit is contained in:
2026-04-13 16:16:20 +02:00
parent d056f02f78
commit b805bd77e7
3 changed files with 62 additions and 62 deletions

View File

@@ -104,6 +104,7 @@ def scan_library(library_id: int, library_path: str, db_path: str,
""", (library_id, tags.get("title",""), tags.get("artist",""),
tags.get("album",""), bpm, tags.get("duration_sec",0),
tags.get("file_format",""), mtime, extra, existing["id"]))
song_id = existing["id"]
else:
song_id = str(uuid.uuid4())
conn.execute("""
@@ -117,6 +118,30 @@ def scan_library(library_id: int, library_path: str, db_path: str,
tags.get("duration_sec",0), tags.get("file_format",""),
mtime, extra))
# Importer dans-tags fra filen hvis de ikke allerede er i DB
file_dances = tags.get("dances", [])
if file_dances:
existing_dances = conn.execute(
"SELECT COUNT(*) FROM song_dances WHERE song_id=?", (song_id,)
).fetchone()[0]
if existing_dances == 0:
for order, dance_name in enumerate(file_dances, start=1):
dance_row = conn.execute(
"SELECT id FROM dances WHERE name=? COLLATE NOCASE LIMIT 1",
(dance_name,)
).fetchone()
if not dance_row:
cur = conn.execute(
"INSERT INTO dances (name) VALUES (?)", (dance_name,)
)
dance_id = cur.lastrowid
else:
dance_id = dance_row["id"]
conn.execute(
"INSERT OR IGNORE INTO song_dances (song_id, dance_id, dance_order) VALUES (?,?,?)",
(song_id, dance_id, order)
)
conn.commit()
except Exception as e:
logger.warning(f"Scan fejl {fp.name}: {e}")