https://github.com/crowdsalat/spotify-personal-dashboard
Dashboard for showing and clustering currently followed artists on spotify.
https://github.com/crowdsalat/spotify-personal-dashboard
django docker docker-compose drone-ci spotify virtualenv
Last synced: 3 months ago
JSON representation
Dashboard for showing and clustering currently followed artists on spotify.
- Host: GitHub
- URL: https://github.com/crowdsalat/spotify-personal-dashboard
- Owner: CrowdSalat
- Created: 2020-04-14T08:17:19.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T09:33:48.000Z (over 3 years ago)
- Last Synced: 2025-03-25T08:19:33.177Z (over 1 year ago)
- Topics: django, docker, docker-compose, drone-ci, spotify, virtualenv
- Language: Python
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spotify-personal-dashboard
[](https://droneci.weyrich.dev/CrowdSalat/spotify-personal-dashboard)
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](https://gunicorn.org/) as WSGI http server. Alternative servers are listed [here](https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/). To check whether your application is production ready read [this article](https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/) 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 .wsgi`', because the `startproject` of django generates a wsgi.py file in the project folder.
This app uses the [whitenoise](http://whitenoise.evans.io/en/stable/) 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 ` 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](https://developer.spotify.com/documentation/general/guides/app-settings/). After creating you need to edit the [new client](https://developer.spotify.com/dashboard/applications)) and add a redirect uri.
2. Get new oauth2 access token with the [scopes](https://developer.spotify.com/documentation/general/guides/scopes/#user-read-private) you need.
- The spotify [developer dashboard](https://developer.spotify.com/dashboard/login) for managing your api keys.
- oauth python clients:
- [python 2.7 example](https://developer.byu.edu/docs/consume-api/use-api/oauth-20/oauth-20-python-sample-code)
- [python 3 example for spotify](https://gist.github.com/CrowdSalat/770bb1b5a1a8c892b37b7fd940a8e133)
```
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
- django was scaffolded with commands:
- `django-admin startproject config` create django project named config
- `python manage.py startapp dashboard` create django app inside of django porject named config
- `python manage.py migrate` created the standard database tables for django. Needed for session.
- django docs:
- [official starting django tutorial](https://docs.djangoproject.com/en/3.0/intro/tutorial01/)
- [how to handle django project with one django app](https://learndjango.com/tutorials/django-best-practices-projects-vs-apps)
## 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](#authentication)
3. under security generate a new oauth2 token and use it.
[Full guide](https://blog.postman.com/2016/11/09/generate-spotify-playlists-using-a-postman-collection/) from the official postman site explains how to configure a project in order to work with spotify api.