tmdb - people.go
1 package tmdb
2
3 import (
4 "encoding/json"
5 "fmt"
6 "net/url"
7 )
8
9 // Person contains the information about a person
10 type Person struct {
11 Birthday *string `json:"birthday"`
12 KnownForDepartment string `json:"known_for_department"`
13 Deathday *string `json:"deathday"`
14 ID int64 `json:"id"`
15 Name string `json:"name"`
16 AKA []string `json:"also_known_as"`
17 Gender int64 `json:"gender"`
18 Biography string `json:"biography"`
19 Popularity float64 `json:"popularity"`
20 PlaceOfBirth *string `json:"place_of_birth"`
21 ProfilePath *string `json:"profile_path"`
22 Adult bool `json:"adult"`
23 IMDBID string `json:"imdb_id"`
24 Homepage string `json:"homepage"`
25 }
26
27 // PersonDetails retreives the details of the specified person
28 func (t *TMDB) PersonDetails(id int64, params ...option) (*Person, error) {
29 p := new(Person)
30 if err := t.get(p, fmt.Sprintf("/3/person/%d", id), url.Values{}, params...); err != nil {
31 return nil, err
32 }
33 return p, nil
34 }
35
36 // PersonChanges contains informaton about changes made to a person's profile
37 type PersonChanges struct {
38 Changes []struct {
39 Key string `json:"key"`
40 Items []struct {
41 ID string `json:"id"`
42 Action string `json:"action"`
43 Time string `json:"time"`
44 OriginalValue json.RawMessage `json:"original_value"`
45 } `json:"items"`
46 } `json:"changes"`
47 }
48
49 // PersonChanges retreives the information about changes made to a person's profile
50 func (t *TMDB) PersonChanges(id int64, params ...option) (*PersonChanges, error) {
51 p := new(PersonChanges)
52 if err := t.get(p, fmt.Sprintf("/3/person/%d/changes", id), url.Values{}, params...); err != nil {
53 return nil, err
54 }
55 return p, nil
56 }
57
58 // PersonMovieCredits retreives the movie credits for a person
59 func (t *TMDB) PersonMovieCredits(id int64, params ...option) (*Credits, error) {
60 c := new(Credits)
61 if err := t.get(c, fmt.Sprintf("/3/person/%d/movie_credits", id), url.Values{}, params...); err != nil {
62 return nil, err
63 }
64 return c, nil
65 }
66
67 // PersonTVCredits retreives the movie credits for a person
68 func (t *TMDB) PersonTVCredits(id int64, params ...option) (*Credits, error) {
69 c := new(Credits)
70 if err := t.get(c, fmt.Sprintf("/3/person/%d/tv_credits", id), url.Values{}, params...); err != nil {
71 return nil, err
72 }
73 return c, nil
74 }
75
76 // PersonCombinedCredits retreives the movie credits for a person
77 func (t *TMDB) PersonCombinedCredits(id int64, params ...option) (*Credits, error) {
78 c := new(Credits)
79 if err := t.get(c, fmt.Sprintf("/3/person/%d/combined_credits", id), url.Values{}, params...); err != nil {
80 return nil, err
81 }
82 return c, nil
83 }
84
85 // PersonExternalIDs retreives the external IDs for a person
86 func (t *TMDB) PersonExternalIDs(id int64, params ...option) (*ExternalIDs, error) {
87 e := new(ExternalIDs)
88 if err := t.get(e, fmt.Sprintf("/3/person/%d/external_ids", id), url.Values{}, params...); err != nil {
89 return nil, err
90 }
91 return e, nil
92 }
93
94 // PersonImages contains all of the images for a person
95 type PersonImages struct {
96 ID int64 `json:"id"`
97 Profiles []Image `json:"profiles"`
98 }
99
100 // PersonImages retreives all of the images for a person
101 func (t *TMDB) PersonImages(id int64) (*PersonImages, error) {
102 p := new(PersonImages)
103 if err := t.get(p, fmt.Sprintf("/3/person/%d/images", id), url.Values{}); err != nil {
104 return nil, err
105 }
106 return p, nil
107 }
108
109 // PersonTaggedImages contains a list of all tagged images for a person
110 type PersonTaggedImages struct {
111 ID int64 `json:"id"`
112 Search
113 Results []struct {
114 Image
115 ID string `json:"id"`
116 ImageType string `json:"image_type"`
117 Media TVOrMovie `json:"media"`
118 MediaType string `json:"media_type"`
119 } `json:"results"`
120 }
121
122 // PersonTaggedImages retreives all of the tagged images for the specified person
123 func (t *TMDB) PersonTaggedImages(id int64, params ...option) (*PersonTaggedImages, error) {
124 p := new(PersonTaggedImages)
125 if err := t.get(p, fmt.Sprintf("/3/person/%d/tagged_images", id), url.Values{}, params...); err != nil {
126 return nil, err
127 }
128 return p, nil
129 }
130
131 // PersonTranslations contains the translations that have been created for a person
132 type PersonTranslations struct {
133 Translations []struct {
134 Language string `json:"iso_639_1"`
135 Country string `json:"iso_3166_1"`
136 Name string `json:"name"`
137 Data struct {
138 Biography string `json:"biography"`
139 } `json:"data"`
140 EnglishName string `json:"english_name"`
141 } `json:"translations"`
142 ID int64 `json:"id"`
143 }
144
145 // PersonTranslations retreives all of the translations that have been created for a person
146 func (t *TMDB) PersonTranslations(id int64, params ...option) (*PersonTranslations, error) {
147 p := new(PersonTranslations)
148 if err := t.get(p, fmt.Sprintf("/3/person/%d/translations", id), url.Values{}, params...); err != nil {
149 return nil, err
150 }
151 return p, nil
152 }
153
154 // PersonLatest retreives the most recent person added to the database
155 func (t *TMDB) PersonLatest(params ...option) (*Person, error) {
156 p := new(Person)
157 if err := t.get(p, "/3/person/latest", url.Values{}, params...); err != nil {
158 return nil, err
159 }
160 return p, nil
161 }
162
163 // PersonPopular retreives the most popular people in the database
164 func (t *TMDB) PersonPopular(params ...option) (*SearchPeople, error) {
165 s := new(SearchPeople)
166 if err := t.get(s, "/3/person/popular", url.Values{}, params...); err != nil {
167 return nil, err
168 }
169 return s, nil
170 }