1 package tmdb 2 3 import ( 4 "fmt" 5 "net/url" 6 ) 7 8 // Episode contains basic inforamtion for an episode 9 type Episode struct { 10 AirDate string `json:"air_date"` 11 EpisodeNumber int64 `json:"episode_number"` 12 ID int64 `json:"id"` 13 Name string `json:"name"` 14 Overview string `json:"overview"` 15 ProductionCode string `json:"production_code"` 16 SeasonNumber int64 `json:"season_number"` 17 StillPath *string `json:"still_path"` 18 VoteAverage float64 `json:"vote_average"` 19 VoteCount int64 `json:"vote_count"` 20 } 21 22 // TVShow contains all of the information about a TV Show 23 type TVShow struct { 24 BackdropPath *string `json:"backdrop_path"` 25 CreatedBy []struct { 26 ID int64 `json:"id"` 27 CreditID string `json:"credit_id"` 28 Name string `json:"name"` 29 Gender int64 `json:"gender"` 30 ProfilePath *string `json:"profile_path"` 31 } `json:"created_by"` 32 EpisodeRunTime []int64 `json:"episode_run_time"` 33 FirstAirDate string `json:"first_air_date"` 34 Genres Genres `json:"genres"` 35 Homepage string `json:"homepage"` 36 ID int64 `json:"id"` 37 InProduction bool `json:"in_production"` 38 Languages []string `json:"languages"` 39 LastAirDate string `json:"last_air_date"` 40 LastEpisodeToAir Episode `json:"last_episode_to_air"` 41 Name string `json:"name"` 42 Networks []ProductionCompany `json:"networks"` 43 NumberOfEpisodes int64 `json:"number_of_episodes"` 44 NumberOfSeasons int64 `json:"number_of_seasons"` 45 OriginCountry []string `json:"origin_country"` 46 OriginalLanguage string `json:"original_language"` 47 OriginalName string `json:"original_name"` 48 Overview string `json:"overview"` 49 Popularity float64 `json:"popularity"` 50 PosterPath *string `json:"poster_path"` 51 ProductionCompanies []ProductionCompany `json:"production_companies"` 52 ProductionCountries []struct { 53 Country string `json:"iso_3166_1"` 54 Name string `json:"name"` 55 } `json:"production_countries"` 56 Seasons []struct { 57 AirDate string `json:"air_date"` 58 EpisodeCount int64 `json:"episode_count"` 59 ID int64 `json:"id"` 60 Name string `json:"name"` 61 Overview string `json:"overview"` 62 PosterPath string `json:"poster_path"` 63 SeasonNumber int64 `json:"season_number"` 64 } `json:"seasons"` 65 SpokenLanguages Languages `json:"spoken_languages"` 66 Status string `json:"status"` 67 Tagline string `json:"tagline"` 68 Type string `json:"type"` 69 VoteAverage float64 `json:"vote_average"` 70 VoteCount int64 `json:"vote_count"` 71 } 72 73 // TVShow retrieves the details of a TV Show 74 func (t *TMDB) TVShow(id int64, params ...option) (*TVShow, error) { 75 tv := new(TVShow) 76 if err := t.get(tv, fmt.Sprintf("/3/tv/%d", id), url.Values{}, params...); err != nil { 77 return nil, err 78 } 79 return tv, nil 80 } 81 82 // TVAggregateCredits contains the aggregated credits for a TV show 83 type TVAggregateCredits struct { 84 Cast []struct { 85 CreditShared 86 Roles []struct { 87 CreditID string `json:"credit_id"` 88 Character string `json:"character"` 89 EpisodeCount int64 `json:"episode_count"` 90 } `json:"roles"` 91 TotalEpisodeCount int64 `json:"total_episode_count"` 92 Order int64 `json:"order"` 93 } `json:"cast"` 94 Crew []struct { 95 CreditShared 96 Jobs []struct { 97 CreditID string `json:"credit_id"` 98 Job string `json:"job"` 99 EpisodeCount int64 `json:"episode_count"` 100 } `jobs:"jobs"` 101 } `json:"crew"` 102 ID int64 `json:"id"` 103 } 104 105 // TVAggregateCredits retrieves the aggregated credits for a TV show 106 func (t *TMDB) TVAggregateCredits(id int64, params ...option) (*TVAggregateCredits, error) { 107 tv := new(TVAggregateCredits) 108 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/aggregate_credits", id), url.Values{}, params...); err != nil { 109 return nil, err 110 } 111 return tv, nil 112 } 113 114 // TVAlternativeTitles retrieves the alternative titles for a TV show 115 func (t *TMDB) TVAlternativeTitles(id int64, params ...option) (*AlternativeTitles, error) { 116 a := new(AlternativeTitles) 117 if err := t.get(a, fmt.Sprintf("/3/tv/%d/alternative_titles", id), url.Values{}, params...); err != nil { 118 return nil, err 119 } 120 return a, nil 121 } 122 123 // TVChanges retrieves the list of changes for a TV show 124 func (t *TMDB) TVChanges(id int64, params ...option) (*EntryChanges, error) { 125 e := new(EntryChanges) 126 if err := t.get(e, fmt.Sprintf("/3/tv/%d/changes", id), url.Values{}, params...); err != nil { 127 return nil, err 128 } 129 return e, nil 130 } 131 132 // TVContentRatings containts the content ratings for a TV show 133 type TVContentRatings struct { 134 Results []struct { 135 Country string `json:"iso_3166_1"` 136 Rating string `json:"rating"` 137 } `json:"results"` 138 ID int64 `json:"id"` 139 } 140 141 // TVContentRatings retrieves the content ratings for a TV show 142 func (t *TMDB) TVContentRatings(id int64, params ...option) (*TVContentRatings, error) { 143 tv := new(TVContentRatings) 144 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/content_ratings", id), url.Values{}, params...); err != nil { 145 return nil, err 146 } 147 return tv, nil 148 } 149 150 // TVCredits retrieves the credits for a TV show 151 func (t *TMDB) TVCredits(id int64, params ...option) (*Credits, error) { 152 c := new(Credits) 153 if err := t.get(c, fmt.Sprintf("/3/tv/%d/credits", id), url.Values{}, params...); err != nil { 154 return nil, err 155 } 156 return c, nil 157 } 158 159 // TVEpisodeGroups contains all of the episode groups for a TV show 160 type TVEpisodeGroups struct { 161 Results []struct { 162 Description string `json:"description"` 163 EpisodeCount int64 `json:"episode_count"` 164 ID string `json:"id"` 165 Name string `json:"name"` 166 Network *ProductionCompany `json:"network"` 167 Type int64 `json:"type"` 168 } `json:"results"` 169 ID int64 `json:"id"` 170 } 171 172 // TVEpisodeGroups retrieves all of the episode groups for a TV show 173 func (t *TMDB) TVEpisodeGroups(id int64, params ...option) (*TVEpisodeGroups, error) { 174 tv := new(TVEpisodeGroups) 175 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/episode_groups", id), url.Values{}, params...); err != nil { 176 return nil, err 177 } 178 return tv, nil 179 } 180 181 // ExternalIDs contains all known external IDs for a TV show 182 type ExternalIDs struct { 183 IMDB *string `json:"imdb_id"` 184 FreebaseMID *string `json:"freebase_mid"` 185 FreebaseID *string `json:"freebase_id"` 186 TVDB *int64 `json:"tvdb_id"` 187 TVRage *int64 `json:"tbrage_id"` 188 Facebook *string `json:"facebook_id"` 189 Instagram *string `json:"instagram_id"` 190 Twitter *string `json:"twitter_ id"` 191 ID int64 `json:"id"` 192 } 193 194 // TVExternalIDs retrieves all of the external ids for a TV show 195 func (t *TMDB) TVExternalIDs(id int64, params ...option) (*ExternalIDs, error) { 196 e := new(ExternalIDs) 197 if err := t.get(e, fmt.Sprintf("/3/tv/%d/external_ids", id), url.Values{}, params...); err != nil { 198 return nil, err 199 } 200 return e, nil 201 } 202 203 // TVImages retrieves all of the images for a TV show 204 func (t *TMDB) TVImages(id int64, params ...option) (*Images, error) { 205 i := new(Images) 206 if err := t.get(i, fmt.Sprintf("/3/tv/%d/images", id), url.Values{}, params...); err != nil { 207 return nil, err 208 } 209 return i, nil 210 } 211 212 // TVKeywords retrieves all of the keywords for a TV show 213 func (t *TMDB) TVKeywords(id int64) (*Keywords, error) { 214 k := new(Keywords) 215 if err := t.get(k, fmt.Sprintf("/3/tv/%d/keywords", id), url.Values{}); err != nil { 216 return nil, err 217 } 218 return k, nil 219 } 220 221 // TVRecommendations retrieves all of the recommendations for a TV show 222 func (t *TMDB) TVRecommendations(id int64, params ...option) (*SearchTV, error) { 223 s := new(SearchTV) 224 if err := t.get(s, fmt.Sprintf("/3/tv/%d/recommendations", id), url.Values{}, params...); err != nil { 225 return nil, err 226 } 227 return s, nil 228 } 229 230 // TVReviews retrieves reviews for a TV show 231 func (t *TMDB) TVReviews(id int64, params ...option) (*Reviews, error) { 232 r := new(Reviews) 233 if err := t.get(r, fmt.Sprintf("/3/tv/%d/reviews", id), url.Values{}, params...); err != nil { 234 return nil, err 235 } 236 return r, nil 237 } 238 239 // TVScreenedTheatrically contains all of the episodes of a TV show that were screened theatrically 240 type TVScreenedTheatrically struct { 241 ID int64 `json:"id"` 242 Results []struct { 243 ID int64 `json:"id"` 244 EpisodeNumber int64 `json:"episode_number"` 245 SeasonNumber int64 `json:"season_number"` 246 } `json:"results"` 247 } 248 249 // TVScreenedTheatrically retrieves all of the episodes of a TV show that were screened theatrically 250 func (t *TMDB) TVScreenedTheatrically(id int64) (*TVScreenedTheatrically, error) { 251 tv := new(TVScreenedTheatrically) 252 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/screen_theatrically", id), url.Values{}); err != nil { 253 return nil, err 254 } 255 return tv, nil 256 } 257 258 // TVSimilar retrieves all of the similar TV shows 259 func (t *TMDB) TVSimilar(id int64, params ...option) (*SearchTV, error) { 260 s := new(SearchTV) 261 if err := t.get(s, fmt.Sprintf("/3/tv/%d/similar", id), url.Values{}, params...); err != nil { 262 return nil, err 263 } 264 return s, nil 265 } 266 267 // TVTranslations retrieves all of the translations that exist for a show 268 func (t *TMDB) TVTranslations(id int64) (*Translations, error) { 269 tv := new(Translations) 270 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/translations", id), url.Values{}); err != nil { 271 return nil, err 272 } 273 return tv, nil 274 } 275 276 // TVVideos retrieves all of the videos for a TV shows 277 func (t *TMDB) TVVideos(id int64, params ...option) (*Videos, error) { 278 v := new(Videos) 279 if err := t.get(v, fmt.Sprintf("/3/tv/%d/videos", id), url.Values{}, params...); err != nil { 280 return nil, err 281 } 282 return v, nil 283 } 284 285 // TVWatchProviders retrieves all of the watch providers that exist for a show 286 func (t *TMDB) TVWatchProviders(id int64) (*WatchProviders, error) { 287 w := new(WatchProviders) 288 if err := t.get(w, fmt.Sprintf("/3/tv/%d/watch_providers", id), url.Values{}); err != nil { 289 return nil, err 290 } 291 return w, nil 292 } 293 294 // TVLatest retrieves the latest TV show added to the database 295 func (t *TMDB) TVLatest() (*TVShow, error) { 296 tv := new(TVShow) 297 if err := t.get(tv, "/3/tv/latest", url.Values{}); err != nil { 298 return nil, err 299 } 300 return tv, nil 301 } 302 303 // TVAiringToday retrieves the TV show airing today 304 func (t *TMDB) TVAiringToday(params ...option) (*SearchTV, error) { 305 s := new(SearchTV) 306 if err := t.get(s, "/3/tv/airing_today", url.Values{}, params...); err != nil { 307 return nil, err 308 } 309 return s, nil 310 } 311 312 // TVOnTheAir retrieves TV show that are airing within the next 7 days 313 func (t *TMDB) TVOnTheAir(params ...option) (*SearchTV, error) { 314 s := new(SearchTV) 315 if err := t.get(s, "/3/tv/on_the_air", url.Values{}, params...); err != nil { 316 return nil, err 317 } 318 return s, nil 319 } 320 321 // TVPopular retrieves a list of popular TV shows 322 func (t *TMDB) TVPopular(params ...option) (*SearchTV, error) { 323 s := new(SearchTV) 324 if err := t.get(s, "/3/tv/popular", url.Values{}, params...); err != nil { 325 return nil, err 326 } 327 return s, nil 328 } 329 330 // TVTopRated retrieves a list of the top rated TV shows 331 func (t *TMDB) TVTopRated(params ...option) (*SearchTV, error) { 332 s := new(SearchTV) 333 if err := t.get(s, "/3/tv/top_rated", url.Values{}, params...); err != nil { 334 return nil, err 335 } 336 return s, nil 337 }