Concept for providing cover art for single tracks
Tobias Leupold
tl at stonemx.de
Sun Sep 18 09:08:01 BST 2022
Dear Elisa devs,
currently, there seems to be no way to provide CD cover images for single
tracks. In FileScanner::searchForCoverFile, there is a per-folder search for
all kinds of images that could be the cover art -- for that album. But a
collection of single tracks normally don't live in a per-album folder
structure, so this won't work well for single tracks (at least for my
collection structure).
Lately, I worried about how one could solve this.
Back in Amarok days, one could add cover images for all tracks. Amarok
calculated some MD5 ID from the lower-case file name or such IIRC and created
an Amarok-specific cover archive to be used whilst playing songs. This worked
fine, but the problem was that a lot of work had to be done to always see
covers, but the result was application-specific, with no easy way to reuse it
(e.g. in some script). Also, those IDs were filename-agnostic IIRC.
I think there would be a quite straightforward solution for providing cover
art for all songs. What do you think of the following approach?
- We define a folder containing all cover art. This would be typically some
folder inside the collection root (of course configurable by the user).
- We read, if present, the MusicBrainz album ID of the respective song
- If there's a MusicBrainz album ID, we check if the song's folder contains
some cover art as it's done now. And if not, we check if the cover art
folder contains a file named [id].jpg/png
I use such an approach to generate normalized songs to be used in my car's
radio: I decode the song I want to add, calculate it's EBU R 128 loudness
using ffmpeg, apply it and re-encode it to a format my car will play, with the
normalized loudness applied (as of course stuff like ReplayGain or EBU R 128
tags aren't considered). And: I embed the cover art for that album, which I
find using it's MusicBrainz album ID.
This is quite easy: I do this with a small Python script using Mutagen, which
exposes the MusicBrainz album ID as "TXXX:MusicBrainz Album Id" or
"musicbrainz_albumid" (depending on the file type) if one uses the (most
convenient) mutagen.File extractor. And thus, I know which file to embed.
This way, multiple songs can link to one cover image, no matter if it's a
whole album or a single song. Also, the file name can be easily found, and it
is static, even if the album name would be changed (corrected). Also, being an
UUID, we won't have to worry about collisions. And the file's path doesn't
matter. And this is reusable, not application-specific.
Well, I thought this would almost be trivial to implement, so I tried to do it
and file a MR. But sadly, there are some problems for me :-(
I must admit that I don't find my way too well in Elisa's sources. But as far
as I could grasp it, KFileMetaData is used to extract the metadata that is put
in the SQLite database. Now, KFileMetaData::Property doesn't list MusicBrainz
stuff, so I think a custom extractor exposing it would be necessary to be
implemented. The rest would really be easy I think. Just invoke
FileScanner::searchForCoverFile with not only the file name, but also the
MusicBrainz album ID and do one additional lookup.
Anyway ... before I become too obsessed with this idea, I wanted to ask what
you think about this approach, and if this would be something beneficial for
Elisa.
Thanks for all feedback!
Cheers, Tobias
More information about the Elisa
mailing list