mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 04:22:40 +01:00
Fix Issue #5635: improve SubsonicUpdate error messages when server is unavailable
This commit is contained in:
parent
2bd77b9895
commit
30cd320237
1 changed files with 15 additions and 6 deletions
|
|
@ -138,20 +138,29 @@ class SubsonicUpdate(BeetsPlugin):
|
|||
params=payload,
|
||||
timeout=10,
|
||||
)
|
||||
json = response.json()
|
||||
|
||||
try:
|
||||
json = response.json()
|
||||
except ValueError:
|
||||
self._log.error("Invalid JSON from Subsonic: {}", response.text[:200])
|
||||
return
|
||||
resp = json.get("subsonic-response")
|
||||
if not resp:
|
||||
self._log.error("Missing 'subsonic-response' field: {}", json)
|
||||
return
|
||||
status = resp.get("status")
|
||||
if (
|
||||
response.status_code == 200
|
||||
and json["subsonic-response"]["status"] == "ok"
|
||||
and status == "ok"
|
||||
):
|
||||
count = json["subsonic-response"]["scanStatus"]["count"]
|
||||
count = resp.get("scanStatus", {}).get("count", 0)
|
||||
self._log.info("Updating Subsonic; scanning {} tracks", count)
|
||||
elif (
|
||||
response.status_code == 200
|
||||
and json["subsonic-response"]["status"] == "failed"
|
||||
and status == "failed"
|
||||
):
|
||||
msg = resp.get("error", {}).get("message", "Unknown error")
|
||||
self._log.error(
|
||||
"Error: {[subsonic-response][error][message]}", json
|
||||
"Error: {}", msg
|
||||
)
|
||||
else:
|
||||
self._log.error("Error: {}", json)
|
||||
|
|
|
|||
Loading…
Reference in a new issue