Skip to content

Keep the album edition in the title, tags and folder name - #1027

Open
sjbrownrigg wants to merge 1 commit into
nathom:devfrom
sjbrownrigg:feat/album-edition-in-title
Open

Keep the album edition in the title, tags and folder name#1027
sjbrownrigg wants to merge 1 commit into
nathom:devfrom
sjbrownrigg:feat/album-edition-in-title

Conversation

@sjbrownrigg

Copy link
Copy Markdown

Two different editions of the same album can download into the same folder and merge together.

A standard and a deluxe release share a title, a year and often a format, so every key available to folder_format renders identically for both, and the second download lands on top of the first. I ended up with one folder holding a 25-track edition loose in the root and a 39-track 3-disc edition in subfolders, which took a while to work out.

Keep the edition

Qobuz returns it in a version field, which is currently discarded. This folds it into the album title unless the title already says it, so Into the Gap becomes Into the Gap (Deluxe Edition) — in the ALBUM tag and therefore in the folder name — and keeps it on AlbumMetadata as well.

FLAC also gets a standard Vorbis VERSION field. "version" is deliberately last in METADATA_TYPES: MP3_KEY and MP4_KEY are built by zipping that tuple against their own positional key tuples, so a trailing entry with no counterpart is dropped for those formats, while FLAC_KEY is a dict comprehension and picks it up. Verified the MP3/MP4 mappings are unshifted (title→TIT2/©nam, album→TALB/©alb, isrc→TSRC/…).

{tracktotal} and {version} for folder_format

Version alone is not always enough. The two editions that collided for me are both called "Deluxe Edition":

id title version format
25-track vegp0b121e5it Into the Gap Deluxe Edition 1984 · FLAC 16/44.1
39-track grid9ukxx5fx1 Into the Gap Deluxe Edition 1984 · FLAC 16/44.1

Every existing key is identical across those two. {tracktotal} tells them apart and stays readable, which {id} — the only currently-unique option — does not:

Thompson Twins - Into the Gap (Deluxe Edition) (1984) [FLAC] [16B-44.1kHz] [25 tracks]
Thompson Twins - Into the Gap (Deluxe Edition) (1984) [FLAC] [16B-44.1kHz] [39 tracks]

Both are now exposed to folder_format, alongside the existing keys.

Compatibility note

Folding the version into the title changes folder names for releases that have one, so an existing library will not match what this generates. Nothing breaks day to day, since the downloads database prevents re-downloading, but re-fetching an album can create a second folder under the new naming. Worth deciding deliberately — I think the collision is the worse problem, but it is a behaviour change rather than a pure fix, and I am happy to put the title change behind an option if you would prefer.

{tracktotal} and {version} on their own are purely additive: nothing changes unless they are added to folder_format.

Testing

Both editions resolved from live metadata:

vegp0b121e5it  album='Into the Gap (Deluxe Edition)'  version='Deluxe Edition'
grid9ukxx5fx1  album='Into the Gap (Deluxe Edition)'  version='Deluxe Edition'

with {tracktotal}:
  ... [16B-44.1kHz] [25 tracks]
  ... [16B-44.1kHz] [39 tracks]

pytest tests/ unchanged: 59 passed, 1 failed, and that failure (test_meta.py::test_album_metadata_qobuz, a genre assertion) also fails on an unmodified dev.

Two different editions of the same album could download into the same
folder and merge together. A standard and a deluxe release share a
title, a year and often a format, so every key available to
folder_format rendered identically for both and the second download
landed on top of the first.

Qobuz returns the edition in a "version" field, which was discarded.
Keep it: fold it into the album title unless the title already says it,
so "Into the Gap" becomes "Into the Gap (Deluxe Edition)" in the ALBUM
tag and in the folder name, and retain it on AlbumMetadata.

Expose "tracktotal" and "version" to folder_format as well. Two
same-named editions can still collide -- a 25-track and a 39-track
release can both be titled "Deluxe Edition" -- and "tracktotal" tells
them apart without falling back to the opaque album id.

Add "version" to METADATA_TYPES so FLAC gets a standard Vorbis VERSION
field. It is deliberately last in the tuple: MP3_KEY and MP4_KEY are
built by zipping METADATA_TYPES against their own positional key
tuples, so a trailing entry with no counterpart is dropped for those
formats, while FLAC_KEY is a comprehension and picks it up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit 15cbb8a)
@frilled-jelly

Copy link
Copy Markdown

I think this is the problem I'm having.
I noticed it first with 'O My Heart', 'O My Heart (Live Sessions)', and 'O My Heart (Extended Editions)' all going into 'O My Heart' folder, with the album name metadata reduced to 'O My Heart' as well, even for tracks that aren't part of the base album. Mixes up the folders, and Navidrome treats them as one album (that is what the local data says). Adding {id} to the album output name fixes it- somewhat, I still have to manually rename the folder and alter the album metadata, but at least they're not confusingly mixed into one folder (and I don't have to find the different cover.png elsewhere).
I hope something gets worked out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants