From e336bb96f106719dbbee061d5168d42f1752dc97 Mon Sep 17 00:00:00 2001 From: Joren Date: Sun, 12 Jul 2026 03:28:27 +0200 Subject: [PATCH] fix: set album track totals --- internal/app/app.go | 3 +++ internal/app/app_test.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/internal/app/app.go b/internal/app/app.go index c5fef73..4863a54 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -1399,6 +1399,9 @@ func buildTagMetadata(trackMeta map[string]any, title, source, trackID string, o if trackTotal == 0 { trackTotal = jsonutil.IntFromAny(trackMeta["track_total"]) } + if trackTotal == 0 && opts.total > 0 { + trackTotal = opts.total + } if opts.forPlaylist && opts.total > 0 { trackTotal = opts.total } diff --git a/internal/app/app_test.go b/internal/app/app_test.go index 14772e1..364dc72 100644 --- a/internal/app/app_test.go +++ b/internal/app/app_test.go @@ -490,6 +490,22 @@ func TestBuildTagMetadataUsesAlbumArtistOverride(t *testing.T) { } } +func TestBuildTagMetadataUsesAlbumContextTrackTotal(t *testing.T) { + meta := map[string]any{ + "title": "ideal world (feat. higma)", + "track_number": float64(2), + "performer": map[string]any{"name": "Seren Azuma"}, + "album": map[string]any{ + "title": "YUKIHASU", + "artist": map[string]any{"name": "Seren Azuma"}, + }, + } + tags := buildTagMetadata(meta, "ideal world (feat. higma)", "qobuz", "295525879", ripTrackOptions{total: 11}) + if tags.TrackTotal != 11 { + t.Fatalf("track total = %d, want 11", tags.TrackTotal) + } +} + func TestBuildTagMetadataPlaylistOmitsDiscTags(t *testing.T) { meta := map[string]any{ "title": "One Step Too Far",