-
Notifications
You must be signed in to change notification settings - Fork 58
/
collections.go
74 lines (67 loc) · 2.29 KB
/
collections.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
package tmdb
import (
"fmt"
)
// Collection struct
type Collection struct {
BackdropPath string `json:"backdrop_path"`
ID int
Name string
PosterPath string `json:"poster_path"`
Images *CollectionImages `json:",omitempty"`
Parts []struct {
BackdropPath string `json:"backdrop_path"`
ID int
PosterPath string `json:"poster_path"`
ReleaseDate string `json:"release_date"`
Title string
}
}
// CollectionShort struct
type CollectionShort struct {
ID int
Name string
PosterPath string `json:"poster_path"`
BackdropPath string `json:"backdrop_path"`
}
// CollectionImage struct
type CollectionImage struct {
AspectRatio float32 `json:"aspect_ratio"`
FilePath string `json:"file_path"`
Height int
Iso639_1 string `json:"iso_639_1"`
Width int
}
// CollectionImages struct
type CollectionImages struct {
Backdrops []CollectionImage
ID int
Name string
PosterPath string `json:"poster_path"`
Posters []CollectionImage
}
// GetCollectionInfo gets the basic collection information for a specific collection id
// https://developers.themoviedb.org/3/collections/get-collection-details
func (tmdb *TMDb) GetCollectionInfo(id int, options map[string]string) (*Collection, error) {
var availableOptions = map[string]struct{}{
"language": {},
"append_to_response": {}}
var collection Collection
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/collection/%v?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &collection)
return result.(*Collection), err
}
// GetCollectionImages gets a list of people ids that have been edited
// https://developers.themoviedb.org/3/collections/get-collection-images
func (tmdb *TMDb) GetCollectionImages(id int, options map[string]string) (*CollectionImages, error) {
var availableOptions = map[string]struct{}{
"language": {},
"append_to_response": {},
"include_image_language": {}}
var images CollectionImages
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/collection/%v/images?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &images)
return result.(*CollectionImages), err
}