-
Notifications
You must be signed in to change notification settings - Fork 57
/
tvseasons.go
114 lines (103 loc) · 4.61 KB
/
tvseasons.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package tmdb
import (
"fmt"
)
// TvSeason struct
type TvSeason struct {
ID int
AirDate string `json:"air_date"`
Name string
Overview string
PosterPath string `json:"poster_path"`
SeasonNumber int `json:"season_number"`
Episodes []TvEpisode
Credits *TvCredits
ExternalIDs *TvSeasonExternalIds `json:"external_ids,omitempty"`
}
// TvSeasonExternalIds struct
type TvSeasonExternalIds struct {
ID int
FreebaseID string `json:"freebase_id"`
FreebaseMid string `json:"freebase_mid"`
TvdbID int `json:"tvdb_id"`
TvrageID int `json:"tvrage_id"`
}
// TvSeasonImages struct
type TvSeasonImages struct {
ID int
Posters []TvImage
}
// GetTvSeasonInfo the primary information about a TV season by its season number
// https://developers.themoviedb.org/3/tv-seasons/get-tv-season-details
func (tmdb *TMDb) GetTvSeasonInfo(showID, seasonID int, options map[string]string) (*TvSeason, error) {
var availableOptions = map[string]struct{}{
"language": {},
"append_to_response": {}}
var season TvSeason
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/tv/%v/season/%v?api_key=%s%s", baseURL, showID, seasonID, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &season)
return result.(*TvSeason), err
}
// GetTvSeasonChanges gets a TV season's changes by season ID
// https://developers.themoviedb.org/3/tv-seasons/get-tv-season-changes
func (tmdb *TMDb) GetTvSeasonChanges(id int, options map[string]string) (*TvChanges, error) {
var availableOptions = map[string]struct{}{
"start_date": {},
"end_date": {}}
var changes TvChanges
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/tv/season/%v/changes?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &changes)
return result.(*TvChanges), err
}
// GetTvSeasonCredits gets the cast & crew credits for a TV season by season number
// https://developers.themoviedb.org/3/tv-seasons/get-tv-season-credits
func (tmdb *TMDb) GetTvSeasonCredits(showID, seasonNum int) (*TvCredits, error) {
var credits TvCredits
uri := fmt.Sprintf("%s/tv/%v/season/%v/credits?api_key=%s", baseURL, showID, seasonNum, tmdb.apiKey)
result, err := getTmdb(uri, &credits)
return result.(*TvCredits), err
}
// GetTvSeasonAggregateCredits gets all the cast & crew credits for a TV season by season number
// https://developers.themoviedb.org/3/tv-seasons/get-tv-season-aggregate-credits
func (tmdb *TMDb) GetTvSeasonAggregateCredits(showID, seasonNum int) (*TvCredits, error) {
var credits TvCredits
uri := fmt.Sprintf("%s/tv/%v/season/%v/aggregate_credits?api_key=%s", baseURL, showID, seasonNum, tmdb.apiKey)
result, err := getTmdb(uri, &credits)
return result.(*TvCredits), err
}
// GetTvSeasonExternalIds gets the external ids for a TV season by season number
// https://developers.themoviedb.org/3/tv-seasons/get-tv-season-external-ids
func (tmdb *TMDb) GetTvSeasonExternalIds(showID, seasonNum int, options map[string]string) (*TvExternalIds, error) {
var availableOptions = map[string]struct{}{
"language": {}}
var ids TvExternalIds
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/tv/%v/season/%v/external_ids?api_key=%s%s", baseURL, showID, seasonNum, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &ids)
return result.(*TvExternalIds), err
}
// GetTvSeasonImages gets the images (posters) that we have stored for a TV season by season number
// https://developers.themoviedb.org/3/tv-seasons/get-tv-season-images
func (tmdb *TMDb) GetTvSeasonImages(showID, seasonNum int, options map[string]string) (*TvSeasonImages, error) {
var availableOptions = map[string]struct{}{
"language": {},
"include_image_language": {}}
var images TvSeasonImages
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/tv/%v/season/%v/images?api_key=%s%s", baseURL, showID, seasonNum, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &images)
return result.(*TvSeasonImages), err
}
// GetTvSeasonVideos gets the videos that have been added to a TV season
// https://developers.themoviedb.org/3/tv-seasons/get-tv-season-videos
func (tmdb *TMDb) GetTvSeasonVideos(showID, seasonNum int, options map[string]string) (*TvVideos, error) {
var availableOptions = map[string]struct{}{
"language": {}}
var videos TvVideos
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/tv/%v/season/%v/videos?api_key=%s%s", baseURL, showID, seasonNum, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &videos)
return result.(*TvVideos), err
}