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 77 if err := t.get(tv, fmt.Sprintf("/3/tv/%d", id), url.Values{}, params...); err != nil { 78 return nil, err 79 } 80 81 return tv, nil 82 } 83 84 // TVAggregateCredits contains the aggregated credits for a TV show. 85 type TVAggregateCredits struct { 86 Cast []struct { 87 CreditShared 88 Roles []struct { 89 CreditID string `json:"credit_id"` 90 Character string `json:"character"` 91 EpisodeCount int64 `json:"episode_count"` 92 } `json:"roles"` 93 TotalEpisodeCount int64 `json:"total_episode_count"` 94 Order int64 `json:"order"` 95 } `json:"cast"` 96 Crew []struct { 97 CreditShared 98 Jobs []struct { 99 CreditID string `json:"credit_id"` 100 Job string `json:"job"` 101 EpisodeCount int64 `json:"episode_count"` 102 } `jobs:"jobs"` 103 } `json:"crew"` 104 ID int64 `json:"id"` 105 } 106 107 // TVAggregateCredits retrieves the aggregated credits for a TV show. 108 func (t *TMDB) TVAggregateCredits(id int64, params ...option) (*TVAggregateCredits, error) { 109 tv := new(TVAggregateCredits) 110 111 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/aggregate_credits", id), url.Values{}, params...); err != nil { 112 return nil, err 113 } 114 115 return tv, nil 116 } 117 118 // TVAlternativeTitles retrieves the alternative titles for a TV show. 119 func (t *TMDB) TVAlternativeTitles(id int64, params ...option) (*AlternativeTitles, error) { 120 a := new(AlternativeTitles) 121 122 if err := t.get(a, fmt.Sprintf("/3/tv/%d/alternative_titles", id), url.Values{}, params...); err != nil { 123 return nil, err 124 } 125 126 return a, nil 127 } 128 129 // TVChanges retrieves the list of changes for a TV show. 130 func (t *TMDB) TVChanges(id int64, params ...option) (*EntryChanges, error) { 131 e := new(EntryChanges) 132 133 if err := t.get(e, fmt.Sprintf("/3/tv/%d/changes", id), url.Values{}, params...); err != nil { 134 return nil, err 135 } 136 137 return e, nil 138 } 139 140 // TVContentRatings contains the content ratings for a TV show. 141 type TVContentRatings struct { 142 Results []struct { 143 Country string `json:"iso_3166_1"` 144 Rating string `json:"rating"` 145 } `json:"results"` 146 ID int64 `json:"id"` 147 } 148 149 // TVContentRatings retrieves the content ratings for a TV show. 150 func (t *TMDB) TVContentRatings(id int64, params ...option) (*TVContentRatings, error) { 151 tv := new(TVContentRatings) 152 153 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/content_ratings", id), url.Values{}, params...); err != nil { 154 return nil, err 155 } 156 157 return tv, nil 158 } 159 160 // TVCredits retrieves the credits for a TV show. 161 func (t *TMDB) TVCredits(id int64, params ...option) (*Credits, error) { 162 c := new(Credits) 163 164 if err := t.get(c, fmt.Sprintf("/3/tv/%d/credits", id), url.Values{}, params...); err != nil { 165 return nil, err 166 } 167 168 return c, nil 169 } 170 171 // TVEpisodeGroups contains all of the episode groups for a TV show. 172 type TVEpisodeGroups struct { 173 Results []struct { 174 Description string `json:"description"` 175 EpisodeCount int64 `json:"episode_count"` 176 ID string `json:"id"` 177 Name string `json:"name"` 178 Network *ProductionCompany `json:"network"` 179 Type int64 `json:"type"` 180 } `json:"results"` 181 ID int64 `json:"id"` 182 } 183 184 // TVEpisodeGroups retrieves all of the episode groups for a TV show. 185 func (t *TMDB) TVEpisodeGroups(id int64, params ...option) (*TVEpisodeGroups, error) { 186 tv := new(TVEpisodeGroups) 187 188 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/episode_groups", id), url.Values{}, params...); err != nil { 189 return nil, err 190 } 191 192 return tv, nil 193 } 194 195 // ExternalIDs contains all known external IDs for a TV show. 196 type ExternalIDs struct { 197 IMDB *string `json:"imdb_id"` 198 FreebaseMID *string `json:"freebase_mid"` 199 FreebaseID *string `json:"freebase_id"` 200 TVDB *int64 `json:"tvdb_id"` 201 TVRage *int64 `json:"tbrage_id"` 202 Facebook *string `json:"facebook_id"` 203 Instagram *string `json:"instagram_id"` 204 Twitter *string `json:"twitter_ id"` 205 ID int64 `json:"id"` 206 } 207 208 // TVExternalIDs retrieves all of the external ids for a TV show. 209 func (t *TMDB) TVExternalIDs(id int64, params ...option) (*ExternalIDs, error) { 210 e := new(ExternalIDs) 211 212 if err := t.get(e, fmt.Sprintf("/3/tv/%d/external_ids", id), url.Values{}, params...); err != nil { 213 return nil, err 214 } 215 216 return e, nil 217 } 218 219 // TVImages retrieves all of the images for a TV show. 220 func (t *TMDB) TVImages(id int64, params ...option) (*Images, error) { 221 i := new(Images) 222 223 if err := t.get(i, fmt.Sprintf("/3/tv/%d/images", id), url.Values{}, params...); err != nil { 224 return nil, err 225 } 226 227 return i, nil 228 } 229 230 // TVKeywords retrieves all of the keywords for a TV show. 231 func (t *TMDB) TVKeywords(id int64) (*Keywords, error) { 232 k := new(Keywords) 233 234 if err := t.get(k, fmt.Sprintf("/3/tv/%d/keywords", id), url.Values{}); err != nil { 235 return nil, err 236 } 237 238 return k, nil 239 } 240 241 // TVRecommendations retrieves all of the recommendations for a TV show. 242 func (t *TMDB) TVRecommendations(id int64, params ...option) (*SearchTV, error) { 243 s := new(SearchTV) 244 245 if err := t.get(s, fmt.Sprintf("/3/tv/%d/recommendations", id), url.Values{}, params...); err != nil { 246 return nil, err 247 } 248 249 return s, nil 250 } 251 252 // TVReviews retrieves reviews for a TV show. 253 func (t *TMDB) TVReviews(id int64, params ...option) (*Reviews, error) { 254 r := new(Reviews) 255 256 if err := t.get(r, fmt.Sprintf("/3/tv/%d/reviews", id), url.Values{}, params...); err != nil { 257 return nil, err 258 } 259 260 return r, nil 261 } 262 263 // TVScreenedTheatrically contains all of the episodes of a TV show that were screened theatrically. 264 type TVScreenedTheatrically struct { 265 ID int64 `json:"id"` 266 Results []struct { 267 ID int64 `json:"id"` 268 EpisodeNumber int64 `json:"episode_number"` 269 SeasonNumber int64 `json:"season_number"` 270 } `json:"results"` 271 } 272 273 // TVScreenedTheatrically retrieves all of the episodes of a TV show that were screened theatrically. 274 func (t *TMDB) TVScreenedTheatrically(id int64) (*TVScreenedTheatrically, error) { 275 tv := new(TVScreenedTheatrically) 276 277 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/screen_theatrically", id), url.Values{}); err != nil { 278 return nil, err 279 } 280 281 return tv, nil 282 } 283 284 // TVSimilar retrieves all of the similar TV shows. 285 func (t *TMDB) TVSimilar(id int64, params ...option) (*SearchTV, error) { 286 s := new(SearchTV) 287 288 if err := t.get(s, fmt.Sprintf("/3/tv/%d/similar", id), url.Values{}, params...); err != nil { 289 return nil, err 290 } 291 292 return s, nil 293 } 294 295 // TVTranslations retrieves all of the translations that exist for a show. 296 func (t *TMDB) TVTranslations(id int64) (*Translations, error) { 297 tv := new(Translations) 298 299 if err := t.get(tv, fmt.Sprintf("/3/tv/%d/translations", id), url.Values{}); err != nil { 300 return nil, err 301 } 302 303 return tv, nil 304 } 305 306 // TVVideos retrieves all of the videos for a TV shows. 307 func (t *TMDB) TVVideos(id int64, params ...option) (*Videos, error) { 308 v := new(Videos) 309 310 if err := t.get(v, fmt.Sprintf("/3/tv/%d/videos", id), url.Values{}, params...); err != nil { 311 return nil, err 312 } 313 314 return v, nil 315 } 316 317 // TVWatchProviders retrieves all of the watch providers that exist for a show. 318 func (t *TMDB) TVWatchProviders(id int64) (*WatchProviders, error) { 319 w := new(WatchProviders) 320 321 if err := t.get(w, fmt.Sprintf("/3/tv/%d/watch_providers", id), url.Values{}); err != nil { 322 return nil, err 323 } 324 325 return w, nil 326 } 327 328 // TVLatest retrieves the latest TV show added to the database. 329 func (t *TMDB) TVLatest() (*TVShow, error) { 330 tv := new(TVShow) 331 332 if err := t.get(tv, "/3/tv/latest", url.Values{}); err != nil { 333 return nil, err 334 } 335 336 return tv, nil 337 } 338 339 // TVAiringToday retrieves the TV show airing today. 340 func (t *TMDB) TVAiringToday(params ...option) (*SearchTV, error) { 341 s := new(SearchTV) 342 343 if err := t.get(s, "/3/tv/airing_today", url.Values{}, params...); err != nil { 344 return nil, err 345 } 346 347 return s, nil 348 } 349 350 // TVOnTheAir retrieves TV show that are airing within the next 7 days. 351 func (t *TMDB) TVOnTheAir(params ...option) (*SearchTV, error) { 352 s := new(SearchTV) 353 354 if err := t.get(s, "/3/tv/on_the_air", url.Values{}, params...); err != nil { 355 return nil, err 356 } 357 358 return s, nil 359 } 360 361 // TVPopular retrieves a list of popular TV shows. 362 func (t *TMDB) TVPopular(params ...option) (*SearchTV, error) { 363 s := new(SearchTV) 364 365 if err := t.get(s, "/3/tv/popular", url.Values{}, params...); err != nil { 366 return nil, err 367 } 368 369 return s, nil 370 } 371 372 // TVTopRated retrieves a list of the top rated TV shows. 373 func (t *TMDB) TVTopRated(params ...option) (*SearchTV, error) { 374 s := new(SearchTV) 375 376 if err := t.get(s, "/3/tv/top_rated", url.Values{}, params...); err != nil { 377 return nil, err 378 } 379 380 return s, nil 381 } 382