add function to validate albums

+ extract colors in watchdogg
+ rename color db files
This commit is contained in:
mungai-njoroge
2023-07-12 08:56:30 +03:00
parent 4a7416853a
commit 861a854f91
18 changed files with 170 additions and 38 deletions
@@ -44,3 +44,23 @@ class SQLiteAlbumMethods:
return tuples_to_albums(albums)
return []
@staticmethod
def exists(albumhash: str, cur: Cursor = None):
"""
Checks if an album exists in the database.
"""
sql = "SELECT COUNT(1) FROM albums WHERE albumhash = ?"
def _exists(cur: Cursor):
cur.execute(sql, (albumhash,))
count = cur.fetchone()[0]
return count != 0
if cur:
return _exists(cur)
with SQLiteManager() as cur:
return _exists(cur)
@@ -43,3 +43,22 @@ class SQLiteArtistMethods:
for artist in cur_.fetchall():
yield artist
@staticmethod
def exists(artisthash: str, cur: Cursor = None):
"""
Checks if an artist exists in the database.
"""
sql = "SELECT COUNT(1) FROM artists WHERE artisthash = ?"
def _exists(cur: Cursor):
cur.execute(sql, (artisthash,))
count = cur.fetchone()[0]
return count != 0
if cur:
return _exists(cur)
with SQLiteManager() as cur:
return _exists(cur)