diff --git a/sonarr/series.go b/sonarr/series.go index c31c39a..6ac5773 100644 --- a/sonarr/series.go +++ b/sonarr/series.go @@ -117,9 +117,10 @@ type AlternateTitle struct { // Season is part of AddSeriesInput and Queue and used in a few places. type Season struct { - Monitored bool `json:"monitored"` - SeasonNumber int `json:"seasonNumber"` - Statistics *Statistics `json:"statistics,omitempty"` + Monitored bool `json:"monitored"` + SeasonNumber int `json:"seasonNumber"` + Statistics *Statistics `json:"statistics,omitempty"` + Images []*starr.Image `json:"images,omitempty"` } // Statistics is part of AddSeriesInput and Queue. @@ -161,6 +162,8 @@ func (s *Sonarr) GetSeriesContext(ctx context.Context, tvdbID int64) ([]*Series, req.Query.Add("tvdbId", starr.Str(tvdbID)) } + req.Query.Add("includeSeasonImages", "true") + if err := s.GetInto(ctx, req, &output); err != nil { return nil, fmt.Errorf("api.Get(%s): %w", &req, err) } @@ -227,7 +230,9 @@ func (s *Sonarr) GetSeriesByID(seriesID int64) (*Series, error) { func (s *Sonarr) GetSeriesByIDContext(ctx context.Context, seriesID int64) (*Series, error) { var output Series - req := starr.Request{URI: path.Join(bpSeries, starr.Str(seriesID))} + req := starr.Request{URI: path.Join(bpSeries, starr.Str(seriesID)), Query: make(url.Values)} + req.Query.Add("includeSeasonImages", "true") + if err := s.GetInto(ctx, req, &output); err != nil { return nil, fmt.Errorf("api.Get(%s): %w", &req, err) } diff --git a/sonarr/series_test.go b/sonarr/series_test.go index 04a7a1b..6ee4bd8 100644 --- a/sonarr/series_test.go +++ b/sonarr/series_test.go @@ -275,7 +275,7 @@ func TestGetAllSeries(t *testing.T) { tests := []*starrtest.MockData{ { Name: "200", - ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series"), + ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series?includeSeasonImages=true"), ExpectedMethod: "GET", ResponseStatus: 200, ResponseBody: listSeries, @@ -521,7 +521,7 @@ func TestGetAllSeries(t *testing.T) { }, { Name: "404", - ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series"), + ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series?includeSeasonImages=true"), ExpectedMethod: "GET", ResponseStatus: 404, ResponseBody: starrtest.BodyNotFound, @@ -551,7 +551,7 @@ func TestGetSeries(t *testing.T) { tests := []*starrtest.MockData{ { Name: "200", - ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series?tvdbId=360893"), + ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series?includeSeasonImages=true&tvdbId=360893"), ExpectedMethod: "GET", ResponseStatus: 200, ResponseBody: "[" + secondSeries + "]", @@ -656,7 +656,7 @@ func TestGetSeries(t *testing.T) { }, { Name: "404", - ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series?tvdbId=360893"), + ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series?includeSeasonImages=true&tvdbId=360893"), ExpectedMethod: "GET", ResponseStatus: 404, ResponseBody: starrtest.BodyNotFound, @@ -687,7 +687,7 @@ func TestGetSeriesByID(t *testing.T) { tests := []*starrtest.MockData{ { Name: "200", - ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series", "2"), + ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series", "2?includeSeasonImages=true"), ExpectedMethod: "GET", ResponseStatus: 200, ResponseBody: secondSeries, @@ -790,7 +790,7 @@ func TestGetSeriesByID(t *testing.T) { }, { Name: "404", - ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series", "2"), + ExpectedPath: path.Join("/", starr.API, sonarr.APIver, "series", "2?includeSeasonImages=true"), ExpectedMethod: "GET", ResponseStatus: 404, ResponseBody: starrtest.BodyNotFound,