tmdb - collections.go
1 package tmdb
2
3 import (
4 "fmt"
5 "net/url"
6 )
7
8 // CollectionDetails stores a collection
9 type CollectionDetails struct {
10 ID int64 `json:"id"`
11 Name string `json:"name"`
12 Overview string `json:"overview"`
13 BackdropPath string `json:"backdrop_path"`
14 Parts []MovieResult `json:"parts"`
15 }
16
17 // CollectionDetails retrieves collection details by id
18 func (t *TMDB) CollectionDetails(id int64, params ...option) (*CollectionDetails, error) {
19 c := new(CollectionDetails)
20 if err := t.get(c, fmt.Sprintf("/3/collection/%d", id), url.Values{}, params...); err != nil {
21 return nil, err
22 }
23 return c, nil
24 }
25
26 // Image stores the data of a single image
27 type Image struct {
28 AspectRatio float64 `json:"aspect_ratio"`
29 FilePath string `json:"file_path"`
30 Height uint64 `json:"height"`
31 Language *string `json:"iso_639_1"`
32 VoteAverage float64 `json:"vote_average"`
33 VoteCount int64 `json:"vote_count"`
34 Width int64 `json:"width"`
35 }
36
37 // CollectionImages stores the images details for a collection
38 type CollectionImages struct {
39 ID int64 `json:"id"`
40 Backdrops Image `json:"backdrops"`
41 Posters Image `json:"posters"`
42 }
43
44 // CollectionImages retrieves collection images details by id
45 func (t *TMDB) CollectionImages(id int64, params ...option) (*CollectionImages, error) {
46 c := new(CollectionImages)
47 if err := t.get(c, fmt.Sprintf("/3/collection/%d/images", id), url.Values{}, params...); err != nil {
48 return nil, err
49 }
50 return c, nil
51 }
52
53 // Translations represents collection translations data
54 type Translations struct {
55 ID int64 `json:"id"`
56 Translations []struct {
57 Country string `json:"iso_3166_1"`
58 Language string `json:"iso_639_1"`
59 Name string `json:"name"`
60 EnglishName string `json:"english_name"`
61 Data struct {
62 Title string `json:"title"`
63 Overview string `json:"overview"`
64 Homepage string `json:"homepage"`
65 } `json:"data"`
66 } `json:"translations"`
67 }
68
69 // CollectionTranslations gets the list translations for a collection by ID
70 func (t *TMDB) CollectionTranslations(id int64, params ...option) (*Translations, error) {
71 tr := new(Translations)
72 if err := t.get(tr, fmt.Sprintf("/3/collection/%d/translations", id), url.Values{}, params...); err != nil {
73 return nil, err
74 }
75 return tr, nil
76 }