Fix failing to return when no shows.

This commit is contained in:
Matthew Stratford 2021-08-16 23:29:58 +01:00
parent 8d98410a6a
commit b90330ff57

View file

@ -156,23 +156,22 @@ class MyRadioAPI:
payload = json.loads(await request)["payload"] payload = json.loads(await request)["payload"]
shows = []
if not payload["current"]: if not payload["current"]:
self._logException("API did not return a current show.") self._logException("API did not return a current show.")
else:
shows.append(payload["current"])
if not payload["next"]: if not payload["next"]:
self._logException("API did not return a list of next shows.") self._logException("API did not return a list of next shows.")
else:
shows.extend(payload["next"])
shows = []
shows.append(payload["current"])
shows.extend(payload["next"])
timeslots = []
# Remove jukebox etc # Remove jukebox etc
for show in shows: for show in shows:
if not "timeslot_id" in show: if not "timeslot_id" in show:
shows.remove(show) shows.remove(show)
# TODO filter out jukebox
return shows return shows
async def get_showplan(self, timeslotid: int): async def get_showplan(self, timeslotid: int):