Skip to content

aesrael/musical

Repository files navigation

musical 🎸🎧

.github/workflows/send-track.yml

.github/workflows/backup-db.yml

Building a job runner and exec environment around https://github.com/spotDL/spotify-downloader

how this works (optional flow)

simply create an issue comment with the url of a spotify track or playlist, and it is automatically uploaded to a drive folder.

NOTE: GitHub issues/actions is not required for this to work, just any http request to said endpoints will do, using github actions is merely a matter of convenience and personal choice

prerequisites

running locally

start project

make build-run

or using docker

docker

docker-compose build
docker-compose up

how it works

This service consists of an http server, a redis database (used also as a queue & cache) and a set of workers consuming jobs published to said queue.

Role of redis

Using asynq, Redis is utilized in this project as a durable queue.

Role of github actions

comments on any issue in this repo, trigger an action workflow, which enqueues jobs(tracks to download in the redis database), once these tracks are downloaded, they are uploaded to google drive, after which a cleanup occurs.

A backup job also happens at given time intervals to backup the redis db to google drive.

Role of google drive

Using the google drive API, authorized by means of a service account, tracks are uploaded to a google drive bucket, it also acts as a backup for the redis db in the event of a failure or crash.

connections are authenticated via google service accounts

for a more visual guide to service accounts see these

What are Service Accounts?

Uploading files to Google Drive API with a service account

http server is exposed on port 8999 the endpoints are

endpoint method body description
/api/job POST {"track": track|playlist|artist|album url} enqueue a new track, artist, album or playlist for download
/api/backup GET - backup db

both endpoint requires an Authorization header with any jwt token generated from the secret key.

Role of asynqmon

using asynqmon you can monitor and manage the jobs, install the binary and allow it access to your redis db.