A small web app to automatically generate a spotify playlist based on your top last fm tracks for the week or month
Well mainly to scratch an itch and try out golang and htmx for a real project. But it's also cool having playlists automatically generated every month
Because I am the only user, I've only bothered to make a docker container as a release method. Compiling it should be fairly straightforward though and will detail below.
On Gitea, this will automatically be built and published to the private registry. You can also just run:
docker build . -t {name}
to build the container locally.
Once you have the container built/downloaded, you can run it through docker compose
. You just need to ensure you map your chosen port to port 8000.
The program will compile to a single binary. You can do so by running:
# Install the required modules then build the binary
go mod download && go mod verify
go build -v -o /path/to/output
# Generate the minified css file
npx tailwindcss -o build.css --minify
Then just ensure that wherever you deploy the app to, you have the following folder structure:
syncer <- the main executable
templates/
| all template files
static/
| all static files generated by tailwind
| app.css <- this is the tailwind generated css file
Sorry it's messy, but I just use docker to deploy and don't bother with the binary directly.
Once the program is installed and running, access it in a browser at localhost:8000
(by default). You need to populate the api key fields.
You will need to create new applications for lastfm and spotify using the following links:
- Lastfm:
- Spotify:
Populate the fields, then click save. Once done, click the authenticate buttons for each of the services at the top to generate the api tokens needed to communicate with the services. It should tell you when you are correctly signed in. Then you can simply enable syncing for either weekly or monthly periods, and how many tracks to save. You might need to toggle it off and on for any changes to have an effect 😬
This project can build hot-reloaded using air.
Follow the instructions to install it.
You will also need npx
to install and run tailwindcss, to generate the css file.
Run
# assuming gopath is setup correctly
air
# if not:
/Users/user/go/bin/air
Air will reload and recompile every time you make a change as well as rerunning tailwind to update the css.
The app will be available at localhost:8000
while air is running.
Sadly, spotify doesn't provide any way to put the playlists into folders via the api, so there's no way to control where the new playlist is added to: https://developer.spotify.com/documentation/web-api/concepts/playlists#folders