Posters: re-place after a resize, measure cell size without padding, log failed posters

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 00:14:50 +02:00
co-authored by Claude Sonnet 5.5
parent b40ee8b61c
commit 9edd62634f
5 changed files with 111 additions and 4 deletions
+16
View File
@@ -8,6 +8,7 @@ import (
"image/color"
_ "image/jpeg" // poster formats
_ "image/png"
"net/url"
"os/exec"
"strings"
"time"
@@ -503,6 +504,8 @@ func (a *App) loadCover(ref coverRef, done func(*image.RGBA, error)) {
delete(c.waiting, ref.key)
if err != nil {
c.failed[ref.key] = time.Now()
// Say why in the log: a poster that silently never shows up is hard to diagnose.
a.logs.add(levelWarn, "Poster not loaded ("+posterSource(ref.key)+"): "+err.Error())
} else {
if len(c.imgs) >= maxCoverCache {
c.imgs = map[string]*image.RGBA{} // simple bound; posters are cheap to fetch again
@@ -518,3 +521,16 @@ func (a *App) loadCover(ref coverRef, done func(*image.RGBA, error)) {
})
}()
}
// posterSource describes where a poster key points, for the log: the host and
// file name of a remote image, or the path on the Radarr/Sonarr instance.
func posterSource(key string) string {
if _, local, ok := strings.Cut(key, "|"); ok {
key = local
}
if u, err := url.Parse(key); err == nil && u.Host != "" {
return u.Host + u.Path
}
path, _, _ := strings.Cut(key, "?")
return path
}