Fix Emby person image routing and search dropdown dismissal

This commit is contained in:
truewhile
2026-09-12 16:55:53 +08:00
parent df654ea47b
commit e337d9932b
6 changed files with 96 additions and 28 deletions
+2 -2
View File
@@ -96,10 +96,10 @@ func TestResolveMediaPeopleFetchesTMDbAndCaches(t *testing.T) {
if hits.Load() != 1 {
t.Fatalf("TMDb credits hits=%d want 1", hits.Load())
}
if people[0]["Id"] != "person~tmdb~101" || people[0]["PrimaryImageTag"] != "tmdb:/actor.jpg" {
if people[0]["Id"] != "person~tmdb~101" || people[0]["PrimaryImageTag"] != "tmdb:/actor.jpg?p2" {
t.Fatalf("unexpected person: %#v", people[0])
}
raw, err := svc.PersonImageURL(t.Context(), "person~tmdb~101", "Primary", "tmdb:/actor.jpg")
raw, err := svc.PersonImageURL(t.Context(), "person~tmdb~101", "Primary", "tmdb:/actor.jpg?p2")
if err != nil {
t.Fatal(err)
}
+8 -4
View File
@@ -10,9 +10,10 @@ import (
)
const (
tmdbPersonIDPrefix = "person~tmdb~"
tmdbProfileTagPrefix = "tmdb:"
tmdbPeopleMax = 80
tmdbPersonIDPrefix = "person~tmdb~"
tmdbProfileTagPrefix = "tmdb:"
tmdbProfileTagVersion = "p2"
tmdbPeopleMax = 80
)
var tmdbProfilePathRE = regexp.MustCompile(`^/[A-Za-z0-9._-]+$`)
@@ -220,7 +221,7 @@ func tmdbProfileTag(profilePath string) string {
if !tmdbProfilePathRE.MatchString(profilePath) {
return ""
}
return tmdbProfileTagPrefix + profilePath
return tmdbProfileTagPrefix + profilePath + "?" + tmdbProfileTagVersion
}
func tmdbProfilePathFromTag(tag string) string {
@@ -229,6 +230,9 @@ func tmdbProfilePathFromTag(tag string) string {
return ""
}
profilePath := strings.TrimPrefix(tag, tmdbProfileTagPrefix)
if idx := strings.IndexByte(profilePath, '?'); idx >= 0 {
profilePath = profilePath[:idx]
}
if !tmdbProfilePathRE.MatchString(profilePath) {
return ""
}
+1 -1
View File
@@ -47,7 +47,7 @@ func TestTMDbGetPeopleAndProfileImage(t *testing.T) {
if people[0]["Id"] != "person~tmdb~101" || people[0]["Role"] != "主角" {
t.Fatalf("unexpected actor: %#v", people[0])
}
if people[0]["PrimaryImageTag"] != "tmdb:/actor.jpg" {
if people[0]["PrimaryImageTag"] != "tmdb:/actor.jpg?p2" {
t.Fatalf("unexpected actor image tag: %#v", people[0])
}
if got := provider.ProfileImageURL("/actor.jpg"); got != "https://image.example/t/p/w300/actor.jpg" {