Compare commits

..

No commits in common. "6bc982f668eb13642228ef4d994a354d3296b867" and "1a4c44e33b1948f9c71789487d0a86be79ace1cc" have entirely different histories.

View File

@ -170,30 +170,6 @@ class RadioUtil:
traceback.print_exc() traceback.print_exc()
return False return False
async def add_genre(self, artist: str, genre: str) -> bool:
"""
Add artist/genre pairing to DB
Args:
artist (str)
genre (str)
Returns:
bool
"""
try:
async with sqlite3.connect(self.artist_genre_db_path, timeout=2) as _db:
query: str = "INSERT OR IGNORE INTO artist_genre (artist, genre) VALUES(?, ?)"
params: tuple[str, str] = (artist, genre)
res = await _db.execute_insert(query, params)
if res:
return True
return False
except Exception as e:
logging.info("Failed to store artist/genre pair: %s/%s (%s)",
artist, genre, str(e))
traceback.print_exc()
return False
async def get_genre(self, artist: str) -> str: async def get_genre(self, artist: str) -> str:
""" """
Retrieve Genre for given Artist Retrieve Genre for given Artist
@ -204,8 +180,8 @@ class RadioUtil:
""" """
try: try:
artist = artist.strip() artist = artist.strip()
query: str = "SELECT genre FROM artist_genre WHERE artist LIKE ?" query = "SELECT genre FROM artist_genre WHERE artist LIKE ?"
params: tuple[str] = (f"%%{artist}%%",) params = (f"%%{artist}%%",)
async with sqlite3.connect(self.artist_genre_db_path, timeout=2) as _db: async with sqlite3.connect(self.artist_genre_db_path, timeout=2) as _db:
_db.row_factory = sqlite3.Row _db.row_factory = sqlite3.Row
async with await _db.execute(query, params) as _cursor: async with await _db.execute(query, params) as _cursor:
@ -329,7 +305,7 @@ class RadioUtil:
async with sqlite3.connect(self.album_art_db_path, timeout=2) as db_conn: async with sqlite3.connect(self.album_art_db_path, timeout=2) as db_conn:
db_conn.row_factory = sqlite3.Row db_conn.row_factory = sqlite3.Row
query: str = "SELECT album_art FROM album_art WHERE track_id = ?" query: str = "SELECT album_art FROM album_art WHERE track_id = ?"
query_params: tuple[int] = (track_id,) query_params: tuple = (track_id,)
async with await db_conn.execute(query, query_params) as db_cursor: async with await db_conn.execute(query, query_params) as db_cursor:
result: Optional[Union[sqlite3.Row, bool]] = ( result: Optional[Union[sqlite3.Row, bool]] = (