Skip to content

Dashboard for showing and clustering currently followed artists on spotify.

Notifications You must be signed in to change notification settings

CrowdSalat/spotify-personal-dashboard

Repository files navigation

spotify-personal-dashboard

Build Status

Dashboard for showing and clustering currently followed albums on spotify.

TODO

  • nicer cards and layouts via css
  • better routing with exception handling
  • more than 20 resutls maybe via paging
  • searching and filtering

docker

Before you run the image on your computer you need to create a client key at spotify like described in [authentication overview](## authentication overview]

  • Run with docker: docker run -d --name spotidash -p 8000:8000 -e SPOTIFY_CLIENT_ID=<> -e SPOTIFY_SECRET_CLIENT_ID=<> crowdsalat/spotidash
  • Or with compose: add the spotify variables in the docker-compose file and run docker-compose up

You may also want to overwrite the host part of SPOTIFY_CALLBACK_URL. It defaults to localhost:8000/dashboard/albums

production configuration

server

This projekt uses gunicorn as WSGI http server. Alternative servers are listed here. To check whether your application is production ready read this article or run python manage.py check --deploy for a subset of the recommended checks.

To start a gunicorn server which serves the django application run gunicorn config.wsgi. By default it will be reachable under [http://localhost:8000]. You can run 'gunicorn <project_name>.wsgi', because the startproject of django generates a wsgi.py file in the project folder.

This app uses the whitenoise library to serve static files directly via the WSGI Server instead of serving them via a dedicated webserver. In order to work a wrapper was added in the wsgi python file and in the settings.py a middleware was added as well a the variables STATIC_ROOT and STATIC_URL were added. See commit 1ec48f2fa76abcae8a44eb2620eaebfbc58a04e6.

development

run

  • activate environment: source env/bin/activate
  • start django development server on 8000: python manage.py runserver

requirements

you need:

  1. python 3
  2. pip3
  3. modules defined in requirements.txt

update packages

  • activate virtualenv source env/bin/activate
  • install new packages via pip install <packageName> and afterwards save it in requirements.txt pip3 freeze > requirements.txt

install (one time)

  1. (optional) install pip3 if not present: sudo apt-get install python3-pip
  2. (optional) install virtualenv if not present: sudo pip3 install virtualenv (without sudo it wont be on the path)
  3. checkout repo and navigate inside it: git clone https://github.com/CrowdSalat/spotify-personal-dashboard.git && cd ./spotify-personal-dashboard (you may want to use ssh git url instead of the given https)
  4. Create virtualenv in root of this repo: virtualenv env (env is just the name)
  5. Activate virtualenv: source env/bin/activate
  6. Install python packages inside of the virtualenv: pip3 install -r requirements.txt

authentication overview

steps:

  1. Create a client key. After creating you need to edit the new client) and add a redirect uri.
  2. Get new oauth2 access token with the scopes you need.
Auth URL: https://accounts.spotify.com/authorize
Access Token URL: https://accounts.spotify.com/api/token
Redirect URI: {{callback_uri}}
Client ID: {{client_id}}
Client Secret: {{client_secret}}
Scope: playlist-read-private playlist-read-collaborative user-library-read user-follow-read user-top-read
Grant Type: Authorization Code

django

postman example

The project includes a postman project to explore the spotify api. In order to work:

  1. import the spotify.postman_collection.json and the spotify.postman_environment.json files into postman
  2. edit the spotify enviroment in postman so it includes your client_id and client_secret see
  3. under security generate a new oauth2 token and use it.

Full guide from the official postman site explains how to configure a project in order to work with spotify api.