add get_song_by_title_artist

This commit is contained in:
Francesco De Carlo 2025-08-01 23:07:04 +02:00
parent 0f06261c96
commit e94af7a6b0

View file

@ -43,6 +43,20 @@ def get_song_by_mbid(mbid: str) -> Song | None:
return song return song
def get_song_by_title_artist(title: str, artist: str) -> Song | None:
conn = get_connection()
cursor = conn.cursor()
cursor.execute("SELECT * FROM songs WHERE title = ? AND artist = ?", (title, artist))
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"])
return song
def add_song(song: Song): def add_song(song: Song):
conn = get_connection() conn = get_connection()
cursor = conn.cursor() cursor = conn.cursor()