mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
check if track exists in db before sending file
This commit is contained in:
@@ -14,6 +14,7 @@ class SQLiteFavoriteMethods:
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, (itemhash, fav_type))
|
||||
items = cur.fetchall()
|
||||
cur.close()
|
||||
return len(items) > 0
|
||||
|
||||
@classmethod
|
||||
@@ -28,6 +29,7 @@ class SQLiteFavoriteMethods:
|
||||
sql = """INSERT INTO favorites(type, hash) VALUES(?,?)"""
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, (fav_type, fav_hash))
|
||||
cur.close()
|
||||
|
||||
@classmethod
|
||||
def get_all(cls) -> list[tuple]:
|
||||
@@ -38,6 +40,7 @@ class SQLiteFavoriteMethods:
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql)
|
||||
favs = cur.fetchall()
|
||||
cur.close()
|
||||
return [fav for fav in favs if fav[1] != ""]
|
||||
|
||||
@classmethod
|
||||
@@ -48,7 +51,9 @@ class SQLiteFavoriteMethods:
|
||||
sql = """SELECT * FROM favorites WHERE type = ?"""
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, (fav_type,))
|
||||
return cur.fetchall()
|
||||
all_favs = cur.fetchall()
|
||||
cur.close()
|
||||
return all_favs
|
||||
|
||||
@classmethod
|
||||
def get_fav_tracks(cls) -> list[tuple]:
|
||||
@@ -80,3 +85,4 @@ class SQLiteFavoriteMethods:
|
||||
|
||||
with SQLiteManager(userdata_db=True) as cur:
|
||||
cur.execute(sql, (fav_hash, fav_type))
|
||||
cur.close()
|
||||
|
||||
Reference in New Issue
Block a user