I need to keep a database up-to-date with a playlist’s contents.
I am using the C# Wrapper for the libspotify api – http://libspotify-sharp.hallerud.se/
My work flow is as follows at present
Login, wait for playlist container to load, when loaded listen for playlist loaded events, when the playlist I am interested in is loaded wait for all the tracks on the playlist to have loaded, then write the contents to the db.
I am completely clearing the cache directory everytime the program starts.
I am finding this works fine and as expected most of the time, then when deleting some of the tracks within the normal spotify client, that the tracks still seem to get returned by the api even though they are no longer there (I am clearing the cache directory so they must be?).
Does anyone know what could cause this?
UPDATE
What I am finding is that the API seems to return different information to what is viewable in the client. I have run the console app from different computers and the tracks which have been removed are still being returned. The normal spotify client does not show these, also tested on multiple computers. In my app I login, wait for the playlists to have loaded fully and then exit, this app is on a scheduled task.
UPDATE 2
I am currently waiting until
(playlist.IsLoaded == true &&
playlist.CurrentTracks.All(x => x.IsLoaded && x.Artists.Count() > 0))
using
session.OnMetaDataUpdated += HandleOnMetaUpdated;
and
playlist.OnMetadataUpdated += PlaylistMetaUpdated;
If the playlist backend is running slowly, it can take a little while for changes made in the client to make it to the Spotify backend. Only once they’re in the backend will the changes make it down to other clients.