-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathtv.go
1077 lines (1010 loc) · 28.9 KB
/
tv.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
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package tmdb
import (
"fmt"
"net/http"
jsoniter "github.com/json-iterator/go"
)
// TVDetails type is a struct for details JSON response.
type TVDetails struct {
BackdropPath string `json:"backdrop_path"`
CreatedBy []struct {
ID int64 `json:"id"`
CreditID string `json:"credit_id"`
Name string `json:"name"`
Gender int `json:"gender"`
ProfilePath string `json:"profile_path"`
} `json:"created_by"`
EpisodeRunTime []int `json:"episode_run_time"`
FirstAirDate string `json:"first_air_date"`
Genres []struct {
ID int64 `json:"id"`
Name string `json:"name"`
} `json:"genres"`
Homepage string `json:"homepage"`
ID int64 `json:"id"`
InProduction bool `json:"in_production"`
Languages []string `json:"languages"`
LastAirDate string `json:"last_air_date"`
LastEpisodeToAir struct {
AirDate string `json:"air_date"`
EpisodeNumber int `json:"episode_number"`
ID int64 `json:"id"`
Name string `json:"name"`
Overview string `json:"overview"`
ProductionCode string `json:"production_code"`
SeasonNumber int `json:"season_number"`
ShowID int64 `json:"show_id"`
StillPath string `json:"still_path"`
VoteAverage float32 `json:"vote_average"`
VoteCount int64 `json:"vote_count"`
} `json:"last_episode_to_air"`
Name string `json:"name"`
NextEpisodeToAir struct {
AirDate string `json:"air_date"`
EpisodeNumber int `json:"episode_number"`
ID int64 `json:"id"`
Name string `json:"name"`
Overview string `json:"overview"`
ProductionCode string `json:"production_code"`
SeasonNumber int `json:"season_number"`
ShowID int64 `json:"show_id"`
StillPath string `json:"still_path"`
VoteAverage float32 `json:"vote_average"`
VoteCount int64 `json:"vote_count"`
} `json:"next_episode_to_air"`
Networks []struct {
Name string `json:"name"`
ID int64 `json:"id"`
LogoPath string `json:"logo_path"`
OriginCountry string `json:"origin_country"`
} `json:"networks"`
NumberOfEpisodes int `json:"number_of_episodes"`
NumberOfSeasons int `json:"number_of_seasons"`
OriginCountry []string `json:"origin_country"`
OriginalLanguage string `json:"original_language"`
OriginalName string `json:"original_name"`
Overview string `json:"overview"`
Popularity float32 `json:"popularity"`
PosterPath string `json:"poster_path"`
ProductionCompanies []struct {
Name string `json:"name"`
ID int64 `json:"id"`
LogoPath string `json:"logo_path"`
OriginCountry string `json:"origin_country"`
} `json:"production_companies"`
ProductionCountries []struct {
Iso3166_1 string `json:"iso_3166_1"`
Name string `json:"name"`
} `json:"production_countries"`
Seasons []struct {
AirDate string `json:"air_date"`
EpisodeCount int `json:"episode_count"`
ID int64 `json:"id"`
Name string `json:"name"`
Overview string `json:"overview"`
PosterPath string `json:"poster_path"`
SeasonNumber int `json:"season_number"`
VoteAverage float32 `json:"vote_average"`
} `json:"seasons"`
Status string `json:"status"`
Tagline string `json:"tagline"`
Type string `json:"type"`
VoteAverage float32 `json:"vote_average"`
VoteCount int64 `json:"vote_count"`
*TVAggregateCreditsAppend
*TVAlternativeTitlesAppend
*TVChangesAppend
*TVContentRatingsAppend
*TVCreditsAppend
*TVEpisodeGroupsAppend
*TVExternalIDsAppend
*TVImagesAppend
*TVKeywordsAppend
*TVRecommendationsAppend
*TVReviewsAppend
*TVScreenedTheatricallyAppend
*TVSimilarAppend
*TVTranslationsAppend
*TVVideosAppend
*TVWatchProvidersAppend
}
// TVAggregateCreditsAppend type is a struct
// for aggregate credits in append to response.
type TVAggregateCreditsAppend struct {
AggregateCredits *TVAggregateCredits `json:"aggregate_credits,omitempty"`
}
// TVAlternativeTitlesAppend type is a struct
// for alternative titles in append to response.
type TVAlternativeTitlesAppend struct {
AlternativeTitles *TVAlternativeTitles `json:"alternative_titles,omitempty"`
}
// TVChangesAppend type is a struct for changes in append to response.
type TVChangesAppend struct {
Changes *TVChanges `json:"changes,omitempty"`
}
// TVContentRatingsAppend type is a struct for
// content ratings in append to response.
type TVContentRatingsAppend struct {
ContentRatings *TVContentRatings `json:"content_ratings,omitempty"`
}
// TVCreditsAppend type is a struct for credits in append to response.
type TVCreditsAppend struct {
Credits struct {
*TVCredits
} `json:"credits,omitempty"`
}
// TVEpisodeGroupsAppend type is a struct for
// episode groups in append to response.
type TVEpisodeGroupsAppend struct {
EpisodeGroups *TVEpisodeGroups `json:"episode_groups,omitempty"`
}
// TVExternalIDsAppend type is a short for
// external ids in append to response.
type TVExternalIDsAppend struct {
*TVExternalIDs `json:"external_ids,omitempty"`
}
// TVImagesAppend type is a struct for images in append to response.
type TVImagesAppend struct {
Images *TVImages `json:"images,omitempty"`
}
// TVKeywordsAppend type is a struct for keywords in append to response.
type TVKeywordsAppend struct {
Keywords struct {
*TVKeywords
} `json:"keywords,omitempty"`
}
// TVRecommendationsAppend type is a struct
// for recommendations in append to response.
type TVRecommendationsAppend struct {
Recommendations *TVRecommendations `json:"recommendations,omitempty"`
}
// TVReviewsAppend type is a struct for reviews in append to response.
type TVReviewsAppend struct {
Reviews struct {
*TVReviews
} `json:"reviews,omitempty"`
}
// TVScreenedTheatricallyAppend type is a struct
// for screened theatrically in append to response.
type TVScreenedTheatricallyAppend struct {
ScreenedTheatrically *TVScreenedTheatrically `json:"screened_theatrically,omitempty"`
}
// TVSimilarAppend type is a struct for
// similar tv shows in append to response.
type TVSimilarAppend struct {
Similar *TVSimilar `json:"similar,omitempty"`
}
// TVTranslationsAppend type is a struct
// for translations in append to response.
type TVTranslationsAppend struct {
Translations *TVTranslations `json:"translations,omitempty"`
}
// TVVideosAppend type is a struct for videos in append to response.
type TVVideosAppend struct {
Videos struct {
*TVVideos
} `json:"videos,omitempty"`
}
// TVWatchProvidersAppend type is a struct for
// watch/providers in append to response.
type TVWatchProvidersAppend struct {
WatchProviders *TVWatchProviders `json:"watch/providers,omitempty"`
}
// GetTVDetails get the primary TV show details by id.
//
// Supports append_to_response.
//
// https://developers.themoviedb.org/3/tv/get-tv-details
func (c *Client) GetTVDetails(
id int,
urlOptions map[string]string,
) (*TVDetails, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvDetails := TVDetails{}
if err := c.get(tmdbURL, &tvDetails); err != nil {
return nil, err
}
return &tvDetails, nil
}
// TVAccountStates type is a struct for account states JSON response.
type TVAccountStates struct {
ID int64 `json:"id"`
Favorite bool `json:"favorite"`
Rated jsoniter.RawMessage `json:"rated"`
Watchlist bool `json:"watchlist"`
}
// GetTVAccountStates grab the following account states for a session:
//
// TV show rating.
//
// If it belongs to your watchlist.
//
// If it belongs to your favourite list.
//
// https://developers.themoviedb.org/3/tv/get-tv-account-states
func (c *Client) GetTVAccountStates(
id int,
urlOptions map[string]string,
) (*TVAccountStates, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/account_states?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvAccountStates := TVAccountStates{}
if err := c.get(tmdbURL, &tvAccountStates); err != nil {
return nil, err
}
return &tvAccountStates, nil
}
// TVAggregateCredits type is a struct for aggregate credits JSON response.
type TVAggregateCredits struct {
ID int64 `json:"id,omitempty"`
Cast []struct {
ID int64 `json:"id"`
Adult bool `json:"adult"`
Gender int `json:"gender"`
KnownForDepartment string `json:"known_for_department"`
Name string `json:"name"`
Order int `json:"order"`
OriginalName string `json:"original_name"`
Popularity float64 `json:"popularity"`
ProfilePath string `json:"profile_path"`
Roles []struct {
Character string `json:"character"`
CreditID string `json:"credit_id"`
EpisodeCount int `json:"episode_count"`
} `json:"roles"`
TotalEpisodeCount int `json:"total_episode_count"`
} `json:"cast"`
Crew []struct {
ID int64 `json:"id"`
Adult bool `json:"adult"`
Department string `json:"department"`
Gender int `json:"gender"`
Jobs []struct {
CreditID string `json:"credit_id"`
EpisodeCount int `json:"episode_count"`
Job string `json:"job"`
} `json:"jobs"`
TotalEpisodeCount int `json:"total_episode_count"`
KnownForDepartment string `json:"known_for_department"`
Name string `json:"name"`
OriginalName string `json:"original_name"`
Popularity float64 `json:"popularity"`
ProfilePath string `json:"profile_path"`
} `json:"crew"`
}
// GetTVAggregateCredits get the aggregate credits (cast and crew) that have been added to a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-aggregate-credits
func (c *Client) GetTVAggregateCredits(
id int,
urlOptions map[string]string,
) (*TVAggregateCredits, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/aggregate_credits?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvAggregateCredits := TVAggregateCredits{}
if err := c.get(tmdbURL, &tvAggregateCredits); err != nil {
return nil, err
}
return &tvAggregateCredits, nil
}
// TVAlternativeTitles type is a struct for alternative titles JSON response.
type TVAlternativeTitles struct {
ID int `json:"id,omitempty"`
*TVAlternativeTitlesResults
}
// GetTVAlternativeTitles get all of the alternative titles for a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-alternative-titles
func (c *Client) GetTVAlternativeTitles(
id int,
urlOptions map[string]string,
) (*TVAlternativeTitles, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/alternative_titles?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvAlternativeTitles := TVAlternativeTitles{}
if err := c.get(tmdbURL, &tvAlternativeTitles); err != nil {
return nil, err
}
return &tvAlternativeTitles, nil
}
// TVChanges type is a struct for changes JSON response.
type TVChanges struct {
Changes []struct {
Key string `json:"key"`
Items []struct {
ID string `json:"id"`
Action string `json:"action"`
Time string `json:"time"`
Iso639_1 string `json:"iso_639_1"`
Iso3166_1 string `json:"iso_3166_1"`
Value jsoniter.RawMessage `json:"value"`
OriginalValue jsoniter.RawMessage `json:"original_value"`
} `json:"items"`
} `json:"changes"`
}
// GetTVChanges get the changes for a TV show.
//
// By default only the last 24 hours are returned.
// You can query up to 14 days in a single query by using
// the start_date and end_date query parameters.
//
// TV show changes are different than movie changes in that there
// are some edits on seasons and episodes that will create a change
// entry at the show level. These can be found under the season
// and episode keys. These keys will contain a series_id and episode_id.
// You can use the and methods to look these up individually.
//
// https://developers.themoviedb.org/3/tv/get-tv-changes
func (c *Client) GetTVChanges(
id int,
urlOptions map[string]string,
) (*TVChanges, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/changes?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tVChanges := TVChanges{}
if err := c.get(tmdbURL, &tVChanges); err != nil {
return nil, err
}
return &tVChanges, nil
}
// TVContentRatings type is a struct for content ratings JSON response.
type TVContentRatings struct {
*TVContentRatingsResults
ID int64 `json:"id,omitempty"`
}
// GetTVContentRatings get the list of content ratings (certifications) that have been added to a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-content-ratings
func (c *Client) GetTVContentRatings(
id int,
urlOptions map[string]string,
) (*TVContentRatings, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/content_ratings?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvContentRatings := TVContentRatings{}
if err := c.get(tmdbURL, &tvContentRatings); err != nil {
return nil, err
}
return &tvContentRatings, nil
}
// TVCredits type is a struct for credits JSON response.
type TVCredits struct {
ID int64 `json:"id,omitempty"`
Cast []struct {
Character string `json:"character"`
CreditID string `json:"credit_id"`
Gender int `json:"gender"`
ID int64 `json:"id"`
KnownForDepartment string `json:"known_for_department"`
Name string `json:"name"`
Order int `json:"order"`
OriginalName string `json:"original_name"`
Popularity float32 `json:"popularity"`
ProfilePath string `json:"profile_path"`
} `json:"cast"`
Crew []struct {
CreditID string `json:"credit_id"`
Department string `json:"department"`
Gender int `json:"gender"`
ID int64 `json:"id"`
Job string `json:"job"`
KnownForDepartment string `json:"known_for_department"`
Name string `json:"name"`
OriginalName string `json:"original_name"`
Popularity float32 `json:"popularity"`
ProfilePath string `json:"profile_path"`
} `json:"crew"`
}
// GetTVCredits get the credits (cast and crew) that have been added to a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-credits
func (c *Client) GetTVCredits(
id int,
urlOptions map[string]string,
) (*TVCredits, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/credits?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvCredits := TVCredits{}
if err := c.get(tmdbURL, &tvCredits); err != nil {
return nil, err
}
return &tvCredits, nil
}
// TVEpisodeGroups type is a struct for episode groups JSON response.
type TVEpisodeGroups struct {
*TVEpisodeGroupsResults
ID int64 `json:"id,omitempty"`
}
// GetTVEpisodeGroups get all of the episode groups that have been created for a TV show.
//
// With a group ID you can call the get TV episode group details method.
//
// https://developers.themoviedb.org/3/tv/get-tv-episode-groups
func (c *Client) GetTVEpisodeGroups(
id int,
urlOptions map[string]string,
) (*TVEpisodeGroups, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/episode_groups?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tVEpisodeGroups := TVEpisodeGroups{}
if err := c.get(tmdbURL, &tVEpisodeGroups); err != nil {
return nil, err
}
return &tVEpisodeGroups, nil
}
// TVExternalIDs type is a struct for external ids JSON response.
type TVExternalIDs struct {
IMDbID string `json:"imdb_id"`
FreebaseMID string `json:"freebase_mid"`
FreebaseID string `json:"freebase_id"`
TVDBID int64 `json:"tvdb_id"`
TVRageID int64 `json:"tvrage_id"`
FacebookID string `json:"facebook_id"`
InstagramID string `json:"instagram_id"`
TwitterID string `json:"twitter_id"`
WikiDataID string `json:"wikidata_id,omitempty"`
ID int64 `json:"id,omitempty"`
}
// GetTVExternalIDs get the external ids for a TV show.
//
// We currently support the following external sources.
//
// Media Databases: IMDb ID, TVDB ID, Freebase MID*, Freebase ID* TVRage ID*.
//
// Social IDs: Facebook, Instagram and Twitter.
//
// *Defunct or no longer available as a service.
//
// https://developers.themoviedb.org/3/tv/get-tv-external-ids
func (c *Client) GetTVExternalIDs(
id int,
urlOptions map[string]string,
) (*TVExternalIDs, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/external_ids?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvExternalIDs := TVExternalIDs{}
if err := c.get(tmdbURL, &tvExternalIDs); err != nil {
return nil, err
}
return &tvExternalIDs, nil
}
// TVImage type is a struct for a single image.
type TVImage struct {
AspectRatio float32 `json:"aspect_ratio"`
FilePath string `json:"file_path"`
Height int `json:"height"`
Iso639_1 string `json:"iso_639_1"`
VoteAverage float32 `json:"vote_average"`
VoteCount int64 `json:"vote_count"`
Width int `json:"width"`
}
// TVImages type is a struct for images JSON response.
type TVImages struct {
ID int64 `json:"id,omitempty"`
Backdrops []TVImage `json:"backdrops"`
Logos []TVImage `json:"logos"`
Posters []TVImage `json:"posters"`
}
// GetTVImages get the images that belong to a TV show.
//
// Querying images with a language parameter will filter the results.
// If you want to include a fallback language (especially useful for backdrops)
// you can use the include_image_language parameter. This should be a comma
// separated value like so: include_image_language=en,null.
//
// https://developers.themoviedb.org/3/tv/get-tv-images
func (c *Client) GetTVImages(
id int,
urlOptions map[string]string,
) (*TVImages, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/images?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvImages := TVImages{}
if err := c.get(tmdbURL, &tvImages); err != nil {
return nil, err
}
return &tvImages, nil
}
// TVKeywords type is a struct for keywords JSON response.
type TVKeywords struct {
ID int64 `json:"id,omitempty"`
*TVKeywordsResults
}
// GetTVKeywords get the keywords that have been added to a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-keywords
func (c *Client) GetTVKeywords(
id int,
) (*TVKeywords, error) {
tmdbURL := fmt.Sprintf(
"%s%s%d/keywords?api_key=%s",
baseURL,
tvURL,
id,
c.apiKey,
)
tvKeywords := TVKeywords{}
if err := c.get(tmdbURL, &tvKeywords); err != nil {
return nil, err
}
return &tvKeywords, nil
}
// TVRecommendations type is a struct for recommendations JSON response.
type TVRecommendations struct {
Page int64 `json:"page"`
*TVRecommendationsResults
TotalPages int64 `json:"total_pages"`
TotalResults int64 `json:"total_results"`
}
// GetTVRecommendations get the list of TV show recommendations for this item.
//
// https://developers.themoviedb.org/3/tv/get-tv-recommendations
func (c *Client) GetTVRecommendations(
id int,
urlOptions map[string]string,
) (*TVRecommendations, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/recommendations?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvRecommendations := TVRecommendations{}
if err := c.get(tmdbURL, &tvRecommendations); err != nil {
return nil, err
}
return &tvRecommendations, nil
}
// TVReviews type is a struct for reviews JSON response.
type TVReviews struct {
ID int64 `json:"id,omitempty"`
Page int64 `json:"page"`
*TVReviewsResults
TotalPages int64 `json:"total_pages"`
TotalResults int64 `json:"total_results"`
}
// GetTVReviews get the reviews for a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-reviews
func (c *Client) GetTVReviews(
id int,
urlOptions map[string]string,
) (*TVReviews, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/reviews?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvReviews := TVReviews{}
if err := c.get(tmdbURL, &tvReviews); err != nil {
return nil, err
}
return &tvReviews, nil
}
// TVScreenedTheatrically type is a struct for screened theatrically JSON response.
type TVScreenedTheatrically struct {
ID int64 `json:"id,omitempty"`
*TVScreenedTheatricallyResults
}
// GetTVScreenedTheatrically get a list of seasons or episodes that
// have been screened in a film festival or theatre.
//
// https://developers.themoviedb.org/3/tv/get-screened-theatrically
func (c *Client) GetTVScreenedTheatrically(
id int,
) (*TVScreenedTheatrically, error) {
tmdbURL := fmt.Sprintf(
"%s%s%d/screened_theatrically?api_key=%s",
baseURL,
tvURL,
id,
c.apiKey,
)
tvScreenedTheatrically := TVScreenedTheatrically{}
if err := c.get(tmdbURL, &tvScreenedTheatrically); err != nil {
return nil, err
}
return &tvScreenedTheatrically, nil
}
// TVSimilar type is a struct for similar tv shows JSON response.
type TVSimilar struct {
*TVRecommendations
}
// GetTVSimilar a list of similar TV shows.
// These items are assembled by looking at keywords and genres.
//
// https://developers.themoviedb.org/3/tv/get-similar-tv-shows
func (c *Client) GetTVSimilar(
id int,
urlOptions map[string]string,
) (*TVSimilar, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/similar?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tVSimilar := TVSimilar{}
if err := c.get(tmdbURL, &tVSimilar); err != nil {
return nil, err
}
return &tVSimilar, nil
}
// TVWatchProviders type is a struct for watch/providers JSON response.
type TVWatchProviders struct {
ID int64 `json:"id,omitempty"`
*TVWatchProvidersResults
}
// GetTVWatchProviders get a list of the availabilities per country by provider for a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-watch-providers
func (c *Client) GetTVWatchProviders(
id int,
urlOptions map[string]string,
) (*TVWatchProviders, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/watch/providers?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvWatchProviders := TVWatchProviders{}
if err := c.get(tmdbURL, &tvWatchProviders); err != nil {
return nil, err
}
return &tvWatchProviders, nil
}
// TVTranslations type is a struct for translations JSON response.
type TVTranslations struct {
ID int64 `json:"id,omitempty"`
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 {
Name string `json:"name"`
Overview string `json:"overview"`
Tagline string `json:"tagline"`
Homepage string `json:"homepage"`
} `json:"data"`
} `json:"translations"`
}
// GetTVTranslations get a list fo translations that have been created for a TV Show.
//
// https://developers.themoviedb.org/3/tv/get-tv-translations
func (c *Client) GetTVTranslations(
id int,
urlOptions map[string]string,
) (*TVTranslations, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/translations?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvTranslations := TVTranslations{}
if err := c.get(tmdbURL, &tvTranslations); err != nil {
return nil, err
}
return &tvTranslations, nil
}
// TVVideos type is a struct for videos JSON response.
type TVVideos struct {
ID int64 `json:"id,omitempty"`
*TVVideosResults
}
// GetTVVideos get the videos that have been added to a TV show.
//
// https://developers.themoviedb.org/3/tv/get-tv-videos
func (c *Client) GetTVVideos(
id int,
urlOptions map[string]string,
) (*TVVideos, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%s%d/videos?api_key=%s%s",
baseURL,
tvURL,
id,
c.apiKey,
options,
)
tvVideos := TVVideos{}
if err := c.get(tmdbURL, &tvVideos); err != nil {
return nil, err
}
return &tvVideos, nil
}
// TVLatest type is a struct for latest JSON response.
type TVLatest struct {
*TVDetails
}
// GetTVLatest get the most newly created TV show.
//
// This is a live response and will continuously change.
//
// https://developers.themoviedb.org/3/tv/get-latest-tv
func (c *Client) GetTVLatest(
urlOptions map[string]string,
) (*TVLatest, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%slatest?api_key=%s%s",
baseURL,
tvURL,
c.apiKey,
options,
)
tvLatest := TVLatest{}
if err := c.get(tmdbURL, &tvLatest); err != nil {
return nil, err
}
return &tvLatest, nil
}
// TVAiringToday type is a struct for airing today JSON response.
type TVAiringToday struct {
Page int64 `json:"page"`
TotalResults int64 `json:"total_results"`
TotalPages int64 `json:"total_pages"`
*TVAiringTodayResults
}
// GetTVAiringToday get a list of TV shows that are airing today.
// This query is purely day based as we do not currently support
// airing times.
//
// You can specify a to offset the day calculation.
// Without a specified timezone, this query defaults
// to EST (Eastern Time UTC-05:00).
//
// https://developers.themoviedb.org/3/tv/get-tv-airing-today
func (c *Client) GetTVAiringToday(
urlOptions map[string]string,
) (*TVAiringToday, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%sairing_today?api_key=%s%s",
baseURL,
tvURL,
c.apiKey,
options,
)
tvAiringToday := TVAiringToday{}
if err := c.get(tmdbURL, &tvAiringToday); err != nil {
return nil, err
}
return &tvAiringToday, nil
}
// TVOnTheAir type is a struct for on the air JSON response.
type TVOnTheAir struct {
*TVAiringToday
}
// GetTVOnTheAir get a list of shows that are currently on the air.
//
// This query looks for any TV show that has an episode with an
// air date in the next 7 days.
//
// https://developers.themoviedb.org/3/tv/get-tv-on-the-air
func (c *Client) GetTVOnTheAir(
urlOptions map[string]string,
) (*TVOnTheAir, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%son_the_air?api_key=%s%s",
baseURL,
tvURL,
c.apiKey,
options,
)
tvOnTheAir := TVOnTheAir{}
if err := c.get(tmdbURL, &tvOnTheAir); err != nil {
return nil, err
}
return &tvOnTheAir, nil
}
// TVPopular type is a struct for popular JSON response.
type TVPopular struct {
*TVAiringToday
}
// GetTVPopular get a list of the current popular TV shows on TMDb.
// This list updates daily.
//
// https://developers.themoviedb.org/3/tv/get-popular-tv-shows
func (c *Client) GetTVPopular(
urlOptions map[string]string,
) (*TVPopular, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%spopular?api_key=%s%s",
baseURL,
tvURL,
c.apiKey,
options,
)
tvPopular := TVPopular{}
if err := c.get(tmdbURL, &tvPopular); err != nil {
return nil, err
}
return &tvPopular, nil
}
// TVTopRated type is a struct for top rated JSON response.
type TVTopRated struct {
*TVAiringToday
}
// GetTVTopRated get a list of the top rated TV shows on TMDb.
//
// https://developers.themoviedb.org/3/tv/get-top-rated-tv
func (c *Client) GetTVTopRated(
urlOptions map[string]string,
) (*TVTopRated, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%stop_rated?api_key=%s%s",
baseURL,
tvURL,
c.apiKey,
options,
)
tvTopRated := TVTopRated{}