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>
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
//go:build live
|
|
|
|
// Live checks against the real music services: go test -tags live ./internal/providers
|
|
package providers
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestLiveMusic(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
|
defer cancel()
|
|
reg := NewRegistry(func(context.Context) Credentials { return Credentials{} })
|
|
albums, _ := reg.For(ctx, "album")
|
|
|
|
for _, c := range []struct{ query, want string }{
|
|
{"death magnetic", "Death Magnetic"},
|
|
{"super mario galaxy soundtrack", "Super Mario Galaxy Original Soundtrack"},
|
|
{"chrono trigger original soundtrack", "Chrono Trigger Original Soundtrack"},
|
|
} {
|
|
res, err := albums.Search(ctx, c.query)
|
|
if err != nil {
|
|
t.Fatalf("%s: %v", c.query, err)
|
|
}
|
|
found := -1
|
|
for i, r := range res {
|
|
if r.Title == c.want {
|
|
found = i
|
|
break
|
|
}
|
|
}
|
|
t.Logf("%q → %q at #%d (%s, type %q)", c.query, c.want, found+1, pick(res, found).Provider, pick(res, found).Extra["type"])
|
|
if found < 0 || found > 2 {
|
|
t.Errorf("%q: want %q in the top 3", c.query, c.want)
|
|
}
|
|
}
|
|
|
|
ref, err := reg.MatchDeezer(ctx, "album", "Death Magnetic", "Metallica")
|
|
t.Logf("Death Magnetic → Deezer %q", ref)
|
|
if err != nil || !strings.HasPrefix(ref, "album:") {
|
|
t.Fatalf("match: %q %v", ref, err)
|
|
}
|
|
u, err := reg.DeezerPreview(ctx, ref)
|
|
if err != nil || !strings.HasPrefix(u, "https://") {
|
|
t.Fatalf("preview: %q %v", u, err)
|
|
}
|
|
t.Logf("preview URL host: %s", strings.SplitN(strings.TrimPrefix(u, "https://"), "/", 2)[0])
|
|
|
|
song, err := reg.MatchDeezer(ctx, "song", "Dreams", "Fleetwood Mac")
|
|
t.Logf("Dreams → Deezer %q", song)
|
|
if err != nil || song == "" {
|
|
t.Errorf("song match: %q %v", song, err)
|
|
}
|
|
}
|
|
|
|
func pick(res []Result, i int) Result {
|
|
if i < 0 {
|
|
return Result{}
|
|
}
|
|
return res[i]
|
|
}
|