misc
This commit is contained in:
@ -157,8 +157,13 @@ class LastFM(FastAPI):
|
||||
'errorText': 'Invalid request'
|
||||
})
|
||||
|
||||
track_info_result: dict = await self.lastfm.get_track_info(artist=artist,
|
||||
track_info_result: Optional[dict] = await self.lastfm.get_track_info(artist=artist,
|
||||
track=track)
|
||||
if not track_info_result:
|
||||
return JSONResponse(status_code=500, content={
|
||||
'err': True,
|
||||
'errorText': 'Not found.',
|
||||
})
|
||||
if "err" in track_info_result:
|
||||
raise LastFMException("Unknown error occurred: %s",
|
||||
track_info_result.get('errorText', '??'))
|
||||
|
@ -72,8 +72,9 @@ class RadioUtil:
|
||||
async with sqlite3.connect(self.active_playlist_path,
|
||||
timeout=1) as _db:
|
||||
_db.row_factory = sqlite3.Row
|
||||
db_query: str = 'SELECT DISTINCT(LOWER(TRIM(artist) || " - " || TRIM(song))) as artistsong FROM tracks WHERE\
|
||||
artistsong LIKE ? LIMIT 30'
|
||||
db_query: str = """SELECT DISTINCT(LOWER(TRIM(artist) || " - " || TRIM(song))),\
|
||||
(TRIM(artist) || " - " || TRIM(song)) as artistsong FROM tracks WHERE\
|
||||
artistsong LIKE ? LIMIT 30"""
|
||||
db_params: tuple[str] = (f"%{query}%",)
|
||||
async with _db.execute(db_query, db_params) as _cursor:
|
||||
result: Iterable[sqlite3.Row] = await _cursor.fetchall()
|
||||
@ -150,7 +151,7 @@ class RadioUtil:
|
||||
LIMITED GENRES
|
||||
"""
|
||||
|
||||
db_query: str = """SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))) AS artistdashsong, id, artist, song, genre, file_path, duration FROM tracks\
|
||||
db_query: str = """SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song)) AS artistdashsong, id, artist, song, genre, file_path, duration FROM tracks\
|
||||
WHERE genre LIKE "%metalcore%"\
|
||||
OR genre LIKE "%rock%"\
|
||||
OR genre LIKE "%pop punk%"\
|
||||
@ -182,7 +183,9 @@ class RadioUtil:
|
||||
OR genre LIKE "%hardcore punk%"\
|
||||
OR genre LIKE "%synthwave%"\
|
||||
OR genre LIKE "%trap%"\
|
||||
OR genre LIKE "%indie pop%" GROUP BY artistdashsong ORDER BY RANDOM()"""
|
||||
OR genre LIKE "%indie pop%"\
|
||||
OR genre LIKE "untagged"\
|
||||
GROUP BY artistdashsong ORDER BY RANDOM()"""
|
||||
|
||||
"""
|
||||
LIMITED TO ONE ARTIST...
|
||||
@ -333,7 +336,7 @@ class RadioUtil:
|
||||
"description": f'## {track['song']}\nby\n## {track['artist']}',
|
||||
"color": 0x30c56f,
|
||||
"thumbnail": {
|
||||
"url": f"https://api.codey.lol/radio/album_art?track_id={track['id']}&{time.time()}",
|
||||
"url": f"https://api.codey.lol/radio/album_art?track_id={track['id']}&{int(time.time())}",
|
||||
},
|
||||
"fields": [
|
||||
{
|
||||
|
Reference in New Issue
Block a user