Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions beetsplug/subsonicupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,24 @@ def start_scan(self):
params=payload,
timeout=10,
)
json = response.json()

if (
response.status_code == 200
and json["subsonic-response"]["status"] == "ok"
):
count = json["subsonic-response"]["scanStatus"]["count"]
self._log.info("Updating Subsonic; scanning {} tracks", count)
elif (
response.status_code == 200
and json["subsonic-response"]["status"] == "failed"
):
response.raise_for_status()
try:
json = response.json()
except ValueError:
self._log.error(
"Error: {[subsonic-response][error][message]}", json
"Invalid JSON from Subsonic: {}", response.text[:200]
)
return
if not (resp := json.get("subsonic-response")):
self._log.error("Missing 'subsonic-response' field: {}", json)
return
status = resp.get("status")
if status == "ok":
count = resp.get("scanStatus", {}).get("count", 0)
self._log.info("Updating Subsonic; scanning {} tracks", count)
elif status == "failed":
msg = resp.get("error", {}).get("message", "Unknown error")
self._log.error("Error: {}", msg)
else:
self._log.error("Error: {}", json)
except Exception as error:
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ New features:

Bug fixes:

- :doc:`plugins/subsonicupdate`: Improve error messages when the Subsonic server
is unavailable or returns invalid JSON. Previously, failures were cryptic
(for instance, "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
expressions now skip self-references during evaluation to avoid infinite
Expand Down