When I spotted ‘antisocial music recommendations’ in the roadmap I was excited. I have been slowly laying foundations to do exactly that in a research project I call Calliope. Progress is slow but steady. I haven’t shared the project anywhere yet but it ties in with Beets, so let me try and fix that by giving an overview of the design.
The main goal of Calliope is to generate interesting playlists. It doesn’t do much of that yet.
The other goal of Calliope is to be a sustainable project, currently meaning it can be developed and maintained in small blocks of maybe 2 hours a week. (You might also think of it as small technology).
Concretely, Calliope is a suite of commandline tools which operate on playlists. It’s written in Python so you can work with it in a Python shell like iPython, or in any UNIX-style shell.
The best playlist format is XSPF, but there aren’t good UNIX shell tools for working with XML. Inspired by jq, I combined XSPF with JSON Lines to define the ‘Calliope playlist format’. There’s a small example in the linked documentation.
The general operation of a recommender is this:
- Get source data
- Process the data, based on some configurable parameters
- Output a playlist
Calliope provides tools for each of those things. For getting source data, you can
cpe import an existing playlist, use
cpe lastfm-history to pull from last.fm,
cpe spotify to get various things from Spotify, etc. (Note that
cpe spotify requires you to register a Spotify API key). I’m sure you can think of more.
The magic happens in stage two. A simple playlist processing example is
cpe shuffle which shuffles its input. Let’s say you want to listen to random tracks from your Beets library – once
cpe beets is ready, you could do this:
cpe beets tracks | cpe shuffle | cpe export > playlist.xspf
Then you would open
playlist.xspf in a media player and away you go. (Try to ignore the fact that your media player already has this functionality built in).
I’m looking at a more interesting use case of reminding you about music you didn’t listen to for a while. The
cpe lastfm-history module fetches your listen history from last.fm (a slow process) and stores it in an SQLite database. This lets us do interesting queries. My idea is to score the artists out of 10 on different axes, for example when you first listened, how much you have listened, when you last listened, when they last released music, and how popular they are overall. This will find its way to a new
cpe remind command which you might call like this:
# Music I've forgotten about but other people haven't cpe remind --forgotten 7.0 --popular 10 # Music I discovered a long time ago cpe remind --fresh 1.0
You can see a list of currently existing commands at: https://calliope-music.readthedocs.io/en/latest/reference.html
The code itself is here: https://gitlab.com/samthursfield/calliope/
I have more ideas for things we could do, more ideas than time to try them all as is normal :). In particular I like Spotify’s ‘artist radio’ and ‘track radio’ feature and I think Calliope could do something similar. I’m sure you have more ideas as well, so please let me know… here, or I’m also in the #beets IRC room as ssam2.