Skip to content
13 changes: 9 additions & 4 deletions sonarr/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions sonarr/series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 + "]",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading