From 62565e0887341d408c0e649407d9b9aac9d566de Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 25 Apr 2021 00:45:20 +0100 Subject: [PATCH] Fix loading shows due to myradio caching. --- helpers/myradio_api.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/helpers/myradio_api.py b/helpers/myradio_api.py index 8fb331f..aa1ba45 100644 --- a/helpers/myradio_api.py +++ b/helpers/myradio_api.py @@ -183,7 +183,21 @@ class MyRadioAPI: self._logException("Failed to get show plan.") return None - return json.loads(await request)["payload"] + payload = json.loads(await request)["payload"] + + plan = {} + + # Account for MyRadio api being dumb depending on if it's cached or not. + if isinstance(payload, list): + for channel in range(len(payload)): + plan[str(channel)] = payload[channel] + return plan + elif isinstance(payload, dict): + return payload + + self.logger.log.error("Show plan in unknown format.") + return None + # Audio Library