mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-05 07:27:47 +00:00
Merge pull request #138 from nyanfly/master
Add Audio Analysis Endpoint Support
This commit is contained in:
commit
6b774e9f48
@ -711,6 +711,14 @@ class Spotify(object):
|
|||||||
'''
|
'''
|
||||||
return self._get('recommendations/available-genre-seeds')
|
return self._get('recommendations/available-genre-seeds')
|
||||||
|
|
||||||
|
def audio_analysis(self, track_id):
|
||||||
|
''' Get audio analysis for a track based upon its Spotify ID
|
||||||
|
Parameters:
|
||||||
|
- track_id - a track URI, URL or ID
|
||||||
|
'''
|
||||||
|
trid = self._get_id('track', track_id)
|
||||||
|
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 multiple tracks based upon their Spotify IDs
|
||||||
Parameters:
|
Parameters:
|
||||||
|
@ -37,6 +37,10 @@ class AuthTestSpotipy(unittest.TestCase):
|
|||||||
bad_id = 'BAD_ID'
|
bad_id = 'BAD_ID'
|
||||||
|
|
||||||
|
|
||||||
|
def test_audio_analysis(self):
|
||||||
|
result = spotify.audio_analysis(self.four_tracks[0])
|
||||||
|
assert('beats' in result)
|
||||||
|
|
||||||
def test_audio_features(self):
|
def test_audio_features(self):
|
||||||
results = spotify.audio_features(self.four_tracks)
|
results = spotify.audio_features(self.four_tracks)
|
||||||
self.assertTrue(len(results) == len(self.four_tracks))
|
self.assertTrue(len(results) == len(self.four_tracks))
|
||||||
|
Loading…
Reference in New Issue
Block a user