check if track exists in db before sending file

This commit is contained in:
mungai-njoroge
2023-06-19 21:49:13 +03:00
parent a201303bd9
commit cc6552cb94
17 changed files with 96 additions and 31 deletions
+7 -1
View File
@@ -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()