BimmerGestalt / AAIdrive

Implementations of some Android Auto features as unofficial IDrive apps
MIT License
527 stars 89 forks source link

Spotify Web API memoization #434

Open hufman opened 2 years ago

hufman commented 2 years ago

The Spotify Web API is used by some of the new features, and it would be nifty to add a little bit of memoization to reduce the API call count. image

hufman commented 2 years ago

SpotifyWebApi's SpotifyApiOptions has useCache=true by default, hmmmm

NavjotPanesar commented 2 years ago

Did we ever get around to this? If not, I'd be interested to know which exact API call we're seeing a lot of so I can take a stab at this.

hufman commented 2 years ago

image

The biggest API calls currently are /v1/me/tracks and /v1/playlists/<>/tracks. All of the API accesses should be within the SpotifyWebApi class, probably webApi?.library?.getSavedTracks and webApi?.playlists?.getPlaylistTracks. I'm not sure if there's a cheap way to check the current version of the playlist to invalidate any cache, or perhaps just cheat a little and assume the playlist stays the same between app restarts as long as the context url stays the same.