This looks like a set of notes more than questions where i can concretely help with everything, anyway its great to see someone diving into the code
I’m trying to get my feet wet with “all beets albums, ordered by $added”.
It might indeed be possible to do this with Beets commandline.
certainly using beet ls -a added+
you can get the list of albums. If you want to avoid -a
so you get a list of albums and all their tracks in a single list, it might be hard to get the right sort order.
So cpe beets albums
runs in two stages, first querying the albums with ls -a
, then running beet export
for each album to get the tracklist.
(as a side note, this can be slow for large exports as it runs beet
many times and the program can be slow to startup. adding a beet export-many
command would help speed up cpe beets
)
Looking at the code, cpe beets albums
doesn’t have any --sort-order
option, it would be nice to add that, although it should already to run cpe beets albums added+
.
Right now I miss a sql-like query functionality.
Early designs of Calliope had a single giant database that would store all possible info about your music, and processing would be done using a query language like SQL. A “big SQL database” design didn’t work for me as (1) it’s good if you can design your schema up front, but its not so easy to prototype and evolve new features (2) SQL is readable for short queries, but becomes very unreadable for large complex queries.
So the key insight of this version, is to have many small tools instead of one big one. The json-lines based playlist format is designed as an interface between different components. But it’s not necessarily the best way to process data inside a component.
In many cases, importing/exporting from an SQL database in the component is a good option. For example, listenbrainz-history
and lastfm-history
both use an SQLite database for storage, and run SQL queries internally to generate the playlists that are output.
There isn’t currently a cpe sql
command that could import a playlist into an SQL database and run SQL-like queries, but it would be valid to add one. (There is cpe tracker
, which if you happen to be on Linux lets you use Tracker SPARQL database).
Another thing I am playing with myself is Nushell. It’s a shell with first-class support for tables and dataframes, which plays very nicely with the design of Calliope. you can get data out of cpe
and into nu
using from json --objects
.
Here’s a quick nushell example to show the top lastfm artists I’ve listed to <100 times:
cpe lastfm-history --user ssam artists | \
from json --objects | \
sort-by "lastfm.playcount" -r | \
where "lastfm.playcount" < 100 | \
first 10
Worth noting that nushell is in active development and things sometimes don’t work. But it could be useful for prototyping and scripting in a way that feels natural.
This looks promising: examples/special-mix/special_mix.py · main · Sam Thursfield / calliope · GitLab
That’s what i am currently using to generate my playlists