From 0f06261c96283a4218d6715cb0e3aa25010337fe Mon Sep 17 00:00:00 2001 From: panzerotto Date: Fri, 1 Aug 2025 22:43:15 +0200 Subject: [PATCH] mod get_song_by_mbid returns None if it finds nothing --- backend/src/song.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/song.py b/backend/src/song.py index 598975f..9b95add 100644 --- a/backend/src/song.py +++ b/backend/src/song.py @@ -29,7 +29,7 @@ class Song: youtube_id: str -def get_song_by_mbid(mbid: str) -> Song: +def get_song_by_mbid(mbid: str) -> Song | None: conn = get_connection() cursor = conn.cursor() cursor.execute("SELECT * FROM songs WHERE mbid = ?", (mbid,)) @@ -37,7 +37,7 @@ def get_song_by_mbid(mbid: str) -> Song: conn.close() if row is None: - raise ValueError(f"Song with MBID {mbid} not found") + 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"]) return song