radio widget changes
This commit is contained in:
parent
e30ae2460d
commit
796c8cd913
@ -69,7 +69,7 @@ class Misc(FastAPI):
|
||||
return Response(content=f.read(),
|
||||
media_type="image/png")
|
||||
|
||||
async def get_radio_np(self) -> str:
|
||||
async def get_radio_np(self) -> tuple[str, str, str]:
|
||||
"""
|
||||
Get radio now playing
|
||||
Args:
|
||||
@ -78,10 +78,11 @@ class Misc(FastAPI):
|
||||
str: Radio now playing in artist - song format
|
||||
"""
|
||||
|
||||
artistsong: Optional[str] = self.radio.radio_util.now_playing['artistsong']
|
||||
if not isinstance(artistsong, str):
|
||||
return "N/A - N/A"
|
||||
return artistsong
|
||||
np: dict = self.radio.radio_util.now_playing
|
||||
artistsong: str = np.get('artistsong', 'N/A - N/A')
|
||||
album: str = np.get('album', 'N/A')
|
||||
genre: str = np.get('genre', 'N/A')
|
||||
return (artistsong, album, genre)
|
||||
|
||||
|
||||
async def homepage_redis_widget(self) -> JSONResponse:
|
||||
@ -137,12 +138,15 @@ class Misc(FastAPI):
|
||||
"""
|
||||
Homepage Radio Widget Handler
|
||||
"""
|
||||
radio_np: str = await self.get_radio_np()
|
||||
radio_np: tuple = await self.get_radio_np()
|
||||
if not radio_np:
|
||||
return JSONResponse(status_code=500, content={
|
||||
'err': True,
|
||||
'errorText': 'General failure.',
|
||||
})
|
||||
(artistsong, album, genre) = radio_np
|
||||
return JSONResponse(content={
|
||||
'now_playing': await self.get_radio_np(),
|
||||
'now_playing': artistsong,
|
||||
'album': album,
|
||||
'genre': genre,
|
||||
})
|
@ -147,7 +147,7 @@ class RadioUtil:
|
||||
"""
|
||||
|
||||
db_query: str = """SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song)) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
|
||||
WHERE id >= 74284 AND (genre LIKE "%metalcore%"\
|
||||
WHERE id >= 67166 AND (genre LIKE "%metalcore%"\
|
||||
OR genre LIKE "%rock%"\
|
||||
OR genre LIKE "%pop punk%"\
|
||||
OR genre LIKE "%math rock%"\
|
||||
@ -187,14 +187,14 @@ class RadioUtil:
|
||||
"""
|
||||
|
||||
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
|
||||
# WHERE genre like "%edm%" OR genre LIKE "%electronic%"'
|
||||
# WHERE genre like "%hip hop%" OR genre LIKE "%rap%" OR genre LIKE "%edm%" OR genre LIKE "%trap%"'
|
||||
|
||||
"""
|
||||
LIMITED TO ONE/SOME ARTISTS...
|
||||
"""
|
||||
|
||||
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
|
||||
# WHERE (artist LIKE "%lmfao%" OR artist LIKE "%fire from the gods%" OR artist LIKE "%nothing, nowhere%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%%live%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()'
|
||||
# WHERE (artist LIKE "%more of myself to kill%" OR artist LIKE "%tethered%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY artist DESC, album DESC, id ASC'
|
||||
|
||||
async with sqlite3.connect(self.active_playlist_path,
|
||||
timeout=2) as db_conn:
|
||||
|
Loading…
x
Reference in New Issue
Block a user