[flickr] handle non-JSON errors (#5131)

This commit is contained in:
Mike Fährmann
2024-02-06 21:22:10 +01:00
parent 90ac6d7375
commit 6e928300bc

View File

@@ -386,7 +386,11 @@ class FlickrAPI(oauth.OAuth1API):
params["nojsoncallback"] = "1" params["nojsoncallback"] = "1"
if self.api_key: if self.api_key:
params["api_key"] = self.api_key params["api_key"] = self.api_key
data = self.request(self.API_URL, params=params).json() response = self.request(self.API_URL, params=params)
try:
data = response.json()
except ValueError:
data = {"code": -1, "message": response.content}
if "code" in data: if "code" in data:
msg = data.get("message") msg = data.get("message")
self.log.debug("Server response: %s", data) self.log.debug("Server response: %s", data)