radio widget changes
This commit is contained in:
@ -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,
|
||||
})
|
Reference in New Issue
Block a user