tmdb - options.go
1 package tmdb
2
3 import (
4 "net/url"
5 "strconv"
6 )
7
8 type option interface {
9 setParam(url.Values)
10 }
11
12 // Language is a ISO 639-1 value to display translated data for the fields that support it
13 type Language string
14
15 func (l Language) setParam(v url.Values) {
16 v.Set("language", string(l))
17 }
18
19 // Page specifies which page of results to query
20 type Page uint16
21
22 func (p Page) setParam(v url.Values) {
23 v.Set("page", strconv.FormatUint(uint64(p), 10))
24 }
25
26 // IncludeAdult determines whether adult content is included in search results
27 type IncludeAdult bool
28
29 func (i IncludeAdult) setParam(v url.Values) {
30 v.Set("include_adult", strconv.FormatBool(bool(i)))
31 }
32
33 // FirstAirDateYear limits a search to the year specified
34 type FirstAirDateYear int64
35
36 func (f FirstAirDateYear) setParam(v url.Values) {
37 v.Set("first_air_date_year", strconv.FormatInt(int64(f), 10))
38 }
39
40 // Region specified a ISO 3166-1 code to filter release dates. Must be uppercase
41 type Region string
42
43 func (r Region) setParam(v url.Values) {
44 v.Set("region", string(r))
45 }
46
47 // Year filters the results by the specified year
48 type Year int64
49
50 func (y Year) setParam(v url.Values) {
51 v.Set("year", strconv.FormatInt(int64(y), 10))
52 }
53
54 // PrimaryReleaseYear filters the results by the specified year
55 type PrimaryReleaseYear int64
56
57 func (p PrimaryReleaseYear) setParam(v url.Values) {
58 v.Set("primary_release_year", strconv.FormatInt(int64(p), 10))
59 }
60
61 // Country filters a list by country
62 type Country string
63
64 func (c Country) setParam(v url.Values) {
65 v.Set("country", string(c))
66 }
67
68 // StartDate limits a search to a starting date
69 type StartDate string
70
71 func (s StartDate) setParam(v url.Values) {
72 v.Set("start_date", string(s))
73 }
74
75 // EndDate limits a search to a end date
76 type EndDate string
77
78 func (e EndDate) setParam(v url.Values) {
79 v.Set("end_date", string(e))
80 }
81
82 // SortBy sorts an applicable list bythe specified key and direction
83 type SortBy string
84
85 func (s SortBy) setParam(v url.Values) {
86 v.Set("sort_by", string(s))
87 }
88
89 // AirDateGTE filters and only include TV shows that have an airy date greater than (or equal to) that specified
90 type AirDateGTE string
91
92 func (a AirDateGTE) setParam(v url.Values) {
93 v.Set("air_date.gte", string(a))
94 }
95
96 // AirDateLTE filters and only include TV shows that have any air date less than (or equal to) that specified
97 type AirDateLTE string
98
99 func (a AirDateLTE) setParam(v url.Values) {
100 v.Set("air_date.gte", string(a))
101 }
102
103 // FirstAirDateGTE filters and only include TV shows that have a first air date greater than (or equal to) that specified
104 type FirstAirDateGTE string
105
106 func (f FirstAirDateGTE) setParam(v url.Values) {
107 v.Set("air_date.lte", string(f))
108 }
109
110 // FirstAirDateLTE filters and only include TV shows that have a first air date less than (or equal to) that specified
111 type FirstAirDateLTE string
112
113 func (f FirstAirDateLTE) setParam(v url.Values) {
114 v.Set("first_air_date.lte", string(f))
115 }
116
117 // Timezone is used to set the correct timezone for date limiting filters
118 type Timezone string
119
120 func (t Timezone) setParam(v url.Values) {
121 v.Set("timezone", string(t))
122 }
123
124 // VoteAverageGTE filters by only allowing results with a vote average greater than (or equal to) that specified
125 type VoteAverageGTE float64
126
127 func (va VoteAverageGTE) setParam(v url.Values) {
128 v.Set("vote_average.gte", strconv.FormatFloat(float64(va), 'f', 0, 64))
129 }
130
131 // VoteAverageLTE filters by only allowing results with a vote average less than (or equal to) that specified
132 type VoteAverageLTE float64
133
134 func (va VoteAverageLTE) setParam(v url.Values) {
135 v.Set("vote_average.lte", strconv.FormatFloat(float64(va), 'f', 0, 64))
136 }
137
138 // WithGenres specifies a comma seperated list of genre ids to limit the results to
139 type WithGenres string
140
141 func (w WithGenres) setParam(v url.Values) {
142 v.Set("with_genres", string(w))
143 }
144
145 // WithNetworks specifies a comma seperated list of network IDs to limit the results to
146 type WithNetworks string
147
148 func (w WithNetworks) setParam(v url.Values) {
149 v.Set("with_networks", string(w))
150 }
151
152 // WithoutGenres specifies a comma seperated list of genre ids to filter from the results
153 type WithoutGenres string
154
155 func (w WithoutGenres) setParam(v url.Values) {
156 v.Set("without_genres", string(w))
157 }
158
159 // WithRuntimeGTE filters by only allowing results with a runtime greater than (or equal to) that specified
160 type WithRuntimeGTE int64
161
162 func (w WithRuntimeGTE) setParam(v url.Values) {
163 v.Set("with_runtime.gte", strconv.FormatFloat(float64(w), 'f', 0, 64))
164 }
165
166 // WithRuntimeLTE filters by only allowing results with a runtime less than (or equal to) that specified
167 type WithRuntimeLTE int64
168
169 func (w WithRuntimeLTE) setParam(v url.Values) {
170 v.Set("with_runtime.lte", strconv.FormatFloat(float64(w), 'f', 0, 64))
171 }
172
173 // IncludeNullFirstAirDates specifies that results without a first air date should be included when filtering by air date
174 type IncludeNullFirstAirDates bool
175
176 func (i IncludeNullFirstAirDates) setParam(v url.Values) {
177 v.Set("include_null_first_air_dates", strconv.FormatBool(bool(i)))
178 }
179
180 // WithOriginalLanguage specifies and ISO 639-1 string to filter results by original language
181 type WithOriginalLanguage string
182
183 func (w WithOriginalLanguage) setParam(v url.Values) {
184 v.Set("with_original_language", string(w))
185 }
186
187 // WithoutKeywords filters results by the specified keywords
188 type WithoutKeywords string
189
190 func (w WithoutKeywords) setParam(v url.Values) {
191 v.Set("without_keywords", string(w))
192 }
193
194 // ScreenedTheatrically filters results to only include those with a theatrical release
195 type ScreenedTheatrically bool
196
197 func (s ScreenedTheatrically) setParam(v url.Values) {
198 v.Set("screened_theatrically", strconv.FormatBool(bool(s)))
199 }
200
201 // WithCompanies specifies a comma seperated list of company ids to limit the results to
202 type WithCompanies string
203
204 func (w WithCompanies) setParam(v url.Values) {
205 v.Set("with_companies", string(w))
206 }
207
208 // WithKeywords filters results by the specified keywords
209 type WithKeywords string
210
211 func (w WithKeywords) setParam(v url.Values) {
212 v.Set("with_keywords", string(w))
213 }
214
215 // WithWatchProviders filters results by the specified watch proviers
216 type WithWatchProviders string
217
218 func (w WithWatchProviders) setParam(v url.Values) {
219 v.Set("with_watch_providers", string(w))
220 }
221
222 // WatchRegion filters results by the specified regions
223 type WatchRegion string
224
225 func (w WatchRegion) setParam(v url.Values) {
226 v.Set("watch_region", string(w))
227 }
228
229 // VoteCountGTE filters by only allowing results with a vote count greater than (or equal to) that specified
230 type VoteCountGTE float64
231
232 func (vc VoteCountGTE) setParam(v url.Values) {
233 v.Set("vote_count.gte", strconv.FormatFloat(float64(vc), 'f', 0, 64))
234 }
235
236 // VoteCountLTE filters by only allowing results with a vote count less than (or equal to) that specified
237 type VoteCountLTE float64
238
239 func (vc VoteCountLTE) setParam(v url.Values) {
240 v.Set("vote_count.lte", strconv.FormatFloat(float64(vc), 'f', 0, 64))
241 }
242
243 // CertificationCountry is used in conjustion fir the Certification filter to specify a country with a valid certificate
244 type CertificationCountry string
245
246 func (c CertificationCountry) setParam(v url.Values) {
247 v.Set("certification_country", string(c))
248 }
249
250 // CertificationFilter filters results with a vald certification from the CertificationCountry value
251 type CertificationFilter string
252
253 func (c CertificationFilter) setParam(v url.Values) {
254 v.Set("certification", string(c))
255 }
256
257 // CertificationLTE filters results to only include those with a certification less than (or equal to) that specified
258 type CertificationLTE string
259
260 func (c CertificationLTE) setParam(v url.Values) {
261 v.Set("certification.lte", string(c))
262 }
263
264 // CertificationGTE filters results to only include those with a certification greater than (or equal to) that specified
265 type CertificationGTE string
266
267 func (c CertificationGTE) setParam(v url.Values) {
268 v.Set("certification.gte", string(c))
269 }
270
271 // IncludeVideo is a filter to include/exclude videos
272 type IncludeVideo bool
273
274 func (i IncludeVideo) setParam(v url.Values) {
275 v.Set("include_video", strconv.FormatBool(bool(i)))
276 }
277
278 // PrimaryReleaseDateGTE filters results to only include those with a primary release date greater than (or equal to) that specified
279 type PrimaryReleaseDateGTE string
280
281 func (p PrimaryReleaseDateGTE) setParam(v url.Values) {
282 v.Set("primary_release_date.gte", string(p))
283 }
284
285 // PrimaryReleaseDateLTE filters results to only include those with a primary release date less than (or equal to) that specified
286 type PrimaryReleaseDateLTE string
287
288 func (p PrimaryReleaseDateLTE) setParam(v url.Values) {
289 v.Set("primary_release_date.lte", string(p))
290 }
291
292 // ReleaseDateGTE filters results to only include those with a release date greater than (or equal to) that specified
293 type ReleaseDateGTE string
294
295 func (r ReleaseDateGTE) setParam(v url.Values) {
296 v.Set("release_date.gte", string(r))
297 }
298
299 // ReleaseDateLTE filters results to only include those with a release date less than (or equal to) that specified
300 type ReleaseDateLTE string
301
302 func (r ReleaseDateLTE) setParam(v url.Values) {
303 v.Set("release_date.lte", string(r))
304 }
305
306 // WithReleaseType filters results with the specified list type
307 type WithReleaseType int64
308
309 func (w WithReleaseType) setParam(v url.Values) {
310 v.Set("with_release_type", strconv.FormatInt(int64(w), 10))
311 }
312
313 // WithCast specifies a comma seperated list of person IDs, any of which must be included in each result
314 type WithCast string
315
316 func (w WithCast) setParam(v url.Values) {
317 v.Set("with_cast", string(w))
318 }
319
320 // WithCrew specifies a comma seperated list of person IDs, any of which must be included in each result
321 type WithCrew string
322
323 func (w WithCrew) setParam(v url.Values) {
324 v.Set("with_crew", string(w))
325 }
326
327 // WithPeople specifies a comma seperated list of person IDs, any of which must be included in each result
328 type WithPeople string
329
330 func (w WithPeople) setParam(v url.Values) {
331 v.Set("with_people", string(w))
332 }
333
334 // IncludeImageLanguage determines whether an the language of an image is returned with the image data
335 type IncludeImageLanguage string
336
337 func (i IncludeImageLanguage) setParam(v url.Values) {
338 v.Set("include_image_language", string(i))
339 }