[Script] and [Plugin] Volumio Smart Playlists - rule-based playlists from a text file

[Script] and [Plugin] Volumio Smart Playlists - rule-based playlists from a text file (AND/OR filters, dedup)

Hi everyone,

I wanted to share a bash script I’ve been building together with Claude AI (and battle-testing on my own ~24,000 track library) that generates native Volumio playlists
automatically from a plain text file of rules - one line per playlist.

Developed for and tested on Volumio 3. May also work on other Volumio Versions.

The idea

Instead of manually building playlists in the UI, you write something like
this in a text file:

Genesis;Supertramp;Pink Floyd
Classic Rock 70s::Genesis;Supertramp;Pink Floyd|album!~Live|year>=1973|year<=1979
Simply Red Mixes::Simply Red|title~Mix,album=12'' Ers
Queen Best-Of::Queen|duplicate=false
Long Uptempo::Genesis|duration>300|bpm>=120
Genesis Albums In Order::Genesis|sort=album-track+
New Genesis::Genesis|added<30|sort=added+|limit=15
Recently Added (All Artists)::*|added<5|limit=20

…and running the script turns each line into a real Volumio playlist,
showing up directly in your Playlist view - no import needed.

Features

  • Artist lists: Artist1;Artist2;Artist3 → one playlist with every
    track from any of those artists (OR). Use * instead of an artist
    list to match all artists - handy for library-wide playlists that only
    filter on other fields, like “20 tracks added in the last 5 days”.
  • Formats: FLAC, MP3, M4A, DSF, OGG, Opus, AIFF, and APE out of the
    box (configurable). WAV/WMA are deliberately left out - tagging
    conventions for those are too inconsistent to trust blindly.
  • Filters on album, genre, year, title, artist, track
    (number), duration (seconds), bpm, and added (days since the
    file’s mtime - not a real “date added” tag, but the closest proxy
    available), using =, !=, ~ (contains), !~ (doesn’t contain),
    >, >=, <, <=.
  • AND/OR combinations: |-separated filters are AND-combined; within
    one filter, comma-separated conditions are OR-combined - e.g.
    |title~Mix,album=12'' Ers|year>=1990 means
    (title contains "Mix" OR album is "12'' Ers") AND year >= 1990.
  • Deduplication (duplicate=false): handy if you have both a
    studio album and a best-of/live compilation in your library and don’t
    want the same song twice.
  • Sorting (sort=key+/-...): default is random shuffle, but you can
    order by title, track, artist, album, year, and/or added
    instead, ascending (+) or descending (-). Keys chain directly, e.g.
    sort=album-track+ groups by album (Z-A) with tracks in order (1-N)
    within each album - handy for “play these albums back to back, in
    order” playlists instead of a shuffled mess.
  • limit=N: cap a playlist at N tracks, applied after filtering and
    sorting. Combine with sort= for “top N” playlists - e.g.
    sort=added+|limit=15 for “15 most recently added tracks”, or
    sort=duration-|limit=20 for “20 longest tracks”.
  • Custom playlist names via an optional Name:: prefix.
  • Fast incremental metadata cache: the first run reads tags for your
    whole library (this takes a while on large collections - ~20 min for
    24k tracks in my case), but every run after that only re-reads files
    that are new or have changed, so subsequent runs are seconds, not
    minutes.
  • Self-cleaning: playlists it created that are no longer in your input
    file get automatically removed, so /data/playlist/ doesn’t accumulate
    stale files.
  • Comment lines (#) supported in the input file, so you can document or
    temporarily disable entries.

Requirements

exiftool and jq (both installable via apt-get on Volumio).

Get it

Full script + README with setup instructions, syntax reference, and cron
setup for scheduled runs: https://github.com/Celindir69/Volumio-Smart-Playlists/tree/main

This comes with absolutely no warranty in the hope it may be useful for others.
I can’t take any responsibility for any damage this may cause to your system or library. Use at your own risk.

Why not just use Volumio’s built-in playlist tools?

This isn’t a replacement for manual playlist curation - it’s for the
“I want a playlist per decade-spanning artist group with sensible filters,
and I want it to stay up to date as I add new music” use case. Point it at
your library, define your rules once, and re-run it (manually or via cron)
whenever your collection changes.

Happy to answer questions or take suggestions - this started as a
Claude-assisted afternoon project to solve my own “too many artists, too
few playlists” problem, so there’s a decent chance I’ve missed an edge case
that’s obvious to someone else’s library structure. Feedback welcome!

[UPDATE]

Moved this to Plugin category because I also built a plugin based on the original script

You can find it here: https://github.com/Celindir69/smart-playlist-plugin

Hi everyone,

After some testing and research, I realized that I had unnecessarily complicated things for myself by taking the detour through exiftool.

I didn’t realize that I could access most of the data directly from the Volumio database using mpc. Claude and I have rewritten the script and the plugin accordingly and republished them.

Now it should perform significantly better, even with large libraries.
I also expanded the max number of playlists to 90. - This should be enough for most users.

The only thing is that the “BMP” tag is no longer available as a filter, since Volumio doesn’t support it. But that wasn’t a big deal for me.

Best regards, Celindir