Fix borked API, makes webstudio not white screen.
This commit is contained in:
parent
212f449e13
commit
2b2e77fb27
1 changed files with 19 additions and 14 deletions
|
@ -102,6 +102,7 @@ class MyRadioAPI:
|
|||
self._log("Requesting API V2 URL with method {}: {}".format(method, url))
|
||||
|
||||
request = None
|
||||
try:
|
||||
if method == "GET":
|
||||
request = await self.async_call(url, method="GET", timeout=timeout)
|
||||
elif method == "POST":
|
||||
|
@ -112,6 +113,10 @@ class MyRadioAPI:
|
|||
else:
|
||||
self._logException("Invalid API method. Request not sent.")
|
||||
return None
|
||||
except aiohttp.ClientError:
|
||||
self._logException("Failed async API request.")
|
||||
return None
|
||||
|
||||
self._log("Finished request.")
|
||||
|
||||
return request
|
||||
|
@ -291,7 +296,7 @@ class MyRadioAPI:
|
|||
|
||||
if not request or not isinstance(request, bytes):
|
||||
self._logException("Failed to retrieve music playlists.")
|
||||
return None
|
||||
return []
|
||||
|
||||
return json.loads(request)["payload"]
|
||||
|
||||
|
@ -302,7 +307,7 @@ class MyRadioAPI:
|
|||
|
||||
if not request or not isinstance(request, bytes):
|
||||
self._logException("Failed to retrieve music playlists.")
|
||||
return None
|
||||
return []
|
||||
|
||||
return json.loads(request)["payload"]
|
||||
|
||||
|
@ -319,7 +324,7 @@ class MyRadioAPI:
|
|||
self._logException(
|
||||
"Failed to retrieve items for aux playlist {}.".format(library_id)
|
||||
)
|
||||
return None
|
||||
return []
|
||||
|
||||
return json.loads(request)["payload"]
|
||||
|
||||
|
@ -333,7 +338,7 @@ class MyRadioAPI:
|
|||
self._logException(
|
||||
"Failed to retrieve items for music playlist {}.".format(library_id)
|
||||
)
|
||||
return None
|
||||
return []
|
||||
|
||||
return json.loads(request)["payload"]
|
||||
|
||||
|
@ -347,7 +352,7 @@ class MyRadioAPI:
|
|||
|
||||
if not request or not isinstance(request, bytes):
|
||||
self._logException("Failed to search for track.")
|
||||
return None
|
||||
return []
|
||||
|
||||
return json.loads(request)["payload"]
|
||||
|
||||
|
|
Loading…
Reference in a new issue