My endgame is to build a webapp that can log a user into their Spotify account, allow them to select a playlist to work with, and
python3, atom
$ sudo pip install spotipy
Go to developer.spotify.com/dashboard
Dashboard -> create app
Application Name, Description, Agree to terms
Edit Settings: Set a Redirect URI WHY?
Save Client ID and Secret
Erase cache and prompt for user permission WHY?
try:
token = spotipy.util.prompt_for_user_token(username)
except:
os.remove(f".cache-{username}")
token = util.prompt_for_user_token(username)
Create Spotify Object
spotify_object = spotipy.Spotify(auth=token)
Print JSON data
print(json.dumps(VARIABLE, sort_keys=True, indent=4))
Create some terminal variables
$ export SPOTIPY_CLIENT_ID='<spotify app Client ID>'
$ export SPOTIPY_CLIENT_SECRET='<spotify app Client Secret>'
$ export SPOTIPY_REDIRECT_URI='<spotify app redirect uri>'
(These have to be exported again when the terminal is restarted... would we want to save them permanently? Probably something to do in a Heroku Procfile.)
Now explore the track files... there are 100 tracks per file, and the files are named Zoukables0.pkl, Zoukables1.pkl, etc
Figure out what useful metadata is in this dataset. Next, find out how to look up audio features for the track and pull more useful metadata from there. Finally, pull the metadata for each track in the playlist, format it, and insert it into a database.
import pickle
with open('Zoukables0.pkl', 'rb') as zpkl:
tracks = pickle.load(zpkl)
tracks.keys()
tracks['items'][0].keys()
tracks['items'][0]['track'].keys()
spotipy.readthedocs.io
github.com/plamere/spotipy