我对 python 语法不是 100% 确定(对不起,如果它不是很正确),但你能在你的本地spotipy/client.py
文件中添加一个额外的方法吗?这将非常相似,user_playlist/user_playlist_tracks
但会绕过对用户 ID 的需求。
所以,像:
def user_playlist_custom(self, playlist_id=None, fields=None):
""" Gets playlist of a user
Parameters:
- playlist_id - the id of the playlist
- fields - which fields to return
"""
plid = self._get_id('playlist', playlist_id)
return self._get("playlists/%s" % (plid), fields=fields)
或者只是曲目:
def user_playlist_tracks_custom(self, playlist_id=None, fields=None,
limit=100, offset=0, market=None):
""" Get full details of the tracks of a playlist owned by a user.
Parameters:
- 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
- market - an ISO 3166-1 alpha-2 country code.
"""
plid = self._get_id('playlist', playlist_id)
return self._get("playlists/%s/tracks" % (plid),
limit=limit, offset=offset, fields=fields,
market=market)