radio_util: new method add_genre added, groundwork for auto tagging. to be continued...
This commit is contained in:
parent
1a4c44e33b
commit
ebc21cfb10
@ -170,6 +170,30 @@ class RadioUtil:
|
||||
traceback.print_exc()
|
||||
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:
|
||||
"""
|
||||
Retrieve Genre for given Artist
|
||||
|
Loading…
x
Reference in New Issue
Block a user