I came across this beautiful project by someone called Timothee Boussus or better known as Yooooomi on Github. This project displays stats about your spotify account like recently played, most listened to artists in near real time.

Yooooomi/your_spotify
Self hosted Spotify tracking dashboard. Contribute to Yooooomi/your_spotify development by creating an account on GitHub.
r/selfhosted - YourSpotify
84 votes and 36 comments so far on Reddit
Pages

You will need to have some knowledge of docker. I have a quick write up here on how to install it on Linux.

Once your docker is up and running, we will need to gitclone this to our computer. I prefer to keep all my github projects in one folder. Where you put it is up to you.

[email protected]:~/github$ git clone [email protected]:Yooooomi/your_spotify.git

Once that's downloaded, we can go to developer.spotify.com and create a new application.

Login and click 'Create an app'

Name your app as you like. I called mine 'Docker' because #originality Answer the questions and make up something on what it does. I just wrote docker again. Sign away your first born and family name.

Keep this page open as we will need it again.

I had some issues with the config file so you can use mine below. It's based off the original except I have had to change the name of the mongo container.

Save this file as docker-compose.yml

version: "3"

services:
  app:
    image: yooooomi/your_spotify_server
    container_name: express-mongo
    restart: always
    ports:
      - "8080:8080"
    links:
      - mongo
    depends_on:
      - mongo
    environment:
      - API_ENDPOINT=http://localhost:8080 # This MUST be included as a valid URL in the spotify dashboard
      - CLIENT_ENDPOINT=http://localhost:3000
      - SPOTIFY_PUBLIC=__your_spotify_client_id__
      - SPOTIFY_SECRET=__your_spotify_secret__
      - CORS=http://localhost:3000,http://localhost:3001
      #- CORS=all
      #- MONGO_ENDPOINT=mongodb://mongo:27017/your_spotify
  mongo:
    container_name: mongo_spotify
    image: mongo
    volumes:
      - ./your_spotify_db:/data/db

  web:
    image: yooooomi/your_spotify_client
    container_name: web
    restart: always
    ports:
      - "3000:3000"
    environment:
      - API_ENDPOINT=http://localhost:8080

On the spotify webpage, replace the your_spotify_client_id with the public key and then the same thing for the secret. Obviously using the secret.

Next go back to spotify and click edit.

In here scroll down till you find redirect links:

I had some issues the first time so I slapped both these in there. If you're hosting this on a publically accessable server, you will put the address such as:

https://spotify.breadnet.co.uk/oauth/spotify/callback

just append /oauth/spotify/callback to the end of the address to access this.

Now we can start actually using the application. In the same folder as your docker-compose.yml file run docker-compose up and it should whirr away. it took mine around 5 minutes the first time.

Depending on where this is being hosted, you can go to http://localhost:3000 or where ever you've got it. If you're going to have this publicly hosted, use a reverse proxy like nginx or traefik

Once running, click register and make a username and password up:

then login. Once loggedin you'll be presented asking to connect to spotify. Click and login.

Give it around 20 minutes for good measure and you should start to see stats being generated.

If you're having issues, check the github issues or the reddit post from the top!

A quick update. if you see that you cant login to the app, check all the docker containers are running. I found that after rebooting one of the containers had not started up and thus I was unable to login