joeyy-watts / SpotifyWLED

A script to listen to the currently playing track on your Spotify account and forward it to a WLED (https://github.com/Aircoookie/WLED) LED matrix with support for animations.
2 stars 0 forks source link

Improve image update time on track skip (without decreasing polling interval) #3

Closed joeyy-watts closed 10 months ago

joeyy-watts commented 1 year ago

If track ends by it self, the script will instantaneously switch cover already. But it is not handled when the track is skip; hence we'll still resort to the polling period, which can sometimes lead to long period before the image is updated when a track is skipped.

joeyy-watts commented 1 year ago

I'm not sure what the exact rate limit on the Spotify API is; I was only able to find that the limit is in a 30-second rolling window (https://developer.spotify.com/documentation/web-api/concepts/rate-limits).

So the current default for polling interval is 10 seconds to be conservative.

Although it seems reasonable to just decrease the polling interval to just ~3-5 seconds or something; the update delay wouldn't be too long and the number of requests isn't ridiculous.

joeyy-watts commented 10 months ago

Considering using WebSocket: https://github.com/lrholmes/spotify-connect-ws

(still uses polling, but this way I can remove the polling code)

Additional ref: https://github.com/spotify/web-api/issues/492

joeyy-watts commented 10 months ago

2 second polling interval is pretty much stable and doesn't cause much issue, so closing this issue until a better option is available.