From 51be7be0b00876e2df8587b8142f5a1e6fc5c489 Mon Sep 17 00:00:00 2001 From: Jaslin Date: Fri, 5 Dec 2025 00:24:47 -0500 Subject: [PATCH] Simplifies subsonicupdate JSON handling and updated changelog --- beetsplug/subsonicupdate.py | 8 ++++---- docs/changelog.rst | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/beetsplug/subsonicupdate.py b/beetsplug/subsonicupdate.py index ace5546f4..8a4423782 100644 --- a/beetsplug/subsonicupdate.py +++ b/beetsplug/subsonicupdate.py @@ -138,6 +138,7 @@ class SubsonicUpdate(BeetsPlugin): params=payload, timeout=10, ) + response.raise_for_status() try: json = response.json() except ValueError: @@ -145,15 +146,14 @@ class SubsonicUpdate(BeetsPlugin): "Invalid JSON from Subsonic: {}", response.text[:200] ) return - resp = json.get("subsonic-response") - if not resp: + if not (resp := json.get("subsonic-response")): self._log.error("Missing 'subsonic-response' field: {}", json) return status = resp.get("status") - if response.status_code == 200 and status == "ok": + if status == "ok": count = resp.get("scanStatus", {}).get("count", 0) 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") self._log.error("Error: {}", msg) else: diff --git a/docs/changelog.rst b/docs/changelog.rst index 82783ce0d..d3234e9a3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -33,8 +33,8 @@ New features: resolve differences in metadata source styles. Bug fixes: -- :doc:`plugins/subsonicupdate`: Improve error messages when the Subsonic server - is unavailable or returns invalid/missing JSON. Previously, failures were +- :doc:`plugins/subsonicupdate`: Improve error messages when the Subsonic server + is unavailable or returns invalid or missing JSON. Previously, failures were cryptic (e.g., "Expecting value: line 1 column 1 (char 0)"). :bug:`5635` - :doc:`plugins/inline`: Fix recursion error when an inline field definition shadows a built-in item field (e.g., redefining ``track_no``). Inline