I'm trying to understand how to decode a file that Spotify leaves on my system.
The file in question is called context_player_state_restore and lives in /Users/<myuser>/Library/Application Support/Spotify/PersistentCache/, so obviously the expectation is that its structure (and now encoding likely) can change without warning.
The Spotify app updates that file at regular time intervals with the currently playing song, the current context (e.g. currently playing playlist), and some other useful stuff like the history of played tracks.
I want to parse the information in that file for an app I'm building. (I can use the Spotify API for some of this data, but the local file contains more useful information, is immediate (no delay in API calls), and I can react to any changes on it).
Until recently that file was an UTF-8 JSON file and could be parsed with JSON.parse(data).
Recently however, Spotify has changed that JSON / UTF-8 encoding.
Currently, opening that file with vscode (with UTF-8 encoding) gives back some legible text, indicating that some of the JSON structure has been kept, but also shows a lot of illegible text – the odd question mark symbols �� and various UTF characters that don't belong e.g. Ω.
In short, I'd like to understand:
- whether I can find out what encoding Spotify is now using for this file
- and whether it is possible to decode the file back to JSON (or a similar format) so it can be easily parsed
Gist link to file dump as seen by vscode
Gist link to hexdump of file (obtained with hexdump -C context_player_state_restore > context_player_state_restore.hexdump)