Adapted to new audio_features response

This commit is contained in:
Paul Lamere
2016-02-17 09:18:06 -05:00
parent 38ea4b6910
commit 9c0b872e86
2 changed files with 25 additions and 1 deletions

View File

@@ -633,7 +633,13 @@ class Spotify(object):
- tracks - a list of track URIs, URLs or IDs, maximum: 50 ids
'''
tlist = [self._get_id('track', t) for t in tracks]
return self._get('audio-features?ids=' + ','.join(tlist))
results = self._get('audio-features?ids=' + ','.join(tlist))
# the response has changed, look for the new style first, and if
# its not there, fallback on the old style
if 'audio_attributes' in results:
return results['audio_attributes']
else:
return results
def _get_id(self, type, id):
fields = id.split(':')