mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-07 03:35:35 +00:00

+ fix: sqlite3.ProgrammingError: Cannot operate on a closed cursor on ProcessAlbumColors() + move processing artist images from periodic_scans to Populate + bump hash string limit from 7 to 10 + add last_mod property to database + fix: TypeError: '<' not supported between instances of 'int' and 'str' on album page
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from sqlite3 import Cursor
|
|
|
|
from .utils import SQLiteManager, tuples_to_albums
|
|
|
|
|
|
class SQLiteAlbumMethods:
|
|
@classmethod
|
|
def insert_one_album(cls, cur: Cursor, albumhash: str, colors: str):
|
|
"""
|
|
Inserts one album into the database
|
|
"""
|
|
|
|
sql = """INSERT OR REPLACE INTO albums(
|
|
albumhash,
|
|
colors
|
|
) VALUES(?,?)
|
|
"""
|
|
|
|
cur.execute(sql, (albumhash, colors))
|
|
lastrowid = cur.lastrowid
|
|
|
|
return lastrowid
|
|
|
|
@classmethod
|
|
def get_all_albums(cls):
|
|
with SQLiteManager() as cur:
|
|
cur.execute("SELECT * FROM albums")
|
|
albums = cur.fetchall()
|
|
cur.close()
|
|
|
|
if albums is not None:
|
|
return albums
|
|
|
|
return []
|
|
|
|
@staticmethod
|
|
def get_albums_by_albumartist(albumartist: str):
|
|
with SQLiteManager() as cur:
|
|
cur.execute("SELECT * FROM albums WHERE albumartist=?", (albumartist,))
|
|
albums = cur.fetchall()
|
|
cur.close()
|
|
|
|
if albums is not None:
|
|
return tuples_to_albums(albums)
|
|
|
|
return []
|