diff --git a/backend/src/song.py b/backend/src/song.py index 12ef130..39871cc 100644 --- a/backend/src/song.py +++ b/backend/src/song.py @@ -8,7 +8,7 @@ from .connect import get_connection def init_db(db: Cursor): db.execute(""" CREATE TABLE IF NOT EXISTS songs ( - mbid TEXT PRIMARY KEY, + uuid TEXT PRIMARY KEY, title TEXT NOT NULL, artist TEXT NOT NULL, tags TEXT NOT NULL, @@ -20,7 +20,7 @@ def init_db(db: Cursor): @dataclass(frozen=True) class Song: - mbid: str + uuid: str title: str artist: str tags: list[str] @@ -28,17 +28,17 @@ class Song: youtube_id: str -def get_song_by_mbid(mbid: str) -> Song | None: +def get_song_by_uuid(uuid: str) -> Song | None: conn = get_connection() cursor = conn.cursor() - cursor.execute("SELECT * FROM songs WHERE mbid = ?", (mbid,)) + cursor.execute("SELECT * FROM songs WHERE uuid = ?", (uuid,)) row = cursor.fetchone() conn.close() if row is None: return None - song = Song(mbid=row["mbid"], title=row["title"], artist=row["artist"], tags=row["tags"].split(","), image_id=row["lastfm_image_id"], youtube_id=row["youtube_id"]) + song = Song(uuid=row["uuid"], title=row["title"], artist=row["artist"], tags=row["tags"].split(","), image_id=row["lastfm_image_id"], youtube_id=row["youtube_id"]) return song @@ -52,7 +52,7 @@ def get_song_by_title_artist(title: str, artist: str) -> Song | None: if row is None: return None - song = Song(mbid=row["mbid"], title=row["title"], artist=row["artist"], tags=row["tags"].split(","), image_id=row["lastfm_image_id"], youtube_id=row["youtube_id"]) + song = Song(uuid=row["uuid"], title=row["title"], artist=row["artist"], tags=row["tags"].split(","), image_id=row["lastfm_image_id"], youtube_id=row["youtube_id"]) return song @@ -62,7 +62,7 @@ def add_song_in_db(title: str, artist: str, tags: list[str], image_id: str, yt_i cursor.execute( """ - INSERT OR REPLACE INTO songs (mbid, title, artist, tags, lastfm_image_id, youtube_id) + INSERT OR REPLACE INTO songs (uuid, title, artist, tags, lastfm_image_id, youtube_id) VALUES (?, ?, ?, ?, ?, ?) """, (str(uuid.uuid4()), title, artist, ",".join(tags), image_id, yt_id),