This commit is contained in:
Simone Tesini 2025-08-01 22:50:12 +02:00
commit 07964c469e
2 changed files with 49 additions and 16 deletions

View file

@ -30,7 +30,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,))
@ -38,7 +38,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