mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
fix source-aware download tracking and filter/path regressions
Make download dedupe source-specific to prevent cross-provider ID collisions. Also correct non-remaster filtering, avoid FLAC tagging on non-FLAC files, and use album IDs for singles folder templating.
This commit is contained in:
@@ -189,7 +189,7 @@ func TestTrackRipPipeline(t *testing.T) {
|
||||
t.Fatalf("expected downloaded file: %v", err)
|
||||
}
|
||||
|
||||
ok, err := sqlite.IsDownloaded(ctx, "19512574")
|
||||
ok, err := sqlite.IsDownloaded(ctx, "qobuz", "19512574")
|
||||
if err != nil {
|
||||
t.Fatalf("IsDownloaded() error = %v", err)
|
||||
}
|
||||
@@ -316,3 +316,44 @@ func TestApplyQobuzArtistFiltersRepeats(t *testing.T) {
|
||||
t.Fatalf("unexpected winners: %+v", ids)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyQobuzArtistFiltersNonRemaster(t *testing.T) {
|
||||
albums := []collectionAlbum{
|
||||
{ID: "rm", Title: "Album X (Remastered)"},
|
||||
{ID: "orig", Title: "Album X"},
|
||||
}
|
||||
|
||||
filtered := applyQobuzArtistFilters("artist", albums, config.QobuzDiscographyFilterConfig{NonRemaster: true})
|
||||
if len(filtered) != 1 {
|
||||
t.Fatalf("len(filtered)=%d want 1", len(filtered))
|
||||
}
|
||||
if filtered[0].ID != "orig" {
|
||||
t.Fatalf("unexpected album kept: %+v", filtered[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrackOutputPathSinglesUsesAlbumID(t *testing.T) {
|
||||
tmp := t.TempDir()
|
||||
d := config.DefaultConfigData()
|
||||
d.Downloads.Folder = tmp
|
||||
d.Downloads.SourceSubdirectories = false
|
||||
d.Filepaths.AddSinglesToFolder = true
|
||||
d.Filepaths.FolderFormat = "{id}"
|
||||
d.Filepaths.TrackFormat = "{title}"
|
||||
d.Filepaths.RestrictCharacters = false
|
||||
|
||||
m := &Main{Config: &config.Config{File: d, Session: d}}
|
||||
meta := map[string]any{
|
||||
"album": map[string]any{
|
||||
"id": "album-123",
|
||||
"title": "Album",
|
||||
"artist": map[string]any{"name": "Artist"},
|
||||
},
|
||||
"performer": map[string]any{"name": "Artist"},
|
||||
}
|
||||
|
||||
out := m.trackOutputPath("qobuz", "track-999", "Song", "flac", meta, "", 0)
|
||||
if got, want := filepath.Dir(out), filepath.Join(tmp, "album-123"); got != want {
|
||||
t.Fatalf("trackOutputPath() dir=%q want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user