mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 12:06:38 +08:00
Fix Emby person image routing and search dropdown dismissal
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 ""
|
||||
}
|
||||
|
||||
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user