a spotify watchdog and database for likes ❤️ and track history ⏳.
create an app for the spotify Web API on your spotify developer dashboard
App Name: my spike app
App Description: watchdog for likes ❤️ and track history ⏳
Redirect URI: http://localhost:8888/callback
copy /backend/.env.example
file to /backend/.env
, add your client credentials (client ID and client secret), and define settings.
PORT=8888
CLIENT_ID="YOUR_SPOTIFY_CLIENT_ID"
CLIENT_SECRET="YOUR_SPOTIFY_CLIENT_SECRET"
LIKES_INTERVAL_S=60
HISTORY_INTERVAL_S=60
LIKES_LIMIT=10
HISTORY_LIMIT=10
# refetch all of `liked.json` and `playlists.json` on start
STARTUP_FETCH_ALL=true
cd backend
docker-compose up -d --build
cd backend
yarn
yarn dev
using pm2.
cd backend
pm2 start index.js --name "spike"
login & create auth token at http://localhost:8888/login
everything is stored locally.
the database lives as files in backend/db
.
auth.json
: persistent spotify api access tokensliked.json
: list of all saved tracksplaylists.json
: list of all playlistshistory.csv
: history of tracks since start
the history is saved in the following csv format.
startedAt,trackUri,contextUri
the observer runs queries every *_INTERVAL_S
seconds. it fetches the last *_LIMIT
entries.
newly discovered saved tracks are automatically added to the according monthly playlist YYYY-mm
, based on their added_at
field. if the playlist doesn't exist, it will be created first.
newly discovered recently played tracks are automatically appended to the history.
the storage directory backend/db
is bind-mounted into the container, so all database files are persistent.
/login
- connect to spotify/user
- current user info/fetch/liked
- query and replace all saved tracks (liked.json
)/fetch/playlists
- query and replace all playlists (playlists.json
)