This basic script will authenticate with your Spotify account and retrieve the most recently saved songs. An audio summary (if available) will be retrieved from Echonest using the Spotify URI for each track.
The purpose of this is to provide data to work with locally to run analysis.
psycopg2
- PostgreSQL Pythonspotipy
- Python Spotify Wrapperpyechonest
- Python Echonest Wrapper
pip install psycopg2 spotipy pyechonest
# CREATE USER owner WITH PASSWORD 'h4ck3r';
# CREATE DATABASE spotifyechonest OWNER owner;
# \list
# \connect spotifyechonest
# \dt
export SPOTIPY_CLIENT_ID='your-spotify-client-id'
export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
export SPOTIPY_REDIRECT_URI='http://localhost'
export ECHO_NEST_API_KEY='your-echonest-api-key'
python main.py <spotify-username> <offset> <limit>
spotify-username
(required): Spotify Username to retrieve saved track data (must have access to this account)offset
(optional): what index in the saved track list to start atlimit
(optional): total number of tracks to retrieve audio summary
- Spotify Authentication will open in your default browser
- Grant Access
- Copy the URL to the terminal when prompted (contains the Spotify code)
- The
tracks
table in thespotifyechonest
database will contain the data