rewrite pending; for now, additional support for multi-station
This commit is contained in:
@@ -115,7 +115,7 @@ class Misc(FastAPI):
|
||||
with open(fallback_path, "rb") as f:
|
||||
return Response(content=f.read(), media_type="image/png")
|
||||
|
||||
async def get_radio_np(self) -> tuple[str, str, str]:
|
||||
async def get_radio_np(self, station: str = "main") -> tuple[str, str, str]:
|
||||
"""
|
||||
Get radio now playing
|
||||
Args:
|
||||
@@ -124,13 +124,13 @@ class Misc(FastAPI):
|
||||
str: Radio now playing in artist - song format
|
||||
"""
|
||||
|
||||
np: dict = self.radio.radio_util.now_playing
|
||||
np: dict = self.radio.radio_util.now_playing[station]
|
||||
artistsong: str = "N/A - N/A"
|
||||
artist = np.get("artist")
|
||||
song = np.get("song")
|
||||
if artist and song:
|
||||
artistsong = f"{artist} - {song}"
|
||||
|
||||
|
||||
album: str = np.get("album", "N/A")
|
||||
genre: str = np.get("genre", "N/A")
|
||||
return (artistsong, album, genre)
|
||||
@@ -194,11 +194,11 @@ class Misc(FastAPI):
|
||||
)
|
||||
return JSONResponse(content=found_counts)
|
||||
|
||||
async def homepage_radio_widget(self) -> JSONResponse:
|
||||
async def homepage_radio_widget(self, station: str = "main") -> JSONResponse:
|
||||
"""
|
||||
Homepage Radio Widget Handler
|
||||
"""
|
||||
radio_np: tuple = await self.get_radio_np()
|
||||
radio_np: tuple = await self.get_radio_np(station)
|
||||
if not radio_np:
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
|
Reference in New Issue
Block a user