harden deezer auth and lyrics tagging behavior

This commit is contained in:
2026-04-21 11:14:57 +02:00
parent 26c9d50fac
commit 9ebddc8316
8 changed files with 1224 additions and 23 deletions

View File

@@ -464,6 +464,77 @@ func TestPlaylistRipPipeline(t *testing.T) {
}
}
func TestPlaylistRipUsesSourceSubdirectory(t *testing.T) {
tmp := t.TempDir()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte("audio-bytes"))
}))
defer ts.Close()
d := config.DefaultConfigData()
d.Downloads.Folder = tmp
d.Downloads.Concurrency = false
d.Downloads.SourceSubdirectories = true
d.Filepaths.RestrictCharacters = false
cfg := &config.Config{File: d, Session: d}
sqlite, err := store.NewSQLite(filepath.Join(tmp, "db.sqlite"))
if err != nil {
t.Fatalf("NewSQLite() error = %v", err)
}
defer func() { _ = sqlite.Close() }()
m := &Main{
Config: cfg,
Providers: map[string]provider.Client{
"qobuz": &fakePlaylistProvider{url: ts.URL},
},
Store: sqlite,
DL: download.NewWithOptions(true, false),
Tagger: noopTagger{},
}
ctx := context.Background()
if err = m.AddByID(ctx, "qobuz", "playlist", "pl1"); err != nil {
t.Fatalf("AddByID() error = %v", err)
}
if err = m.Resolve(ctx); err != nil {
t.Fatalf("Resolve() error = %v", err)
}
if err = m.Rip(ctx); err != nil {
t.Fatalf("Rip() error = %v", err)
}
folder := filepath.Join(tmp, "Qobuz", "Road Trip")
if _, err = os.Stat(filepath.Join(folder, "01. Artist - Track One.flac")); err != nil {
t.Fatalf("missing first playlist track in source subdir: %v", err)
}
}
func TestRipPlaylistRequiresDeezerARL(t *testing.T) {
d := config.DefaultConfigData()
m := &Main{Config: &config.Config{File: d, Session: d}}
err := m.ripPlaylist(context.Background(), nil, "deezer", "pl1", map[string]any{
"name": "Road Trip",
"tracks": map[string]any{"items": []any{map[string]any{"id": "p1"}}},
})
if err == nil || !strings.Contains(err.Error(), "deezer") {
t.Fatalf("expected deezer arl error, got %v", err)
}
}
func TestRipAlbumRequiresDeezerARL(t *testing.T) {
d := config.DefaultConfigData()
m := &Main{Config: &config.Config{File: d, Session: d}}
err := m.ripAlbum(context.Background(), nil, "deezer", "alb1", map[string]any{})
if err == nil || !strings.Contains(err.Error(), "deezer") {
t.Fatalf("expected deezer arl error, got %v", err)
}
}
func TestApplyQobuzArtistFiltersRepeats(t *testing.T) {
albums := []collectionAlbum{
{ID: "a1", Title: "Album X", BitDepth: 16, Sampling: 44.1, Explicit: false},