Added api to get current users followed artists

This commit is contained in:
Paul Lamere 2015-08-10 09:17:14 -04:00
parent 10cf88da90
commit 329ef5722b
2 changed files with 16 additions and 0 deletions

View File

@ -486,6 +486,16 @@ class Spotify(object):
'''
return self._get('me/tracks', limit=limit, offset=offset)
def current_user_followed_artists(self, limit=20, after=None):
''' Gets a list of the artists followed by the current authorized user
Parameters:
- limit - the number of tracks to return
- after - ghe last artist ID retrieved from the previous request
'''
return self._get('me/following', type='artist', limit=limit, after=after)
def current_user_saved_tracks_delete(self, tracks=[]):
''' Remove one or more tracks from the current user's
"Your Music" library.

View File

@ -105,6 +105,11 @@ class AuthTestSpotipy(unittest.TestCase):
response = spotify.featured_playlists()
self.assertTrue(len(response['playlists']) > 0)
def test_current_user_follows(self):
response = spotify.current_user_followed_artists()
artists = response['artists']
self.assertTrue(len(artists['items']) > 0)
def get_or_create_spotify_playlist(self, username, playlist_name):
playlists = spotify.user_playlists(username)
while playlists:
@ -161,6 +166,7 @@ if __name__ == '__main__':
scope = 'playlist-modify-public '
scope += 'user-library-read '
scope += 'user-follow-read '
scope += 'user-library-modify '
scope += 'user-read-private'