mirror of
https://github.com/Aran404/SpotAPI.git
synced 2026-04-25 16:55:50 +03:00
[GH-ISSUE #28] Spotify change? Substring "correlationId":" not found in JSON string #16
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SpotAPI#16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @shillshocked on GitHub (Mar 29, 2025).
Original GitHub issue: https://github.com/Aran404/SpotAPI/issues/28
I've been getting errors with script functions that have worked for a long while. Got some insight on that from an AI:
I examined the source code in
GITHUB.COM
. In the get_session method, after fetching the Spotify homepage (https://open.spotify.com/), the code calls:
self.device_id = parse_json_string(resp.response, "correlationId")
This function (located in spotapi/utils/strings.py) searches for the substring "correlationId": in the response and raises a ValueError if it isn’t found. It appears that Spotify has likely changed its page structure so that this substring is no longer present in the response. That is why your script is failing with the error:
Substring "correlationId":" not found in JSON string
To resolve the issue, you can try one or more of the following approaches:
Patch the Parsing Logic:
Modify the parse_json_string() or adjust get_session in spotapi/client.py so it correctly extracts the needed device identifier from the current page response. For example, you might change the regex or add a fallback to handle the new structure.
Patch Example:
In spotapi/utils/strings.py, you might change:
raise ValueError(f'Substring "{s}":" not found in JSON string')
to something like:
if f'"{s}":' not in json_string:
print(f'Warning: "{s}" not found in JSON. Proceeding without it.')
return None # or some default value
Note that this is a temporary fix; a proper solution may require updating the library to align with Spotify’s current API.
Alternative Authentication Flow:
If the device ID isn’t strictly necessary for your use case, you might bypass that check or supply a default value.
@shillshocked commented on GitHub (Mar 29, 2025):
I was able to get it to continue to work (with warnings) using this updated code in strings.py:
@Leogendra commented on GitHub (Mar 31, 2025):
I'm providing a code example that reproduces the error:
Which gives the following error:
@Aran404 commented on GitHub (Apr 14, 2025):
Sorry, is this issue still relevant?