Simplifies subsonicupdate JSON handling and updated changelog

This commit is contained in:
Jaslin 2025-12-05 00:24:47 -05:00
parent a81456a12c
commit 51be7be0b0
2 changed files with 6 additions and 6 deletions

View file

@ -138,6 +138,7 @@ class SubsonicUpdate(BeetsPlugin):
params=payload, params=payload,
timeout=10, timeout=10,
) )
response.raise_for_status()
try: try:
json = response.json() json = response.json()
except ValueError: except ValueError:
@ -145,15 +146,14 @@ class SubsonicUpdate(BeetsPlugin):
"Invalid JSON from Subsonic: {}", response.text[:200] "Invalid JSON from Subsonic: {}", response.text[:200]
) )
return return
resp = json.get("subsonic-response") if not (resp := json.get("subsonic-response")):
if not resp:
self._log.error("Missing 'subsonic-response' field: {}", json) self._log.error("Missing 'subsonic-response' field: {}", json)
return return
status = resp.get("status") status = resp.get("status")
if response.status_code == 200 and status == "ok": if status == "ok":
count = resp.get("scanStatus", {}).get("count", 0) count = resp.get("scanStatus", {}).get("count", 0)
self._log.info("Updating Subsonic; scanning {} tracks", count) self._log.info("Updating Subsonic; scanning {} tracks", count)
elif response.status_code == 200 and status == "failed": elif status == "failed":
msg = resp.get("error", {}).get("message", "Unknown error") msg = resp.get("error", {}).get("message", "Unknown error")
self._log.error("Error: {}", msg) self._log.error("Error: {}", msg)
else: else:

View file

@ -34,7 +34,7 @@ New features:
Bug fixes: Bug fixes:
- :doc:`plugins/subsonicupdate`: Improve error messages when the Subsonic server - :doc:`plugins/subsonicupdate`: Improve error messages when the Subsonic server
is unavailable or returns invalid/missing JSON. Previously, failures were is unavailable or returns invalid or missing JSON. Previously, failures were
cryptic (e.g., "Expecting value: line 1 column 1 (char 0)"). :bug:`5635` cryptic (e.g., "Expecting value: line 1 column 1 (char 0)"). :bug:`5635`
- :doc:`plugins/inline`: Fix recursion error when an inline field definition - :doc:`plugins/inline`: Fix recursion error when an inline field definition
shadows a built-in item field (e.g., redefining ``track_no``). Inline shadows a built-in item field (e.g., redefining ``track_no``). Inline