Artwork
How cover art is gathered, named, judged, and kept, from the pictures inside the files to Lyra looking at contact sheets, with every discard recoverable.
A cover is the first thing you see and the last thing most tools think about. For a library this size, the problem is not finding art. It is too much of it: three or four candidate fronts for one album, a back cover from a different pressing, a booklet scan, an image that turns out to be the wrong release altogether. The Artwork Curator is the part of the Music Manager that keeps one chosen front cover per album, remembers every image it has seen, and never fetches the same unwanted image twice.
It works in layers. A script settles the unambiguous albums. I look at the ones a script cannot judge. And Mike sees only what I will not decide myself. Throughout, one rule holds: the curator never touches an audio file. It moves images, writes a couple of files in the album folder, and edits the album's notebook. (Two separate repair tools can reach into audio files that have damaged cover frames; they are described near the end.)
Where the pictures come from
- Inside the audio files. The first stage of the pipeline extracts any embedded pictures into the album folder, deduplicated by picture type and byte size across tracks.
- MusicBrainz Cover Art Archive. The images for the matched release, every type the archive returns, not only fronts.
- Discogs. The images listed in the stored Discogs record. Discogs' "primary" image is treated as the front, and everything else as secondary. There is no Discogs search at download time.
- Files Mike adds. Scans, crops, and anything he drops into the folder.
- Wild files. Anything else in the folder, such as a
cover.jpgthat a tagger left behind. Wild files are judged on their content, size, and dimensions, never on guessed origin. Most image metadata has been stripped by the time a file reaches me, so source is a weak hint at best.
One class is special: images that Mike adds, plus the tool's own rotated or cropped outputs, are never discarded.
Names that say what a file is
Every image the pipeline downloads gets a name that tells a person or a script what it is without opening it:
source-type-id-size-dimensions
The prefix says where it came from: mb- for the Cover Art Archive, dc- for Discogs, extracted- for a picture pulled from the audio, user- for something Mike added. A file with no prefix is a third-party file, and the pipeline leaves it alone. The type says what it depicts: front, back, booklet, medium (the disc itself), tray, liner, obi, sticker, secondary, or other.
The id in the middle is the source site's own stable image ID, so the same image always gets the same file name, even if the site reorders its list. An older scheme used a local counter (p01, p02), and orphans piled up whenever an upstream order shifted.
Each source owns only its own prefix
The strictest rule in the whole area is that one source never reads, compares against, or deletes another source's files. It exists because a cross-source cleanup tool once deleted thousands of valid extracted images in a single run and had to be undone from the nightly backup. Each download step now removes only its own prefix's files that are gone from the upstream list, and only after a definitive answer from the source: found or not found, never a transient error. The only component allowed to reconcile across sources is the curator itself.
What a good cover is
- The target for a front cover is at least 1200 by 1200 pixels, or the best available. An image is never upscaled.
- Within a role that takes one image (front, back, medium, tray, obi, sticker), the survivor is ranked by pixel area, then file size, then whether it shows signs of a human editor, then the authority of the source.
- Roles that hold many images (booklet, liner, secondary, other) keep every distinct page. Only exact byte-for-byte duplicates are flagged. This follows the collector's policy: a unique booklet page is never discarded for being low quality, because quality only breaks ties between copies of the same thing.
- A cover from a different release is discarded. If an embedded picture is real artwork but belongs to another album, it goes. If it is unclear whose release it belongs to, it stays.
The nightly steps
Three pipeline steps touch the art, and the curator takes it from there.
- A10b extracts embedded pictures into the album folder.
- B31b and B41b download from the Cover Art Archive and Discogs. B31b first checks the size of an image with a header-only request, so an oversized one is skipped without being downloaded and is listed in a pending registry instead. A separate utility downloads those later, without a size limit, and runs automatically each night as a detached process whenever the registry has entries. Discogs images have an optional size cap of their own, currently off; anything deferred there is simply retried on the next run.
- B70b, auto-curate, works down a ranked backlog and sorts each album into a bucket:
| Bucket | What it means | What happens |
|---|---|---|
| Auto | Exactly one front, at least 1200 pixels each way, and no image of unknown role. | Approved as is. The redundant copies are moved out of the library. |
| Low-res | Exactly one front, but under 1200 pixels. | The script tries a maximum-resolution refetch from the source. If it now clears the bar it is approved; otherwise it is logged and left alone. Refetches rarely help, so most of these stay flagged. |
| Needs vision | At least one image whose role could not be worked out from its name. | Goes to the review queue. The script never guesses at pixels. |
| Front ambiguous / no front / no record | More than one candidate front, none at all, or no artwork record yet. | Goes to the review queue. |
B70b is deliberately not queue-driven like the other Stage B steps. It works its own ranked backlog, with a wall-clock budget, and it saves its queue file after every album, because an early version lost a whole night's bookkeeping to a time-out. A cooldown stops the same stuck albums from taking the whole nightly slice: an album seen in the review queue within a few days ranks after every album not recently tried. A kill switch in the configuration stops it with no code change. And an album is re-queued automatically if its set of images changes after curation.
Looking at the pictures
What the script cannot decide, I decide by looking. The nightly artwork pass works through a batch of albums from the review queue:
- A script re-scans each album for free. Anything that now resolves as "auto" needs no looking at all.
- For what remains, it builds a contact sheet: a labeled grid of the album's images, each on a uniform tile with a large index number, up to a couple of dozen per sheet. One or two looks cover every candidate.
- I hand each album to its own judge, a separate AI reviewer, along with the sheets, a legend giving each image's real file name, guessed role, dimensions, and source, the current canonical picks, and the reason the album was flagged. The task is bounded and concrete.
- A script applies the answers I accept.
What the judge decides by inference:
- The role of each ambiguous image: front, back, medium, tray, booklet, liner, obi, sticker, secondary, or other.
- The best image for each single-copy role. The judge looks for real visual quality, not just pixel count: composition, cropping, glare, damage, watermarks. Two tie-break rules came out of real misses. A complete image beats a higher-resolution one that is cropped or truncated. A true-color copy beats a higher-resolution copy whose title or artist text is unreadable from a tonal crush or heavy color cast.
- Which multi-image entries are true duplicates, or are not artwork for this release at all.
- Page order for booklets, where it is visible.
- A completeness note: which roles exist, and which are genuinely absent.
The existing canonical pick is a starting point, not a constraint. The judge may override it when it is wrong, for example when it came from a different edition.
What stays with scripts: the bucketing, the resolution thresholds, the exact-duplicate detection, writing the decisions, writing the folder files, moving discards, and updating the notebook. One ordering constraint is built in. The apply script must never be followed by a rescan of the same albums, because a rescan recomputes roles from file names and would erase the judge's role corrections.
Who approves
Every album the judge marks resolved is applied immediately, with no per-morning ask. Any album the judge marks unresolved is never applied; I list it by name for Mike to look at himself. I do not escalate a borderline case to a larger model. Mike prefers to receive those calls directly, since a quick human glance beats a second, pricier AI pass. After applying, I read the apply report and spot-check at least one changed album against the disk.
That autonomy was earned. The nightly pass began as a trial of several nights, judged album by album, with a real defect found in a substantial share, usually a cover from an unrelated release. Only after clean results did Mike approve it to run unattended. Real misses have also been folded back into the rules, which is how the two tie-breaks above were born.
When you want to do it yourself
The curator also has a visual tool. It is a small web server bound to the local machine, started with a double-click, with a plain browser front end, run only while Mike is curating. It is a local tool rather than a hosted page because it changes files in the library. For each album in the day's queue, or any album found by search, it shows a gallery of every image with its file name, source hint, role, dimensions, size, and status, plus a badge on the recommended survivor. A click opens a larger view. From there Mike can:
- correct an image's role
- pick any image as the front
- rotate by ninety degrees
- drag a box to crop (a rotate or crop writes a new
user-file and keeps the original) - approve, skip, or send the recommended discards out of the library
Approve writes the artwork record and the folder cover files and removes the album from the queue. Skip marks it reviewed with no change.
What actually gets written
On approval, the chosen front is copied over folder.jpg and cover.jpg in the album folder, converted to JPEG first if necessary. Before it overwrites either file, any different image already at that name is copied to the discard store, so an overwrite is always recoverable. That guard exists because a lost scan was once overwritten at folder.jpg.
Putting the chosen cover inside the audio files is not built. The design target is one 1200-pixel front embedded per album with the rest kept on disk, but that step is not built and not scheduled.
What does reach inside files are two small repair tools, for audio whose embedded cover metadata is damaged. The first handles files so malformed that the tag library cannot open them: an empty picture frame in an MP3, or a null picture block in Opus. For MP3 it removes only the bad frame at the byte level, leaving every other frame and the audio identical. For Opus it does a lossless remux that drops the bad picture. It scans first and repairs only when asked. The second runs in the nightly when extraction flags an MP3 whose picture-frame header is damaged: it patches a few header bytes, and only while writing is switched on. Both follow the same safety model: record the audio checksum, build the fix in a temporary file, verify it, back up the live file, swap, verify again, and restore from the backup on any mismatch.
Discards, tombstones, and what is reversible
- A discard is a move, not a delete. The image goes to a store outside the library, one folder per album, never overwriting an existing name. Mike's rule is that discards are trash, not backed up, and do not belong in the library.
- Because a move is a rename within one drive, a discard can be recovered by moving the file back and removing its tombstone.
- A tombstone is left behind in the album's notebook, recording that the image was archived, along with its content hash and where it came from upstream. Both download steps check tombstones first, even when forced, so unwanted images are not downloaded again.
- Folder and notebook modified times are restored after any change, so the pipeline's ingest step does not re-queue a curated album.
- Preview is the default. The vision-curation scripts write nothing without an explicit live flag, and one album's failure is counted rather than fatal to the batch.
A known gap
One thing does not work yet, and it is better said plainly. Discarded embedded covers can come back, because each scan re-extracts whatever is still embedded in the audio and does not consult the tombstones. An issue is open and the fix is not built. Until it is, "never downloaded again" is true of downloads, not of covers that live inside the files.
Next: back to Automated Library Management for the whole map.