SpOTUfy is an application for the purpose of providing greater value to the everyday Spotify user who wants to get more out of their experience.
Public deployment available here. No longer available as of May 2024.
There are two options for deployment:
- Clone this branch (main), place the
.env
file we submitted to Canvas in the repository directory, install the required packages with Pip, then simplypython3 app.py
Alternatively, use theThe Docker branch has changed so the old Compose file will no longer work.docker-compose.yml
we submitted to Canvas.docker compose up
Deploying locally will simply involve running the Flask application, and uses the Flask server. The Docker image is meant to be the "production" deployment and uses Gunicorn as the web server, with Nginx added to proxy incoming connections.
Either way, visit http://localhost:9191
to access the application.
Self-hosting requires a Spotify account (no subscription required), a Genius.com account. The easiest way to self-host is by using our docker-compose.yml and nginx.conf files.
Put both files in the same directory and set the following values:
- nginx.conf:
server_name
on line 9 - docker-compose.yml:
environment
section starting on line 9CLIENT_ID
andCLIENT_SECRET
are obtained from the Spotify Developer console (steps shown below)GENIUS_TOKEN
is obtained from Genius.com (steps below)SECRET_KEY
can be generated by runningpython
orpython3
(depending on your system) like so:python -c "import os; print(os.urandom(12).hex())"
CALLBACK_URL
should be set tohttps://your.domain/callback
- Sign into Spotify for Developers
- On the dashboard, click
Create app
- Choose an app name and fill the decription with anything.
- Set the redirect URI to the same as
CALLBACK_URL
- In the "Which API/SDKs are you planning to use?" section, select Web API
- Agree with the terms and press Save
- The app will now be created; click settings and you will be shown your client ID and secret.
Generating a Genius API access token is a similar process to Spotify but slightly less involved. Visit the API Client management page, create a new API client, set the name and website to anything, then click Generate Access Token.
Disclaimer: if you intend to use the GitHub Actions workflow for a public deployment, be aware that the LyricsGenius library for the Genius API is only functional locally.
- Get artist new/upcoming releases
- On demand "Daily Mixes"
- Graph visualization of artist relations
- Search artist information
- Get list of artist's top tracks and optionally create playlist with those songs
- Search song details
- Get recommendations based on a song and optionally create playlist with those songs
- Get recommended songs based on your listening activity
- Get artists related to a given input artist
- Get song lyrics
- Search artist discography
The pipeline used for this project can be found at .github/workflows/pipeline.yml. The pipeline contains three jobs: test-code
, publish-docker
, and deploy
and is triggered on any pull request or push (except for the docker
branch itself, more info below) and can also be manually dispatched.
test-code
runstest_unittests.py
onmain.py
usingpytest
. Seetest_unittests.py
for more information on how each unit test workspublish-docker
builds and publishes a new Docker image to GitHub Container Registry through the below steps- Merges the
main
branch into thedocker
branch- This step is why the
docker
branch is excluded from triggering the workflow on push. Without that exclusion, a duplicate job would be run. Apart from being a waste, this can also cause issues with the deployment if both jobs are executing simultaneously.
- This step is why the
- Logs into ghcr.io
- Builds the new Docker image
- Pushes it to ghcr.io
- Merges the
deploy-image
first installs the predefined SSH keys to the Ubuntu runner, then creates an SSH session to the VPS that hosts the public deployment, pulls the newly created Docker image, and runsdocker compose up
to (re)start the application.