add get_song_by_mbid
This commit is contained in:
parent
e78ecede2d
commit
2a10a91776
1 changed files with 14 additions and 0 deletions
|
@ -27,3 +27,17 @@ class Song:
|
||||||
tags: list[str]
|
tags: list[str]
|
||||||
image_id: str
|
image_id: str
|
||||||
youtube_id: str
|
youtube_id: str
|
||||||
|
|
||||||
|
|
||||||
|
def get_song_by_mbid(mbid: str) -> Song:
|
||||||
|
conn = get_connection()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("SELECT * FROM songs WHERE mbid = ?", (mbid,))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
if row is None:
|
||||||
|
raise ValueError(f"Song with MBID {mbid} not found")
|
||||||
|
|
||||||
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue