diff --git a/tv_seasons.go b/tv_seasons.go index bb79042..aa2fe4e 100644 --- a/tv_seasons.go +++ b/tv_seasons.go @@ -46,6 +46,7 @@ type TVSeasonDetails struct { *TVSeasonExternalIDsAppend *TVSeasonImagesAppend *TVSeasonVideosAppend + *TVSeasonTranslationsAppend } // TVSeasonCreditsAppend type is a struct @@ -66,6 +67,27 @@ type TVSeasonImagesAppend struct { Images *TVSeasonImages `json:"images,omitempty"` } +// TVSeasonTranslationsAppend type is a struct +// for translations in append to response. +type TVSeasonTranslationsAppend struct { + Translations *TVSeasonTranslations `json:"translations,omitempty"` +} + +// TVSeasonTranslations type is a struct +type TVSeasonTranslations struct { + ID int64 `json:"id,omitempty"` + Translations []struct { + Iso31661 string `json:"iso_3166_1"` + Iso6391 string `json:"iso_639_1"` + Name string `json:"name"` + EnglishName string `json:"english_name"` + Data struct { + Name string `json:"name"` + Overview string `json:"overview"` + } `json:"data"` + } `json:"translations"` +} + // TVSeasonVideosAppend type is a struct // for videos in append to response. type TVSeasonVideosAppend struct { @@ -324,3 +346,26 @@ func (c *Client) GetTVSeasonVideos( } return &tvSeasonVideos, nil } + +// GetTVSeasonTranslations get the translation data for an season. +// +// https://developer.themoviedb.org/reference/tv-season-translations +func (c *Client) GetTVSeasonTranslations( + id int, + seasonNumber int, +) (*TVSeasonTranslations, error) { + tmdbURL := fmt.Sprintf( + "%s%s%d%s%d/translations?api_key=%s", + baseURL, + tvURL, + id, + tvSeasonURL, + seasonNumber, + c.apiKey, + ) + tvSeasonTranslations := TVSeasonTranslations{} + if err := c.get(tmdbURL, &tvSeasonTranslations); err != nil { + return nil, err + } + return &tvSeasonTranslations, nil +} diff --git a/tv_seasons_test.go b/tv_seasons_test.go index a7df759..e785ac0 100644 --- a/tv_seasons_test.go +++ b/tv_seasons_test.go @@ -108,3 +108,14 @@ func (suite *TMBDTestSuite) TestGetTVSeasonVideosWithOptions() { suite.Nil(err) suite.NotNil(tv.ID) } + +func (suite *TMBDTestSuite) TestGetTVSeasonTranslations() { + got, err := suite.client.GetTVSeasonTranslations(gotID, 1) + suite.Nil(err) + suite.Equal(int64(gotSeasonID), got.ID) +} + +func (suite *TMBDTestSuite) TestGetTVSeasonTranslationsFail() { + _, err := suite.client.GetTVSeasonTranslations(0, 1) + suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error()) +}