Search Deezer and MusicBrainz together; add preview clips

Search
- Albums and songs search Deezer and MusicBrainz at once and merge the
  results: duplicates keep the Deezer copy, best word matches first.
  Deezer's search misses albums it carries (Death Magnetic) and most game
  soundtracks; MusicBrainz finds them
- MusicBrainz secondary types are shown ("Soundtrack", "Live")
- Settings: Deezer + MusicBrainz (default), Deezer only, MusicBrainz only
- Search results show which service they came from

Previews
- Songs and albums get a play button (cards, rows, detail view, editor,
  and Deezer search results) for a 30-second Deezer clip; albums play
  their most popular track
- Clips are looked up fresh (Deezer URLs expire), cached 10 minutes, and
  streamed through Canon with Range support; hidden lists stay private
- Entries from MusicBrainz or added by hand are matched to Deezer on save
  so they can preview too
- "Play previews" toggle in Settings → Profile

Tests cover merging and title/artist matching; `-tags live` runs checks
against the real services.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cdnutterandClaude Opus 5.5 committed 2026-09-25 10:10:15 -07:00
1 parent 6d92b46130
commit b09533cc00
20 files changed
+736 -19

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
package providers
import "testing"
func TestMergeResults(t *testing.T) {
dz := []Result{
{Provider: "deezer", Title: "Death Race", Subtitle: "Magnetico"},
{Provider: "deezer", Title: "Celeste (Original Soundtrack)", Subtitle: "Lena Raine"},
}
mb := []Result{
{Provider: "musicbrainz", Title: "Death Magnetic", Subtitle: "Metallica"},
{Provider: "musicbrainz", Title: "Death Race", Subtitle: "Magnetico"}, // duplicate of a Deezer hit
}
got := mergeResults("death magnetic", dz, mb)
if len(got) != 3 {
t.Fatalf("want duplicates dropped, got %d results: %+v", len(got), got)
}
if got[0].Title != "Death Magnetic" {
t.Errorf("best match should come first, got %q", got[0].Title)
}
for _, r := range got {
if r.Title == "Death Race" && r.Provider != "deezer" {
t.Errorf("duplicate should keep the Deezer copy (it has previews)")
}
}
}
func TestMatching(t *testing.T) {
titles := []struct {
a, b string
want bool
}{
{"Dreams", "Dreams (2004 Remaster)", true},
{"Death Magnetic", "Death Magnetic", true},
{"Celeste: Original Soundtrack", "Celeste (Original Soundtrack)", true},
{"Hey Ya!", "Hey Ya", true},
{"Dreams", "Sweet Dreams", false},
{"Nights", "Nights in White Satin", true},
{"Blonde", "Blond", false},
}
for _, c := range titles {
if got := sameTitle(c.a, c.b); got != c.want {
t.Errorf("sameTitle(%q, %q) = %v, want %v", c.a, c.b, got, c.want)
}
}
artists := []struct {
a, b string
want bool
}{
{"Metallica", "METALLICA", true},
{"Frank Ocean", "Frank Ocean feat. André 3000", true},
{"Queen", "Queens of the Stone Age", false},
{"", "Queen", false},
}
for _, c := range artists {
if got := sameArtist(c.a, c.b); got != c.want {
t.Errorf("sameArtist(%q, %q) = %v, want %v", c.a, c.b, got, c.want)
}
}
}