2

All playlists that I have checked so far has returned 0 subscribers. Am I doing something wrong? Do you need special rights to do this? I am using cocoalibspotify 2.2.0.

Here's the code:

playlistURL = [NSURL URLWithString:@"spotify:user:tunigo:playlist:14KrfXbVeyzVek6UX8jUlH"];
NSLog(@"%@", playlistURL);
[[SPSession sharedSession] playlistForURL:playlistURL callback:^(SPPlaylist *playlist){
    if (playlist != nil) {

        [SPAsyncLoading waitUntilLoaded:playlist timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedPlaylists, NSArray *notLoadedTracks) {

            NSLog(@"Nr of subscribers: %d", [playlist.subscribers count]);
            NSLog(@"========================");
        }];
    }
}];

Outputs this:

spotify:user:tunigo:playlist:14KrfXbVeyzVek6UX8jUlH
Playlist name: Dinner with Friends
Nr of subscribers: 0
========================
pierrovic
  • 338
  • 4
  • 6

1 Answers1

1

Since updating subscribers can be quite a lengthy task, it looks like SPPlaylist starts updating them once it's loaded, i.e., after SPAsyncLoading returns.

However, the subscribers property is KVO-compliant so you should be able to observe the subscribers property for changes.

iKenndac
  • 18,730
  • 3
  • 35
  • 51
  • In addition, make sure you grab the latest HEAD of the dev branch of CocoaLibSpotify - I just saw and fixed something related. My answer still stands, though. – iKenndac Oct 03 '12 at 15:04
  • The subscribers array isn't changing after being loaded. I observed it both with the "KVO-pattern" and manually (by checking its count when pressing a button) and after three minutes it still had zero items in it. I'll grab the latest HEAD and see if it does the trick. – pierrovic Oct 04 '12 at 08:29
  • There seem to have been only one commit after the 2.2.0 tag and that commit is mainly NSLogs. I tried it anyway but it didn't help. Do you have any more suggestions? FYI, my reason for doing this is to find out if the user is subscribing to a certain list. I eventually did that by checking the userPlaylists property of the SPSession object instead so I'm on my way. Still interested in the solution to this problem though. – pierrovic Oct 04 '12 at 08:47
  • Right, the dev commits did make a difference. The example above still returns 0 but after a while the number of subscribers is 500. Is that a limit set in the API because the list has 2994 subscribers according to the Spotify Mac desktop app? – pierrovic Oct 04 '12 at 13:01
  • Correct. If you look through the actual subscriber list itself in the Mac client, it'll probably also be limited to 500 entries. The number is a separate property (and one not available in CocoaLibSpotify at the moment). – iKenndac Oct 04 '12 at 14:43
  • Ok, looking forward to it in later releases then. Thanks for your help! – pierrovic Oct 05 '12 at 09:34