mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
fix album-level tag consistency for mixed-artist tracks
Use album artist overrides during album ripping so compilation-style tracks do not change album performer tags, and add safer disc-number fallbacks for metadata/path generation when providers omit disc fields.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"streamrip-go/internal/audio/tag"
|
||||
@@ -368,6 +369,51 @@ func TestResolveAllFailedReturnsError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildTagMetadataUsesAlbumArtistOverride(t *testing.T) {
|
||||
meta := map[string]any{
|
||||
"title": "One Step Too Far",
|
||||
"track_number": float64(15),
|
||||
"performer": map[string]any{"name": "Faithless"},
|
||||
"artist": map[string]any{"name": "Faithless"},
|
||||
"album": map[string]any{
|
||||
"id": "23324600",
|
||||
"title": "Greatest Hits (Deluxe)",
|
||||
"artist": map[string]any{"name": "Faithless"},
|
||||
},
|
||||
}
|
||||
tags := buildTagMetadata(meta, "One Step Too Far", "tidal", "23324615", ripTrackOptions{albumArtist: "Dido", albumDiscTotal: 2})
|
||||
if tags.AlbumArtist != "Dido" {
|
||||
t.Fatalf("album artist = %q, want Dido", tags.AlbumArtist)
|
||||
}
|
||||
if tags.DiscNumber != 1 {
|
||||
t.Fatalf("disc number = %d, want 1", tags.DiscNumber)
|
||||
}
|
||||
if tags.DiscTotal != 2 {
|
||||
t.Fatalf("disc total = %d, want 2", tags.DiscTotal)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrackOutputPathFallsBackToDisc1(t *testing.T) {
|
||||
tmp := t.TempDir()
|
||||
d := config.DefaultConfigData()
|
||||
d.Downloads.Folder = tmp
|
||||
d.Downloads.DiscSubdirectories = true
|
||||
d.Downloads.SourceSubdirectories = false
|
||||
cfg := &config.Config{File: d, Session: d}
|
||||
m := &Main{Config: cfg}
|
||||
|
||||
meta := map[string]any{
|
||||
"title": "Song",
|
||||
"track_number": float64(1),
|
||||
"performer": map[string]any{"name": "Dido"},
|
||||
"album": map[string]any{"id": "a", "title": "Greatest Hits", "artist": map[string]any{"name": "Dido"}},
|
||||
}
|
||||
path := m.trackOutputPath("tidal", "1", "Song", "flac", meta, filepath.Join(tmp, "Album"), 2)
|
||||
if !strings.Contains(path, string(filepath.Separator)+"Disc 1"+string(filepath.Separator)) {
|
||||
t.Fatalf("expected Disc 1 subdir in path, got %q", path)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlaylistRipPipeline(t *testing.T) {
|
||||
tmp := t.TempDir()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user