add add_song
This commit is contained in:
parent
2a10a91776
commit
386dd64a7a
1 changed files with 15 additions and 0 deletions
|
@ -41,3 +41,18 @@ def get_song_by_mbid(mbid: str) -> Song:
|
||||||
|
|
||||||
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"])
|
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
|
return song
|
||||||
|
|
||||||
|
|
||||||
|
def add_song(song: Song):
|
||||||
|
conn = get_connection()
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
cursor.execute(
|
||||||
|
"""
|
||||||
|
INSERT OR REPLACE INTO songs (mbid, title, artist, tags, lastfm_image_id, youtube_id)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?)
|
||||||
|
""",
|
||||||
|
(song.mbid, song.title, song.artist, ",".join(song.tags), song.image_id, song.youtube_id),
|
||||||
|
) # Updates song info if it already exists
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue