Series drill-down: season posters

The drill-down reads the series with includeSeasonImages=true (Sonarr
only sends season posters when asked, as TheTVDB links). A selected
season or episode shows its season's poster; without one, or when it
cannot be loaded, the series poster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 23:42:49 +02:00
co-authored by Claude Opus 5.5
parent 73efe279d4
commit ca28a3c9bb
7 changed files with 92 additions and 2 deletions
+5 -1
View File
@@ -46,6 +46,9 @@ type Season struct {
SeasonNumber int `json:"seasonNumber"`
Monitored bool `json:"monitored"`
Statistics Statistics `json:"statistics"`
// Images are the season's posters, only filled by GetSeries; Sonarr keeps
// no copy of them, so they only have a remote URL (TheTVDB).
Images []arr.Image `json:"images,omitempty"`
}
// Statistics are the episode counts Sonarr reports for library series.
@@ -179,7 +182,8 @@ func (c *Client) SearchEpisode(ctx context.Context, episodeID int) error {
// GetSeries fetches one library series.
func (c *Client) GetSeries(ctx context.Context, id int) (Series, error) {
var s Series
err := c.Do(ctx, http.MethodGet, "series/"+strconv.Itoa(id), nil, nil, &s)
// Season posters are only sent when asked for.
err := c.Do(ctx, http.MethodGet, "series/"+strconv.Itoa(id), url.Values{"includeSeasonImages": {"true"}}, nil, &s)
return s, err
}
+20
View File
@@ -198,3 +198,23 @@ func TestCalendar(t *testing.T) {
t.Errorf("episode not decoded: %+v", e)
}
}
func TestGetSeriesAsksForSeasonPosters(t *testing.T) {
var query string
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
query = r.URL.RawQuery
w.Write([]byte(`{"id":7,"title":"Andor","seasons":[{"seasonNumber":1,"monitored":true,
"images":[{"coverType":"poster","remoteUrl":"https://artworks.thetvdb.com/banners/seasons/1.jpg"}]}]}`))
}))
defer srv.Close()
s, err := NewClient(srv.URL, "k").GetSeries(t.Context(), 7)
if err != nil {
t.Fatal(err)
}
if query != "includeSeasonImages=true" {
t.Errorf("query %q", query)
}
if len(s.Seasons) != 1 || len(s.Seasons[0].Images) != 1 || s.Seasons[0].Images[0].RemoteURL == "" {
t.Errorf("season images %+v", s.Seasons)
}
}