-
Notifications
You must be signed in to change notification settings - Fork 3
/
Getting_Audio_Data.py
27 lines (21 loc) · 945 Bytes
/
Getting_Audio_Data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
# Make your own Spotify app at https://beta.developer.spotify.com/dashboard/applications
client_id = '21f99642339d4aa5a5d9199bc60e8bf2'
client_secret = '578a8282d52541e1acc2087e024d8698'
uri = 'spotify:track:1V4TCSBKvHpDI41zh60d8J'
client_credentials_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret)
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
sp.trace=False
features = sp.audio_features(uri)
print ('Energy:', features[0]['energy'])
print ('Valence:', features[0]['valence'])
# birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'
# spotify = spotipy.Spotify()
# results = spotify.artist_albums(birdy_uri, album_type='album')
# albums = results['items']
# while results['next']:
# results = spotify.next(results)
# albums.extend(results['items'])
# for album in albums:
# print(album['name'])