← All blogs

I sorted 3,472 liked songs by how they feel

My Liked Songs is one long list: Persian rap next to lo-fi next to film scores. I wanted playlists by mood, not by genre and not by the day I liked something, so I built a small local app that listens to every song and sorts them for me.

TL;DR The app pulls my liked songs from Spotify, finds audio for each one, scores its mood with Essentia's pretrained models, clusters the scores into 24 moods, and pushes them back as playlists. 3,197 songs were analysed and 2,741 made it into a playlist. The map of all of them is below: click a playlist to see where it sits, press ▶ to listen.

The problem

Spotify used to hand out this data. Since late 2024, new apps get neither audio features (valence, energy, danceability) nor 30 second previews. So the app has to find the audio itself and judge the mood itself. And mood is harder than genre: a sad song and a happy song can share every instrument.

How it works

Getting the audio

Matching previews

The first version looked each song up on Deezer by its ISRC (the recording's ID) and fell back to Deezer's strict search, artist:"…" track:"…". That fallback returned nothing for every single query, and my title cleanup wiped Persian and Cyrillic titles to empty strings. So 29% of the library (1,020 songs) came back without audio. What fixed it:

That took the songs without a preview from 29% to under 10%.

30 seconds is not the song

A preview is usually the chorus, and Deezer and iTunes use the same 30 seconds (31 of 32 songs I compared). Clip quality was not the problem: re-encoding at Deezer's 128 kbps moved the mood scores by about 3% of the gap between two random songs. The excerpt was. In a 50 song test, analysing the whole song moved 4 in 10 songs to a different group.

So the app finds each song on YouTube Music by its title (including words like live, remix or slowed), artists, album and length, downloads it, and checks it is the same recording by finding the preview inside it. Then it analyses the full song and deletes the file. My first version took 7 seconds per song. One search request on YouTube Music's own catalogue, one download step and three songs at a time got that to about 1 second, a bit over an hour for the library. 2,929 songs were analysed whole, including 59 that had no preview, 36 of them the failed downloads. 275 songs still have no audio at all.

The result

This is the app's own view, exported as one HTML file. Every dot is a song, placed from sad to happy and from relaxed to aggressive. Click a playlist under the map to pin it, hover a dot to see the song, and press ▶ on any card to play it.

Open it full screen ↗  Songs play through Spotify's player: log in to Spotify for full songs, otherwise you get 30 second previews.

How many songs made it through each step:

StepSongsLost or gained, and why
Liked on Spotify3,559
Counted once3,47287 were liked twice: the single and the album version, or a re-release
Found a 30 second preview3,1382,815 by ISRC, 227 by Deezer search, 96 on iTunes. 334 without one
Analysed3,197YouTube Music added 59 songs with no preview. 275 have no audio anywhere
Grouped into 24 moods3,197every analysed song gets a group
In a playlist2,741456 left out because they sit too far from every mood. 3,228 playlist spots, since songs between two moods are in both

Where it works less well

To my ear, the clustering is weaker on Persian and Kurdish songs overall and makes more mistakes there. The mood models were most likely trained mostly on Western music, so their scores for other traditions are less reliable.

A few other things I fixed along the way

Built with Claude Code as a local Flask app on Windows. The map is the app's own "Find & name moods" page, saved as a single file.