From 329ef5722be9cbc732ccf49ebc7bb30e0aeaf6de Mon Sep 17 00:00:00 2001 From: Paul Lamere Date: Mon, 10 Aug 2015 09:17:14 -0400 Subject: [PATCH] Added api to get current users followed artists --- spotipy/client.py | 10 ++++++++++ tests/authtests.py | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/spotipy/client.py b/spotipy/client.py index 5eb8f16..da37602 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -485,6 +485,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 diff --git a/tests/authtests.py b/tests/authtests.py index b5c7f00..a28ad5b 100644 --- a/tests/authtests.py +++ b/tests/authtests.py @@ -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'