michaelherger / Spotty-Plugin

A Spotify plugin for the Lyrion Music Server (fka. Logitech Media Server) and Squeezebox compatible players
104 stars 20 forks source link

Clear rate limit cache if the client ID changes #124

Closed joshcomley closed 1 month ago

joshcomley commented 1 month ago

The rate limit cache locks out API requests until the timeout reported by Spotify has reached. However, this timeout can be very long (hours), and if the client ID used when the rate limit was reached has changed, we should be able to try again.

michaelherger commented 1 month ago

Thanks for this PR! It's addressing a valid issue. Alas, I think it could be handled more elegantly: you could register a setChange() handler to remove the spotty_rate_limit_exceeded flag whenever the client ID is changed. See eg. https://github.com/michaelherger/Spotty-Plugin/blob/master/Plugin.pm#L79 for how such a handler can be implemented.

joshcomley commented 1 month ago

Hi @michaelherger - no worries, thanks for the project!

Good idea, although I did like the fact that no matter how the client ID changes the call to the API would pick up on the change. Nevertheless, I've pushed an update - I've tested and it seems to work! I am VERY new to Perl, so forgive any mistakes :D