misc
This commit is contained in:
@ -34,8 +34,9 @@ class RadioUtil:
|
||||
Radio Utils
|
||||
"""
|
||||
|
||||
def __init__(self, constants) -> None:
|
||||
def __init__(self, constants, loop) -> None:
|
||||
self.constants = constants
|
||||
self.loop = loop
|
||||
self.gpt = gpt.GPT(self.constants)
|
||||
self.ls_uri: str = self.constants.LS_URI
|
||||
self.sqlite_exts: list[str] = [
|
||||
@ -51,12 +52,12 @@ class RadioUtil:
|
||||
"/usr/local/share", "sqlite_dbs", "track_album_art.db"
|
||||
)
|
||||
self.playback_genres: list[str] = [
|
||||
# "post-hardcore",
|
||||
# "post hardcore",
|
||||
# "metalcore",
|
||||
# "deathcore",
|
||||
# "edm",
|
||||
# "electronic",
|
||||
"post-hardcore",
|
||||
"post hardcore",
|
||||
"metalcore",
|
||||
"deathcore",
|
||||
"edm",
|
||||
"electronic",
|
||||
]
|
||||
self.active_playlist: list[dict] = []
|
||||
self.playlist_loaded: bool = False
|
||||
@ -161,9 +162,11 @@ class RadioUtil:
|
||||
if not artistsong and (not artist or not song):
|
||||
raise RadioException("No query provided")
|
||||
try:
|
||||
search_query: str = 'SELECT id, artist, song, (artist || " - " || song) AS artistsong, album, file_path, duration FROM tracks\
|
||||
search_query: str = (
|
||||
'SELECT id, artist, song, (artist || " - " || song) AS artistsong, album, file_path, duration FROM tracks\
|
||||
WHERE editdist3((lower(artist) || " " || lower(song)), (? || " " || ?))\
|
||||
<= 410 ORDER BY editdist3((lower(artist) || " " || lower(song)), ?) ASC LIMIT 1'
|
||||
)
|
||||
if artistsong:
|
||||
artistsong_split: list = artistsong.split(" - ", maxsplit=1)
|
||||
(search_artist, search_song) = tuple(artistsong_split)
|
||||
@ -255,7 +258,9 @@ class RadioUtil:
|
||||
for pair in pairs:
|
||||
try:
|
||||
artist, genre = pair
|
||||
query: str = "INSERT OR IGNORE INTO artist_genre (artist, genre) VALUES(?, ?)"
|
||||
query: str = (
|
||||
"INSERT OR IGNORE INTO artist_genre (artist, genre) VALUES(?, ?)"
|
||||
)
|
||||
params: tuple[str, str] = (artist, genre)
|
||||
res = _db.execute(query, params)
|
||||
if isinstance(res.lastrowid, int):
|
||||
@ -405,11 +410,12 @@ class RadioUtil:
|
||||
len(self.active_playlist),
|
||||
)
|
||||
self.playlist_loaded = True
|
||||
self.loop.create_task(self._ls_skip())
|
||||
except Exception as e:
|
||||
logging.info("Playlist load failed: %s", str(e))
|
||||
traceback.print_exc()
|
||||
|
||||
async def cache_album_art(self, track_id: int, file_path: str) -> None:
|
||||
def cache_album_art(self, track_id: int, file_path: str) -> None:
|
||||
"""
|
||||
Cache Album Art to SQLite DB
|
||||
Args:
|
||||
@ -445,7 +451,7 @@ class RadioUtil:
|
||||
logging.debug("cache_album_art Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
|
||||
async def get_album_art(self, track_id: int) -> Optional[bytes]:
|
||||
def get_album_art(self, track_id: int) -> Optional[bytes]:
|
||||
"""
|
||||
Get Album Art
|
||||
Args:
|
||||
|
Reference in New Issue
Block a user