Added playlist tracks method. Updated tests.

This commit is contained in:
Paul Lamere
2014-11-15 07:20:11 -05:00
parent 278b7d3005
commit 8adbfe6f6d
4 changed files with 48 additions and 7 deletions

View File

@@ -279,7 +279,6 @@ class Spotify(object):
def user_playlist(self, user, playlist_id = None, fields=None):
''' Gets playlist of a user
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
@@ -288,8 +287,22 @@ class Spotify(object):
if playlist_id == None:
return self._get("users/%s/starred" % (user), fields=fields)
plid = self._get_id('playlist', playlist_id)
return self._get("users/%s/playlists/%s" % (user, plid),
fields=fields)
return self._get("users/%s/playlists/%s" % (user, plid), fields=fields)
def user_playlist_tracks(self, user, playlist_id = None, fields=None,
limit=100, offset=0):
''' Get full details of the tracks of a playlist owned by a user.
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- fields - which fields to return
- limit - the maximum number of tracks to return
- offset - the index of the first track to return
'''
plid = self._get_id('playlist', playlist_id)
return self._get("users/%s/playlists/%s/tracks" % (user, plid),
limit=limit, offset=offset, fields=fields)
def user_playlist_create(self, user, name, public=True):
''' Creates a playlist for a user