Bedre tag sync
This commit is contained in:
@@ -213,10 +213,16 @@ def run_acoustid_scan(db_path: str, api_key: str = "", on_progress=None, stop_ev
|
||||
if result:
|
||||
mbid = result.get("mbid", "")
|
||||
acoustid = result.get("acoustid", "")
|
||||
# Opdater acoustid altid, men kun mbid hvis det ikke allerede bruges
|
||||
conn.execute(
|
||||
"UPDATE songs SET mbid=?, acoustid=? WHERE id=?",
|
||||
(mbid or None, acoustid or None, row["id"])
|
||||
"UPDATE songs SET acoustid=? WHERE id=?",
|
||||
(acoustid or None, row["id"])
|
||||
)
|
||||
if mbid:
|
||||
conn.execute(
|
||||
"UPDATE songs SET mbid=? WHERE id=? AND (mbid IS NULL OR mbid='')",
|
||||
(mbid, row["id"])
|
||||
)
|
||||
conn.commit()
|
||||
found += 1
|
||||
total_found += 1
|
||||
|
||||
@@ -647,8 +647,8 @@ def get_choreographer_suggestions(prefix: str = "", limit: int = 15) -> list[str
|
||||
def get_dances_for_song(song_id: str) -> list:
|
||||
"""Hent alle danse tagget på en sang med niveau og koreograf."""
|
||||
with get_db() as conn:
|
||||
return conn.execute("""
|
||||
SELECT d.id, d.name, dl.name as level_name, d.choreographer,
|
||||
rows = conn.execute("""
|
||||
SELECT d.id, d.name, d.level_id, dl.name as level_name, d.choreographer,
|
||||
d.video_url, d.stepsheet_url, d.notes, sd.dance_order
|
||||
FROM song_dances sd
|
||||
JOIN dances d ON d.id = sd.dance_id
|
||||
@@ -656,13 +656,14 @@ def get_dances_for_song(song_id: str) -> list:
|
||||
WHERE sd.song_id = ?
|
||||
ORDER BY sd.dance_order
|
||||
""", (song_id,)).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
|
||||
def get_alt_dances_for_song(song_id: str) -> list:
|
||||
"""Hent alle alternativ-danse tagget på en sang."""
|
||||
with get_db() as conn:
|
||||
return conn.execute("""
|
||||
SELECT d.id, d.name, dl.name as level_name, d.choreographer,
|
||||
rows = conn.execute("""
|
||||
SELECT d.id, d.name, d.level_id, dl.name as level_name, d.choreographer,
|
||||
d.video_url, d.stepsheet_url, sad.note
|
||||
FROM song_alt_dances sad
|
||||
JOIN dances d ON d.id = sad.dance_id
|
||||
@@ -670,6 +671,7 @@ def get_alt_dances_for_song(song_id: str) -> list:
|
||||
WHERE sad.song_id = ?
|
||||
ORDER BY d.name
|
||||
""", (song_id,)).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
def get_or_create_dance(name: str, level_id: int | None, conn,
|
||||
choreographer: str = "") -> int:
|
||||
|
||||
Reference in New Issue
Block a user