Ex. www.spotontrack.com/playlists
In the API documentation, there is a followers
object with a total
key, yet this code:
client_credentials_manager = SpotifyClientCredentials()
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
name = "rock"
results = sp.search(q='playlist:' + name,limit=10, type='playlist')
for playlist in results['playlists']['items']:
print playlist['name'] + ' - ' + playlist['owner']['href'] + ' - ' + playlist['followers']['total']
(which works fine when playlist['followers']['total']
is commented out), returns this:
Traceback (most recent call last):
File "spotify.py", line 18, in <module>
print playlist['name'] + ' - ' + playlist['owner']['href'] + ' - ' + playlist['followers']['total']
KeyError: 'followers'
Where am I going wrong? Given the example I linked, it's apparently possible (the SpotOnTrack site footer says all information is retrieved through the API).. yet in the full results set, there is no follower total count (only total tracks) returned.
Any advice / assistance is appreciated.
EDIT: Running into the same problem with PHP (using spotify-php-web-api)
$results = $api->search('rock','playlist');
foreach ($results->playlists->items as $playlist) {
echo $playlist->name .' - '. $playlist->owner->external_urls->spotify ." - ". $playlist->followers->total ."<br />";
}
Throws:
Notice: Undefined property: stdClass::$followers in /Applications/XAMPP/xamppfiles/htdocs/spotify-web-api-php-master/test.php on line 26
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/spotify-web-api-php-master/test.php on line 26
This also fails using $api->getCategoryPlaylists()
with the same error.