Skip to content

Commit a2db3b6

Browse files
committed
Fix Season, credit season, person
1 parent 3b44ab7 commit a2db3b6

33 files changed

+2201
-1949
lines changed

account.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ func (c *Client) GetFavoriteTVShows(
134134
// AccountFavorite type is a struct for movies or TV shows
135135
// favorite JSON request.
136136
type AccountFavorite struct {
137-
MediaType string `json:"media_type"`
138-
MediaID int64 `json:"media_id"`
139-
Favorite bool `json:"favorite"`
137+
MediaType MediaType `json:"media_type"`
138+
MediaID int64 `json:"media_id"`
139+
Favorite bool `json:"favorite"`
140140
}
141141

142142
// MarkAsFavorite this method allows you to mark a movie
@@ -316,9 +316,9 @@ func (c *Client) GetTVShowsWatchlist(
316316
// AccountWatchlist type is a struct for movies or TV shows
317317
// watchlist JSON request.
318318
type AccountWatchlist struct {
319-
MediaType string `json:"media_type"`
320-
MediaID int64 `json:"media_id"`
321-
Watchlist bool `json:"watchlist"`
319+
MediaType MediaType `json:"media_type"`
320+
MediaID int64 `json:"media_id"`
321+
Watchlist bool `json:"watchlist"`
322322
}
323323

324324
// AddToWatchlist add a movie or TV show to your watchlist.

collections.go

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,12 @@ import "fmt"
44

55
// CollectionDetails type is a struct for details JSON response.
66
type CollectionDetails struct {
7-
ID int64 `json:"id"`
8-
Name string `json:"name"`
9-
Overview string `json:"overview"`
10-
PosterPath string `json:"poster_path"`
11-
BackdropPath string `json:"backdrop_path"`
12-
Parts []struct {
13-
Adult bool `json:"adult"`
14-
BackdropPath string `json:"backdrop_path"`
15-
GenreIDs []int64 `json:"genre_ids"`
16-
ID int64 `json:"id"`
17-
MediaType string `json:"media_type"`
18-
OriginalLanguage string `json:"original_language"`
19-
OriginalTitle string `json:"original_title"`
20-
Overview string `json:"overview"`
21-
PosterPath string `json:"poster_path"`
22-
ReleaseDate string `json:"release_date"`
23-
Title string `json:"title"`
24-
Video bool `json:"video"`
25-
Popularity float32 `json:"popularity"`
26-
VoteMetrics
27-
} `json:"parts"`
7+
ID int64 `json:"id"`
8+
Name string `json:"name"`
9+
Overview string `json:"overview"`
10+
PosterPath string `json:"poster_path"`
11+
BackdropPath string `json:"backdrop_path"`
12+
Parts []MovieMedia `json:"parts"`
2813
}
2914

3015
// GetCollectionDetails get collection details by id.
@@ -48,8 +33,7 @@ func (c *Client) GetCollectionDetails(
4833

4934
// CollectionImage type is a struct for a single image.
5035
type CollectionImage struct {
51-
ImageBase
52-
Iso639_1 string `json:"iso_639_1"`
36+
ImageIso
5337
}
5438

5539
// CollectionImages type is a struct for images JSON response.

companies.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@ import (
66

77
// CompanyDetails type is a struct for details JSON response.
88
type CompanyDetails struct {
9+
CompanyInfo
910
Description string `json:"description"`
1011
Headquarters string `json:"headquarters"`
1112
Homepage string `json:"homepage"`
12-
ID int64 `json:"id"`
13-
LogoPath string `json:"logo_path"`
14-
Name string `json:"name"`
15-
OriginCountry string `json:"origin_country"`
16-
ParentCompany struct {
17-
Name string `json:"name"`
18-
ID int64 `json:"id"`
19-
LogoPath string `json:"logo_path"`
20-
} `json:"parent_company"`
13+
ParentCompany *CompanyInfo `json:"parent_company"`
2114
}
2215

2316
// GetCompanyDetails get a companies details by id.

configuration.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ func (c *Client) GetConfigurationAPI() (*ConfigurationAPI, error) {
5252
}
5353

5454
// ConfigurationCountries type is a struct for countries configuration JSON response.
55-
type ConfigurationCountries []struct {
56-
Iso3166_1 string `json:"iso_3166_1"`
57-
EnglishName string `json:"english_name"`
58-
NativeName string `json:"native_name"`
59-
}
55+
type ConfigurationCountries []Country
6056

6157
// GetConfigurationCountries get the list of countries
6258
// (ISO 3166-1 tags) used throughout TMDb.

credits.go

Lines changed: 13 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,19 @@ import (
66

77
// CreditsDetails type is a struct for credits JSON response.
88
type CreditsDetails struct {
9-
CreditType string `json:"credit_type"`
10-
Department string `json:"department"`
11-
Job string `json:"job"`
12-
Media struct {
13-
Adult bool `json:"adult,omitempty"` // Movie
14-
OriginalName string `json:"original_name,omitempty"` // TV
15-
OriginalTitle string `json:"original_title,omitempty"` // Movie
16-
ID int64 `json:"id"`
17-
Name string `json:"name,omitempty"` // TV
18-
FirstAirDate string `json:"first_air_date,omitempty"` // TV
19-
PosterPath string `json:"poster_path"`
20-
ReleaseDate string `json:"release_date,omitempty"` // Movie
21-
Title string `json:"title,omitempty"` // Movie
22-
Video bool `json:"video,omitempty"` // Movie
23-
GenreIDs []int64 `json:"genre_ids"`
24-
OriginalLanguage string `json:"original_language"`
25-
BackdropPath string `json:"backdrop_path"`
26-
Overview string `json:"overview"`
27-
OriginCountry []string `json:"origin_country,omitempty"` // TV
28-
Popularity float32 `json:"popularity"`
29-
Character string `json:"character"`
30-
Episodes []struct {
31-
AirDate string `json:"air_date"`
32-
EpisodeNumber int64 `json:"episode_number"`
33-
Name string `json:"name"`
34-
Overview string `json:"overview"`
35-
SeasonNumber int `json:"season_number"`
36-
StillPath string `json:"still_path"`
37-
} `json:"episodes,omitempty"` // TV
38-
Seasons []Season `json:"seasons,omitempty"` // TV
39-
VoteMetrics
40-
} `json:"media"`
41-
MediaType string `json:"media_type"`
42-
ID string `json:"id"`
43-
Person struct {
44-
Adult bool `json:"adult"`
45-
Gender int `json:"gender"`
46-
Name string `json:"name"`
47-
ID int64 `json:"id"`
48-
KnownFor []struct {
49-
Adult bool `json:"adult,omitempty"`
50-
BackdropPath string `json:"backdrop_path"`
51-
// GenreIDs []int64 `json:"genre_ids"` // FIXME: -> []float32
52-
// ID int64 `json:"id"` // FIXME: -> float32
53-
OriginalLanguage string `json:"original_language"`
54-
OriginalTitle string `json:"original_title,omitempty"`
55-
Overview string `json:"overview"`
56-
PosterPath string `json:"poster_path"`
57-
ReleaseDate string `json:"release_date,omitempty"`
58-
Title string `json:"title,omitempty"`
59-
Video bool `json:"video,omitempty"`
60-
Popularity float32 `json:"popularity"`
61-
MediaType string `json:"media_type"`
62-
OriginalName string `json:"original_name,omitempty"`
63-
Name string `json:"name,omitempty"`
64-
FirstAirDate string `json:"first_air_date,omitempty"`
65-
OriginCountry []string `json:"origin_country,omitempty"`
66-
VoteMetrics
67-
} `json:"known_for"`
68-
KnownForDepartment string `json:"known_for_department"`
69-
ProfilePath string `json:"profile_path"`
70-
Popularity float32 `json:"popularity"`
71-
} `json:"person"`
9+
CreditType string `json:"credit_type"`
10+
Department string `json:"department"`
11+
Job string `json:"job"`
12+
Media CreditMedia `json:"media"`
13+
MediaType MediaType `json:"media_type"`
14+
ID string `json:"id"`
15+
Person PersonMedia `json:"person"`
16+
}
17+
18+
type CreditSeason struct {
19+
Season
20+
MediaType MediaType `json:"media_type"`
21+
ShowID int64 `json:"show_id"`
7222
}
7323

7424
// GetCreditDetails get a movie or TV credit details by id.

examples/trending/main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ func main() {
2121
}
2222

2323
for _, result := range trending.Results {
24-
fmt.Println(result.Title)
24+
switch media := result.(type) {
25+
case tmdb.MovieMedia:
26+
fmt.Println(media.Title)
27+
case tmdb.TVShowMedia:
28+
fmt.Println(media.OriginalName)
29+
}
2530
}
2631

2732
fmt.Println("------")
@@ -38,6 +43,11 @@ func main() {
3843
}
3944

4045
for _, result := range trending.Results {
41-
fmt.Println(result.Name)
46+
switch media := result.(type) {
47+
case tmdb.MovieMedia:
48+
fmt.Println(media.Title)
49+
case tmdb.TVShowMedia:
50+
fmt.Println(media.OriginalName)
51+
}
4252
}
4353
}

find.go

Lines changed: 5 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,83 +4,11 @@ import "fmt"
44

55
// FindByID type is a struct for find JSON response.
66
type FindByID struct {
7-
MovieResults []struct {
8-
Adult bool `json:"adult"`
9-
BackdropPath string `json:"backdrop_path"`
10-
GenreIDs []int64 `json:"genre_ids"`
11-
ID int64 `json:"id"`
12-
OriginalLanguage string `json:"original_language"`
13-
OriginalTitle string `json:"original_title"`
14-
Overview string `json:"overview"`
15-
PosterPath string `json:"poster_path"`
16-
ReleaseDate string `json:"release_date"`
17-
Title string `json:"title"`
18-
Video bool `json:"video"`
19-
Popularity float32 `json:"popularity"`
20-
VoteMetrics
21-
} `json:"movie_results,omitempty"`
22-
PersonResults []struct {
23-
Adult bool `json:"adult"`
24-
Gender int `json:"gender"`
25-
Name string `json:"name"`
26-
ID int64 `json:"id"`
27-
KnownFor []struct {
28-
Adult bool `json:"adult,omitempty"` // Movie
29-
BackdropPath string `json:"backdrop_path"`
30-
FirstAirDate string `json:"first_air_date,omitempty"` // TV
31-
// GenreIDs []int64 `json:"genre_ids"` // FIXME: -> []float32
32-
// ID int64 `json:"id"` // FIXME: -> float32
33-
MediaType string `json:"media_type"`
34-
Name string `json:"name,omitempty"` // TV
35-
OriginalLanguage string `json:"original_language"`
36-
OriginalName string `json:"original_name,omitempty"` // TV
37-
OriginalTitle string `json:"original_title,omitempty"` // Movie
38-
OriginCountry []string `json:"origin_country,omitempty"` // TV
39-
Overview string `json:"overview"`
40-
Popularity float32 `json:"popularity"`
41-
PosterPath string `json:"poster_path"`
42-
ReleaseDate string `json:"release_date,omitempty"` // Movie
43-
Title string `json:"title,omitempty"` // Movie
44-
Video bool `json:"video,omitempty"` // Movie
45-
VoteMetrics
46-
} `json:"known_for"`
47-
KnownForDepartment string `json:"known_for_department"`
48-
ProfilePath string `json:"profile_path"`
49-
Popularity float32 `json:"popularity"`
50-
} `json:"person_results,omitempty"`
51-
TvResults []struct {
52-
OriginalName string `json:"original_name"`
53-
ID int64 `json:"id"`
54-
Name string `json:"name"`
55-
FirstAirDate string `json:"first_air_date"`
56-
PosterPath string `json:"poster_path"`
57-
GenreIDs []int64 `json:"genre_ids"`
58-
OriginalLanguage string `json:"original_language"`
59-
BackdropPath string `json:"backdrop_path"`
60-
Overview string `json:"overview"`
61-
OriginCountry []string `json:"origin_country"`
62-
Popularity float32 `json:"popularity"`
63-
VoteMetrics
64-
} `json:"tv_results,omitempty"`
65-
TvEpisodeResults []struct {
66-
AirDate string `json:"air_date"`
67-
EpisodeNumber int `json:"episode_number"`
68-
ID int64 `json:"id"`
69-
Name string `json:"name"`
70-
Overview string `json:"overview"`
71-
ProductionCode string `json:"production_code"`
72-
SeasonNumber int `json:"season_number"`
73-
ShowID int64 `json:"show_id"`
74-
StillPath string `json:"still_path"`
75-
VoteMetrics
76-
} `json:"tv_episode_results,omitempty"`
77-
TvSeasonResults []struct {
78-
AirDate string `json:"air_date"`
79-
Name string `json:"name"`
80-
ID int64 `json:"id"`
81-
SeasonNumber int `json:"season_number"`
82-
ShowID int64 `json:"show_id"`
83-
} `json:"tv_season_results,omitempty"`
7+
MovieResults []MovieMedia `json:"movie_results"`
8+
PersonResults []PersonResults `json:"person_results"`
9+
TvResults []TVShowMedia `json:"tv_results"`
10+
TvEpisodeResults []TVEpisodeMedia `json:"tv_episode_results"`
11+
TvSeasonResults []TVSeasonMedia `json:"tv_season_results"`
8412
}
8513

8614
// GetFindByID the find method makes it easy to search for objects in our

keywords.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,8 @@ func (c *Client) GetKeywordDetails(
3030

3131
// KeywordMovies type is a struct for movies that belong to a keyword JSON response.
3232
type KeywordMovies struct {
33-
ID int64 `json:"id"`
34-
Results []struct {
35-
Adult bool `json:"adult"`
36-
BackdropPath string `json:"backdrop_path"`
37-
GenreIDs []int64 `json:"genre_ids"`
38-
ID int64 `json:"id"`
39-
OriginalLanguage string `json:"original_language"`
40-
OriginalTitle string `json:"original_title"`
41-
Overview string `json:"overview"`
42-
PosterPath string `json:"poster_path"`
43-
ReleaseDate string `json:"release_date"`
44-
Title string `json:"title"`
45-
Video bool `json:"video"`
46-
Popularity float32 `json:"popularity"`
47-
VoteMetrics
48-
} `json:"results"`
33+
ID int64 `json:"id"`
34+
Results []Movie `json:"results"`
4935
PaginatedResultsMeta
5036
}
5137

list.go

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,28 @@ import (
77

88
// ListDetails type is a struct for details JSON response.
99
type ListDetails struct {
10-
CreatedBy string `json:"created_by"`
11-
Description string `json:"description"`
12-
FavoriteCount int64 `json:"favorite_count"`
13-
ID int64 `json:"id"`
14-
Items []struct {
15-
Adult bool `json:"adult,omitempty"` // Movie
16-
BackdropPath string `json:"backdrop_path"`
17-
FirstAirDate string `json:"first_air_date,omitempty"` // TV
18-
GenreIDs []int64 `json:"genre_ids"`
19-
ID int64 `json:"id"`
20-
MediaType string `json:"media_type"`
21-
Name string `json:"name,omitempty"` // TV
22-
OriginalLanguage string `json:"original_language"`
23-
OriginalName string `json:"original_name,omitempty"` // TV
24-
OriginalTitle string `json:"original_title,omitempty"` // Movie
25-
OriginCountry []string `json:"origin_country,omitempty"` // TV
26-
Overview string `json:"overview"`
27-
Popularity float32 `json:"popularity"`
28-
PosterPath string `json:"poster_path"`
29-
ReleaseDate string `json:"release_date,omitempty"` // Movie
30-
Title string `json:"title,omitempty"` // Movie
31-
Video bool `json:"video,omitempty"` // Movie
10+
List
11+
CreatedBy string `json:"created_by"`
12+
Items []struct {
13+
Adult bool `json:"adult,omitempty"` // Movie
14+
BackdropPath string `json:"backdrop_path"`
15+
FirstAirDate string `json:"first_air_date,omitempty"` // TV
16+
GenreIDs []int64 `json:"genre_ids"`
17+
ID int64 `json:"id"`
18+
MediaType MediaType `json:"media_type"`
19+
Name string `json:"name,omitempty"` // TV
20+
OriginalLanguage string `json:"original_language"`
21+
OriginalName string `json:"original_name,omitempty"` // TV
22+
OriginalTitle string `json:"original_title,omitempty"` // Movie
23+
OriginCountry []string `json:"origin_country,omitempty"` // TV
24+
Overview string `json:"overview"`
25+
Popularity float32 `json:"popularity"`
26+
PosterPath string `json:"poster_path"`
27+
ReleaseDate string `json:"release_date,omitempty"` // Movie
28+
Title string `json:"title,omitempty"` // Movie
29+
Video bool `json:"video,omitempty"` // Movie
3230
VoteMetrics
3331
} `json:"items"`
34-
ItemCount int64 `json:"item_count"`
35-
Iso639_1 string `json:"iso_639_1"`
36-
Name string `json:"name"`
37-
PosterPath string `json:"poster_path"`
3832
}
3933

4034
// GetListDetails get the details of a list.

0 commit comments

Comments
 (0)