- Every provider can look an entry up again by its ID (TMDB, TheTVDB,
IGDB, Deezer, MusicBrainz, Wikipedia); search and lookup share parsing
- POST /api/items/{id}/refresh re-applies title, subtitle, year,
description, link, details and artwork. Kept: the "why" note, rank,
theater production/venue/cast and a theater entry's year, the Deezer
preview match. Empty source fields don't erase existing values
- New items.image_custom column (migration 4; existing uploads marked)
records artwork the owner chose; refresh keeps it unless asked
- Refused for custom lists and hand-added entries; entries the source
dropped are reported, and a refresh whose title shares no words with
the current one is rejected as a likely bad ID
- Editor: refresh button per row (asks about the owner's own artwork),
and "Refresh all" with a confirm step, replace-my-art checkbox,
progress with Stop, and a summary of problems
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
2.2 KiB
Go
79 lines
2.2 KiB
Go
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)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSameThing(t *testing.T) {
|
|
for _, c := range []struct {
|
|
a, b string
|
|
want bool
|
|
}{
|
|
{"Dreams", "Dreams (2004 Remaster)", true},
|
|
{"DM (old)", "Death Magnetic", false},
|
|
{"Blonde", "Blond", false},
|
|
{"Hamilton", "Getting On", false},
|
|
{"The Legend of Zelda: Breath of the Wild", "Zelda: Breath of the Wild", true},
|
|
{"", "Anything", true},
|
|
} {
|
|
if got := SameThing(c.a, c.b); got != c.want {
|
|
t.Errorf("SameThing(%q, %q) = %v, want %v", c.a, c.b, got, c.want)
|
|
}
|
|
}
|
|
}
|