mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-01-07 23:22:49 +00:00
Merge pull request #142 from Baschdl/audio-features_one-song
Audio features of one song
This commit is contained in:
commit
01d3e1097b
@ -812,12 +812,16 @@ class Spotify(object):
|
|||||||
return self._get('audio-analysis/' + trid)
|
return self._get('audio-analysis/' + trid)
|
||||||
|
|
||||||
def audio_features(self, tracks=[]):
|
def audio_features(self, tracks=[]):
|
||||||
''' Get audio features for multiple tracks based upon their Spotify IDs
|
''' Get audio features for one or multiple tracks based upon their Spotify IDs
|
||||||
Parameters:
|
Parameters:
|
||||||
- tracks - a list of track URIs, URLs or IDs, maximum: 50 ids
|
- tracks - a list of track URIs, URLs or IDs, maximum: 50 ids
|
||||||
'''
|
'''
|
||||||
tlist = [self._get_id('track', t) for t in tracks]
|
if isinstance(tracks, str):
|
||||||
results = self._get('audio-features?ids=' + ','.join(tlist))
|
trackid = self._get_id('track', tracks)
|
||||||
|
results = self._get('audio-features/?ids=' + trackid)
|
||||||
|
else:
|
||||||
|
tlist = [self._get_id('track', t) for t in tracks]
|
||||||
|
results = self._get('audio-features/?ids=' + ','.join(tlist))
|
||||||
# the response has changed, look for the new style first, and if
|
# the response has changed, look for the new style first, and if
|
||||||
# its not there, fallback on the old style
|
# its not there, fallback on the old style
|
||||||
if 'audio_features' in results:
|
if 'audio_features' in results:
|
||||||
|
Loading…
Reference in New Issue
Block a user