feat: mood playlists from Last.fm crowd tags
Build and publish container / build (pull_request) Successful in 3m50s

A second set of playlists selecting by genre and mood rather than by play
history: eighties synths, high energy rock, screamo, drum and bass, dance,
classic rock.

The tags come from Last.fm rather than MusicBrainz. MusicBrainz genres arrive
free with the Lidarr index, which makes them the obvious choice and the wrong
one: they are sparse and formal, and will not tell you a record is screamo or
synthwave. Crowd tags will, because people typed them.

One request per artist, by MusicBrainz id where Lidarr has one, refreshed every
ninety days. An artist Last.fm has never heard of is recorded as fetched with no
tags rather than left unmarked, so it is not asked about again on every pass
forever. The tag table is keyed on the normalised artist name, not the Lidarr
id, so it survives an artist being removed and re-added there.

Weights are taken from the response's count where it has one. The documented
sample carries only a name and a URL, a live response also carries a 0-100
count, and depending on either alone would be a guess -- so the count is used
when present and the documented ordering by popularity stands in when it is not.

An artist qualifies for a mood when their weights inside it sum to at least
thirty. A single low-weight tag is not a genre, it is somebody's stray opinion.
A mood may also restrict release years, which is what separates eighties synth
records from everything else a synthpop tag drags in.

The built-in set is chosen for this library rather than as a taxonomy, and
--vibes replaces it wholesale with a JSON file so a new mood does not need a new
release. Names are validated when that file is read: an invalid one would
otherwise only surface as a playlist written somewhere unintended.
This commit is contained in:
Emma Thorpe
2026-08-24 17:56:35 +01:00
parent 05cca3508c
commit 15e5ee5aea
4 changed files with 457 additions and 4 deletions
+47 -2
View File
@@ -8,7 +8,8 @@ question that mirror cannot: which of it is worth carrying, and which of it has
not been played in years.
**This is stage three.** It ingests the scrobble history, indexes the library
from Lidarr, matches one to the other, and writes playlists into the mirror.
from Lidarr, matches one to the other, and writes playlists into the mirror
by listening history and by mood.
Nothing is written back to Lidarr — every call there is a `GET`. See "Where this
is going" below.
@@ -151,6 +152,48 @@ few hours, and a playlist that reorders itself each time is one that has to be
re-imported each time — the Music app imports a snapshot of a file, it does not
track it.
### Moods
A second set of playlists selects by **Last.fm's crowd tags** rather than by
listening history. MusicBrainz genres arrive free with the Lidarr index and are
no use for this: they are sparse and formal, and will not tell you a record is
screamo or synthwave. People typing tags will.
Tags are fetched once per artist — one `artist.getTopTags` call each, by
MusicBrainz id where Lidarr has one — and refreshed every ninety days. An
artist Last.fm has never heard of is recorded as fetched with no tags, so it is
not asked about again on every pass. `--tag-limit` spreads the first sweep over
several passes.
The built-in moods are chosen for this library rather than as a general
taxonomy:
| Mood | Selected on |
| ------------------ | ------------------------------------------------- |
| `80s-synths` | synthpop, new wave, synthwave — released 1975-1992 |
| `high-energy-rock` | hard rock, punk, pop punk, alternative |
| `screamo` | screamo, post-hardcore, metalcore, emo |
| `drum-and-bass` | drum and bass, liquid funk, neurofunk, jungle |
| `dance` | house, big room, hardstyle, trance, dubstep |
| `classic-rock` | classic rock, prog, psychedelic, blues rock |
An artist qualifies when their tag weights inside a mood sum to at least 30 out
of Last.fm's 0-100 scale. One low-weight tag is not a genre, it is somebody's
stray opinion.
`years` filters on the album's release date, which is what separates eighties
synth records from everything else a synthpop tag drags in.
`--vibes` replaces the whole set with a JSON file of the same shape, so a new
mood does not need a new release:
```json
[{ "name": "shoegaze", "tags": ["shoegaze", "dream pop"], "min_score": 40 }]
```
Names are validated when the file is read, not when the file is written. A bad
one would otherwise surface as a playlist created somewhere unintended.
### Paths
Lidarr knows where the lossless source is; the playlists have to point at the
@@ -229,6 +272,8 @@ music-curator --report-only # report on the store, fetch nothing
| `--mirror` | `MUSIC_CURATOR_MIRROR` | unset | Root of the MP3 mirror; playlists go here |
| `--library-root` | `MUSIC_CURATOR_LIBRARY_ROOT` | derived | Prefix to strip from Lidarr's paths |
| `--playlist-limit` | `MUSIC_CURATOR_PLAYLIST_LIMIT` | `100` | Most tracks in any one playlist |
| `--vibes` | `MUSIC_CURATOR_VIBES` | built-in | JSON file of mood definitions |
| `--tag-limit` | `MUSIC_CURATOR_TAG_LIMIT` | `0` | Cap artist tag lookups per pass |
| `--skip-index` | — | off | Match against the index already held |
| `--report-only` | — | off | Report without fetching |
@@ -278,7 +323,7 @@ nix shell nixpkgs#python3Packages.pytest -c pytest
| Last.fm ingest and store | done |
| Lidarr index and the scrobble-to-track matcher | done |
| M3U playlists from the listening history | done |
| Genre and mood playlists from Last.fm tags | next |
| Genre and mood playlists from Last.fm tags | done |
| Cold-music report, unmonitoring what is not played | last |
The cull will unmonitor cold albums in Lidarr and tag their artists. It will