01-31-2024, 11:48 PM
(01-31-2024, 11:15 PM)Tim Curtis Wrote: Seems like thats the only way to do it other than their WebAPI but thats not compatible with Open Source license.
It would prolly break if they change the DOM for that website.
In any case here's an overall approach
- Spotify event script writes trackID to /tmp file
- PHP daemon polls the file for change in trackID (or use inotify in a BASH daemon)
---- If changed, scrape the website and cache the data somewhere
---- Send a message + data to the front-end via sendEngCmd()
- Front end receives the message + data and updates the WebUI (only for chromium/local display) with new metadata from the cache
- If page is refreshed re-load metadata from cache into WebUI
Something like that.
Yes, that's the way I had in mind (without the details about sending the results to the UI).
A big difference, though:
There is no need to scrape the log, as librespot invokes the spotify script in non-blocking manner at every track change event, and passes over the track ID.
ATM such script exists straight away if the event is neither START nor STOP (used only to stop/start MPD).
We can add another one, or two events (need some investigation / testing to find out the most suitable) and then invoke (or inline the code, FWIW) the data retrieval and update the UI.
Thing is, I do not have a Spotify premium account that allows me to -connect to moOde and use librespot, IOW I cannot test its full functionality...
This is why I asked @cogitech to do some tests: playing tracks, skip tracks, select other tracks from a playlist and so on, with a modified script that added logs, in order to see what is getting called, how many times upon a (automatic vs manual) track change, etc. etc.
Ah, then also modify the script to prepare a json object, rather than just print its finds...