misc
This commit is contained in:
@ -50,7 +50,8 @@ class LastFM:
|
||||
.split("<a href")[0],
|
||||
}
|
||||
return ret_obj
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return {
|
||||
"err": "Failed",
|
||||
@ -101,8 +102,9 @@ class LastFM:
|
||||
"album": album,
|
||||
}
|
||||
return ret_obj
|
||||
except:
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
logging.debug("Exception: %s", str(e))
|
||||
return {
|
||||
"err": "General Failure",
|
||||
}
|
||||
@ -132,8 +134,9 @@ class LastFM:
|
||||
|
||||
return ret_obj
|
||||
|
||||
except:
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
logging.debug("Exception: %s", str(e))
|
||||
return {
|
||||
"err": "General Failure",
|
||||
}
|
||||
@ -178,7 +181,8 @@ class LastFM:
|
||||
and int(item.get("playcount")) >= 50
|
||||
]
|
||||
return ret_obj
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return {
|
||||
"err": "Failed",
|
||||
@ -201,7 +205,8 @@ class LastFM:
|
||||
return -1
|
||||
artist_id: int = int(artist_search[0].get("id", 0))
|
||||
return artist_id
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return -1
|
||||
|
||||
@ -252,7 +257,8 @@ class LastFM:
|
||||
"members": members,
|
||||
}
|
||||
return ret_obj
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return {
|
||||
"err": "Failed",
|
||||
@ -284,7 +290,8 @@ class LastFM:
|
||||
"err": "Failed",
|
||||
}
|
||||
return artist_info
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return {
|
||||
"err": "Failed",
|
||||
@ -337,7 +344,8 @@ class LastFM:
|
||||
}
|
||||
try:
|
||||
track_key: list = data.get("tracks", None).get("track")
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
track_key = []
|
||||
if isinstance(track_key, list):
|
||||
ret_obj["tracks"] = [
|
||||
@ -357,7 +365,8 @@ class LastFM:
|
||||
}
|
||||
]
|
||||
return ret_obj
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return {
|
||||
"err": "Failed",
|
||||
|
@ -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