2
votes

I cannot seem to reliably fetch the subscriberCount for playlists using the Spotify Apps API. It will nearly always return zero, unless I manually view the playlist before making the API call.

Is there any way to programmatically 'browse' to a playlist, so that it loads the subscriber count? Unfortunately sp.core.browseUri does not work for playlists.

I also attempted the same with libspotify and seemed to get the same problem. Am I doing something wrong? Is anyone able to reliably fetch playlist subscribers?

To Replciate:

var playlist = "spotify:user:crjunkin:playlist:3tNieyc7DFck9BEM2k0IDv";
m.Playlist.fromURI(playlist,function(pl){
    playlist =  pl;
    setTimeout("console.log('Waited: '+playlist.data.subscriberCount)",10000);
    playlist.observe(m.EVENT.CHANGE, function() {
        console.log("Changed: "+playlist.data.subscriberCount);
    });
    console.log(playlist);
    console.log(playlist.data.subscriberCount);
});
2

2 Answers

1
votes

Subscribers can take a while to load in both libspotify and the client. Make sure you're listening to the appropriate callbacks.

0
votes

I found this info like so, after much object inspection:

var plObj = sp.core.getPlaylist(playlistURI); 
console.log(plObj.subscriberCount);