Förvillelser

Playlistlog

Playlistlog is a tool to keep track of song additions and removals from Spotify playlists. In this post I describe why I made it and how it works.

Here’s a screenshot of the application to give you an idea of how it looks and what it does:

Playlistlog screenshot

If you want to check out the code it’s available on github/vorce/playlist_log. If you want to give the app a spin you can do so at playlistlog.vorce.se (you will need a Spotify account).

Motivation

I have a Spotify playlist of around 60 (66 to be precise at this moment) tracks that I currently like. I update this list frequently by adding new songs. To avoid making the playlist too big, I also delete a track when I add one. This means I have no way of seeing what tracks I was really into a while ago. That’s the whole reason for building Playlistlog.

Technology

As usual nowadays when I want to be productive and create a web application I reach for Elixir and the Phoenix framework. Not only can I hit the ground running, but also get some unique features easily when needed. I will go into details in the next sections.

First of all Playlistlog is a Spotify app, althought conceptually I guess it could work for any music platform. This means that I am making use of Spotify’s web API for a lot of functionality such as fetching existing playlists, their tracks, and adding/removing tracks to playlists.

State

I knew that I did not really need a lot of state or relations for this application. But it had to be persisted. This led me to investigate some schemaless and “built in” alternatives to a full blown database. At first I considered just storing stuff in files on disk by myself. Luckily I found CubDB, which sounded like the perfect fit:

CubDB is an embedded key-value database written in the Elixir language. It runs locally, it is schema-less, and backed by a single file.

It’s so convenient, I can use any erlang/elixir term as keys and values!

Interactivity

I quickly realized that being able to incrementally sprinkle some UX goodness on the app was going to be needed. For example being able to filter the events based on its type (removal or addition) would be awkward if you need a full page refresh. Phoenix LiveView to the rescue! <3

DevOps

I was debating how to run this app for a bit. Of course just running it locally would work fine, but I wanted to share it and let others play with it.

I considered getting a Raspberry Pi and operating that, I also considered moving up a price level at Gigalixir (a Heroku like PaaS). In the end I settled for something in between - a “droplet” (virtual server) on Digital Ocean.

I set up nginx and got a SSL cert with let’s encrypt. Playlistlog runs as a docker container (alpine with an elixir release running inside) in Docker Swarm. The reason for swarm is to enable zero downtime deployments.

In closing

It’s still sort of early days for Playlistlog and I’m sure it has a lot of bugs. But it’s serving my main purpose, and I am using it pretty much daily.

It didn’t take long to get the first working version up and running - thanks to Elixir and Phoenix. In fact the things that have taken the longest is to get the app running on my DO server and making it publically available via https.