Skip to content
/ spike Public

a spotify watchdog and database for likes and track history

License

Notifications You must be signed in to change notification settings

gurki/spike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spike 🦔

a spotify watchdog and database for likes ❤️ and track history ⏳.

Setup

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

Build & run (Docker)

cd backend
docker-compose up -d --build

Build & run (bare metal)

cd backend
yarn
yarn dev

using pm2.

cd backend
pm2 start index.js --name "spike"

Authorization

login & create auth token at http://localhost:8888/login

Overview

everything is stored locally. the database lives as files in backend/db.

the history is saved in the following csv format.

startedAt,trackUri,contextUri

Observer

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.

Docker volumes

the storage directory backend/db is bind-mounted into the container, so all database files are persistent.

Endpoints

  • /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)

About

a spotify watchdog and database for likes and track history

Resources

License

Stars

Watchers

Forks

Packages

No packages published