Like tinder, but with songs from Spotify
Tinify is a project of the web engineering course at DHBW. With Tinify you can rate random songs from Spotify and if you like the song it will be added to a Spotify playlist. With this, new songs can be found quickly on Spotify.
Functions of the webapp
- dark and light design depending on OS setting
- Account creation for Tinify
- Session management via session-cookies
- account disabled if more than 5 incorrect logins within 5 minutes
- Delete account from Tinify
- store the songs you have already listened to so that they are not repeated
- store the spotify refresh token in the DB
- Spotify playlist creation
- add liked music to playlist
- storage of the Spotify access token in localstorage
- play a 30s preview
- Choice between random song and recommended song
- api response type returns the status of the query in addition to the json message
- snackbox for errormessages
Spotify tokens are not provided as they are assigned to a developer account and should not be made public.
- go to Spotify Developer Dashboard
- login
- click the button "CREATE AN APP"
- set a name and a description for the app
- if you aren't in the app properties, go to your new created app via the dashboard.
- click the button "EDIT SETTINGS"
- In the section "Redirect URIs" add your address where Spotify should jump back after a user login.
The address is structured like this:
<PROTOCOL>://<DOMAIN>:<EXTERNALPORT>/set/refreshtoken
PROTOCOL, DOMAIN, EXTERNALPORT are the ENV vars that are set when the server is started. - save the settings
- in the app view the client-id and the client-secret can be read out
- Mostly not necessary. Since the generated Spotify app is only in developer-mode, users have to be added manually to use the website. For this, the user must be added under "USER AND ACCESS". The account that created the Spotify app doesn't need to be added.
The easiest way to run it is by using the container. If this isn't wanted the following commands must be executed in the root folder of the project.
npm install
ClIENTID=<clientid> CLIENTSECRET=<clientsecret> node webserver.js
Whether container or running directly via nodejs the following env variables should be set.
SESSIONSECRET
: is used to create the session cookies (default: a long string)PORT
: is the internal port of nodejs in the container (default: 3000)CLIENTID
: is the client ID from the Spotify developer website (required)CLIENTSECRET
: is the client secret from the Spotify developer website (required)PROTOCOL
: is the protocol used for the web server (default: http)DOMAIN
: is the webserver domain (default: localhost)EXTERNALPORT
: is the external exposed port of the container (default: PORT of the ENV-Var)
The Docker image will create a volume in addition to the container to persistently store the db.
- Create image: run
docker build . -t <image-tagname>
in the root folder of this repo - Create container: run
docker run -p <external-port>:<internal-port> -e CLIENTID=<client-id> -e CLIENTSECRET=<client-secret> -d <image-tagname>
and add all necessary env-vars as-e
option - list all running containers: run
docker container ls
- stop container: run
docker stop <container-id>
- Delete container: run
docker rm <container-id>
- Delete image: run
docker rmi <image-tagname>
- Delete volume: run
docker volume prune
if the volume name isn't known. However, all unused volumes are deleted. If the volume name is known, the single volume can be deleted withdocker volume rm <volume-name>
.
- own Webpage
- Spotify login and music suggestions
- Login via REST-API on nodejs with sqlite
- Webapp executable in Docker containers
- went well: html, css, usage of the express module of nodejs, usage of the api from spotify
- Problems: many successive requests to the Spotify API and/or the own API
- Lessons learned: working with nodejs and with promises, working with the spotify api