add get_song_by_title_artist
This commit is contained in:
parent
0f06261c96
commit
e94af7a6b0
1 changed files with 14 additions and 0 deletions
|
@ -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()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue