-
Notifications
You must be signed in to change notification settings - Fork 58
/
movies.go
662 lines (621 loc) · 25.8 KB
/
movies.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
package tmdb
import (
"fmt"
)
// Movie struct
type Movie struct {
Adult bool
BackdropPath string `json:"backdrop_path"`
// BelongsToCollection bool `json:"belongs_to_collection"`
BelongsToCollection CollectionShort `json:"belongs_to_collection"`
Budget uint32
Genres []struct {
ID int
Name string
}
Homepage string
ID int
ImdbID string `json:"imdb_id"`
OriginalLanguage string `json:"original_language"`
OriginalTitle string `json:"original_title"`
Overview string
Popularity float32
PosterPath string `json:"poster_path"`
ProductionCompanies []struct {
ID int
Name string
LogoPath string `json:"logo_path"`
Iso3166_1 string `json:"origin_country"`
} `json:"production_companies"`
ProductionCountries []struct {
Iso3166_1 string `json:"iso_3166_1"`
Name string
} `json:"production_countries"`
ReleaseDate string `json:"release_date"`
Revenue uint32
Runtime uint32
SpokenLanguages []struct {
Iso639_1 string `json:"iso_639_1"`
Name string
} `json:"spoken_languages"`
Status string
Tagline string
Title string
Video bool
VoteAverage float32 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
ExternalIDs *MovieExternalIds `json:"external_ids,omitempty"`
}
// MovieShort struct
type MovieShort struct {
Adult bool `json:"adult"`
BackdropPath string `json:"backdrop_path"`
ID int `json:"id"`
OriginalTitle string `json:"original_title"`
GenreIDs []int32 `json:"genre_ids"`
Popularity float32 `json:"popularity"`
PosterPath string `json:"poster_path"`
ReleaseDate string `json:"release_date"`
Title string `json:"title"`
Overview string `json:"overview"`
Video bool `json:"video"`
VoteAverage float32 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
}
// MovieDatedResults struct
type MovieDatedResults struct {
Dates struct {
Minimum string
Maximum string
}
Page int
Results []MovieShort
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
}
// MoviePagedResults struct
type MoviePagedResults struct {
ID int
Page int
Results []MovieShort
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieAccountState struct
type MovieAccountState struct {
ID int
Favorite bool
Watchlist bool
Rated struct {
Value float32
}
}
// MovieAlternativeTitles struct
type MovieAlternativeTitles struct {
ID int
Titles []struct {
Iso3166_1 string `json:"iso_3166_1"`
Title string
}
AccountStates *MovieAccountState `json:"account_states,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieChanges struct
type MovieChanges struct {
Changes []struct {
Key string
Items []struct {
ID string
Action string
Time string
}
}
}
// MovieCredits struct
type MovieCredits struct {
ID int
Cast []struct {
CastID int `json:"cast_id"`
Character string
CreditID string `json:"credit_id"`
ID int
Name string
Gender int `json:"gender"`
Order int
ProfilePath string `json:"profile_path"`
}
Crew []struct {
CreditID string `json:"credit_id"`
Department string
Gender int `json:"gender"`
ID int
Job string
Name string
ProfilePath string `json:"profile_path"`
}
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieExternalIds struct
type MovieExternalIds struct {
ID int
ImdbID string `json:"imdb_id"`
FacebookID string `json:"facebook_id"`
InstagramID string `json:"instagram_id"`
TwitterID string `json:"twitter_id"`
}
// MovieImage struct
type MovieImage struct {
FilePath string `json:"file_path"`
Width int
Height int
Iso639_1 string `json:"iso_639_1"`
AspectRatio float32 `json:"aspect_ratio"`
VoteAverage float32 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
}
// MovieImages struct
type MovieImages struct {
ID int
Backdrops []MovieImage
Posters []MovieImage
Logos []MovieImage
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieKeywords struct
type MovieKeywords struct {
ID int
Keywords []struct {
ID int
Name string
}
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieLists struct
type MovieLists struct {
ID int
Page int
Results []struct {
Description string
FavoriteCount int `json:"favorite_count"`
ID string
ItemCount int `json:"item_count"`
Iso639_1 string `json:"iso_639_1"`
Name string
PosterPath string `json:"poster_path"`
}
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieRating struct
type MovieRating struct {
StatusCode int `json:"status_code"`
StatusMessage string `json:"status_message"`
}
// MovieReleases struct
type MovieReleases struct {
ID int
Countries []struct {
Iso3166_1 string `json:"iso_3166_1"`
Certification string
ReleaseDate string `json:"release_date"`
}
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieReviews struct
type MovieReviews struct {
ID int
Page int
Results []struct {
ID string
Author string
Content string
URL string
}
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieTranslations struct
type MovieTranslations struct {
ID int
Translations []struct {
Iso3166_1 string `json:"iso_3166_1"`
Iso639_1 string `json:"iso_639_1"`
Name string `json:"name"`
EnglishName string `json:"english_name"`
Data struct {
Title string `json:"title,omitempty"`
Overview string `json:"overview,omitempty"`
Homepage string `json:"homepage,omitempty"`
} `json:"data"`
}
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Videos *MovieVideos `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// MovieRecommendations struct for movie recommendations.
type MovieRecommendations struct {
Page int `json:"page"`
Results []struct {
Adult bool `json:"adult"`
BackdropPath string `json:"backdrop_path"`
GenreIDs []int `json:"genre_ids"`
ID int `json:"id"`
OriginalLanguage string `json:"original_language"`
OriginalTitle string `json:"original_title"`
Overview string `json:"overview"`
ReleaseDate string `json:"release_date"`
PosterPath string `json:"poster_path"`
Popularity float32 `json:"popularity"`
Title string `json:"title"`
Video bool `json:"video"`
VoteAverage float32 `json:"vote_average"`
VoteCount uint32 `json:"vote_count"`
} `json:"results"`
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
}
// MovieVideos struct
type MovieVideos struct {
ID int
Results []struct {
ID string
Iso639_1 string `json:"iso_639_1"`
Key string
Name string
Site string
Size int
Type string
}
AlternativeTitles *MovieAlternativeTitles `json:"alternative_titles,omitempty"`
Credits *MovieCredits `json:",omitempty"`
Images *MovieImages `json:",omitempty"`
Keywords *MovieKeywords `json:",omitempty"`
Releases *MovieReleases `json:",omitempty"`
Translations *MovieTranslations `json:",omitempty"`
Similar *MoviePagedResults `json:",omitempty"`
Reviews *MovieReviews `json:",omitempty"`
Lists *MovieLists `json:",omitempty"`
Changes *MovieChanges `json:",omitempty"`
Rating *MovieRating `json:",omitempty"`
}
// GetMovieInfo for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-details
func (tmdb *TMDb) GetMovieInfo(id int, options map[string]string) (*Movie, error) {
var availableOptions = map[string]struct{}{
"language": {},
"append_to_response": {}}
var movie Movie
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &movie)
return result.(*Movie), err
}
// GetMovieAccountStates gets the status of whether or not the movie has been rated or added to their favourite or movie watch list
// https://developers.themoviedb.org/3/movies/get-movie-account-states
func (tmdb *TMDb) GetMovieAccountStates(id int, sessionID string) (*MovieAccountState, error) {
var state MovieAccountState
uri := fmt.Sprintf("%s/movie/%v/account_states?api_key=%s&session_id=%s", baseURL, id, tmdb.apiKey, sessionID)
result, err := getTmdb(uri, &state)
return result.(*MovieAccountState), err
}
// GetMovieAlternativeTitles for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-alternative-titles
func (tmdb *TMDb) GetMovieAlternativeTitles(id int, options map[string]string) (*MovieAlternativeTitles, error) {
var availableOptions = map[string]struct{}{
"country": {},
"append_to_response": {}}
var titles MovieAlternativeTitles
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/alternative_titles?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &titles)
return result.(*MovieAlternativeTitles), err
}
// GetMovieChanges for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-changes
func (tmdb *TMDb) GetMovieChanges(id int, options map[string]string) (*MovieChanges, error) {
var availableOptions = map[string]struct{}{
"start_date": {},
"end_date": {}}
var changes MovieChanges
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/changes?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &changes)
return result.(*MovieChanges), err
}
// GetMovieCredits for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-credits
func (tmdb *TMDb) GetMovieCredits(id int, options map[string]string) (*MovieCredits, error) {
var availableOptions = map[string]struct{}{
"append_to_response": {}}
var credits MovieCredits
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/credits?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &credits)
return result.(*MovieCredits), err
}
// GetMovieImages for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-images
func (tmdb *TMDb) GetMovieImages(id int, options map[string]string) (*MovieImages, error) {
var availableOptions = map[string]struct{}{
"language": {},
"append_to_response": {},
"include_image_language": {}}
var images MovieImages
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/images?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &images)
return result.(*MovieImages), err
}
// GetMovieKeywords for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-keywords
func (tmdb *TMDb) GetMovieKeywords(id int, options map[string]string) (*MovieKeywords, error) {
var availableOptions = map[string]struct{}{
"append_to_response": {}}
var keywords MovieKeywords
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/keywords?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &keywords)
return result.(*MovieKeywords), err
}
// GetMovieLatest gets the latest movie
// https://developers.themoviedb.org/3/movies/get-latest-movie
func (tmdb *TMDb) GetMovieLatest() (*Movie, error) {
var movie Movie
uri := fmt.Sprintf("%s/movie/latest?api_key=%s", baseURL, tmdb.apiKey)
result, err := getTmdb(uri, &movie)
return result.(*Movie), err
}
// GetMovieLists that the movie belongs to
// https://developers.themoviedb.org/3/movies/get-movie-lists
func (tmdb *TMDb) GetMovieLists(id int, options map[string]string) (*MovieLists, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {},
"append_to_response": {}}
var lists MovieLists
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/lists?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &lists)
return result.(*MovieLists), err
}
// GetMovieNowPlaying that have been, or are being released this week
// https://developers.themoviedb.org/3/movies/get-now-playing
func (tmdb *TMDb) GetMovieNowPlaying(options map[string]string) (*MovieDatedResults, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {}}
var nowPlaying MovieDatedResults
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/now_playing?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &nowPlaying)
return result.(*MovieDatedResults), err
}
// GetMoviePopular gets the list of popular movies on The Movie Database
// https://developers.themoviedb.org/3/movies/get-popular-movies
func (tmdb *TMDb) GetMoviePopular(options map[string]string) (*MoviePagedResults, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {}}
var popular MoviePagedResults
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/popular?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &popular)
return result.(*MoviePagedResults), err
}
// GetMovieReleases for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-release-dates
func (tmdb *TMDb) GetMovieReleases(id int, options map[string]string) (*MovieReleases, error) {
var availableOptions = map[string]struct{}{
"append_to_response": {}}
var releases MovieReleases
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/releases?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &releases)
return result.(*MovieReleases), err
}
// GetMovieReviews for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-reviews
func (tmdb *TMDb) GetMovieReviews(id int, options map[string]string) (*MovieReviews, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {},
"append_to_response": {}}
var reviews MovieReviews
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/reviews?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &reviews)
return result.(*MovieReviews), err
}
// GetMovieSimilar for a specific movie id
// https://developers.themoviedb.org/3/movies/get-similar-movies
func (tmdb *TMDb) GetMovieSimilar(id int, options map[string]string) (*MoviePagedResults, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {},
"append_to_response": {}}
var similar MoviePagedResults
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/similar?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &similar)
return result.(*MoviePagedResults), err
}
// GetMovieTopRated gets the list of top rated movies
// https://developers.themoviedb.org/3/movies/get-top-rated-movies
func (tmdb *TMDb) GetMovieTopRated(options map[string]string) (*MoviePagedResults, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {}}
var topRated MoviePagedResults
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/top_rated?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &topRated)
return result.(*MoviePagedResults), err
}
// GetMovieTranslations for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-translations
func (tmdb *TMDb) GetMovieTranslations(id int, options map[string]string) (*MovieTranslations, error) {
var availableOptions = map[string]struct{}{
"append_to_response": {}}
var translations MovieTranslations
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/translations?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &translations)
return result.(*MovieTranslations), err
}
// GetMovieRecommendations gets a list of recommended movies for a movie by id
// https://developers.themoviedb.org/3/movies/get-movie-recommendations
func (tmdb *TMDb) GetMovieRecommendations(id int, options map[string]string) (*MovieRecommendations, error) {
var availableOptions = map[string]struct{}{
"language": {},
"page": {}}
var movieRec MovieRecommendations
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/recommendations?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &movieRec)
return result.(*MovieRecommendations), err
}
// GetMovieVideos for a specific movie id
// https://developers.themoviedb.org/3/movies/get-movie-recommendations
func (tmdb *TMDb) GetMovieVideos(id int, options map[string]string) (*MovieVideos, error) {
var availableOptions = map[string]struct{}{
"language": {},
"append_to_response": {}}
var videos MovieVideos
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/%v/videos?api_key=%s%s", baseURL, id, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &videos)
return result.(*MovieVideos), err
}
// GetMovieUpcoming by release date
// https://developers.themoviedb.org/3/movies/get-upcoming
func (tmdb *TMDb) GetMovieUpcoming(options map[string]string) (*MovieDatedResults, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {}}
var upcoming MovieDatedResults
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/movie/upcoming?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &upcoming)
return result.(*MovieDatedResults), err
}
// GetMovieExternalIds gets the external ids for a movie
// https://developers.themoviedb.org/3/movies/get-movie-external-ids
func (tmdb *TMDb) GetMovieExternalIds(movieID int, options map[string]string) (*MovieExternalIds, error) {
// currently there are not options, left it so it may be updated in the future without breaking existing code
var ids MovieExternalIds
uri := fmt.Sprintf("%s/movie/%v/external_ids?api_key=%s", baseURL, movieID, tmdb.apiKey)
result, err := getTmdb(uri, &ids)
return result.(*MovieExternalIds), err
}
// // SetMovieRating lets users rate a movie
// // https://developers.themoviedb.org/3/movies/rate-movie
// func (tmdb *TMDb) SetMovieRating(id int) (*MovieRating, error) {
// // TODO
// var rating MovieRating
// var err error
// return &rating, err
// }