This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
forked from ryanbradynd05/go-tmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discover.go
61 lines (58 loc) · 2.29 KB
/
discover.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
package tmdb
import (
"fmt"
)
// DiscoverMovie discovers movies by different types of data like average rating, number of votes, genres and certifications
// http://docs.themoviedb.apiary.io/#reference/discover/discovermovie/get
func (tmdb *TMDb) DiscoverMovie(options map[string]string) (*MoviePagedResults, error) {
var availableOptions = map[string]struct{}{
"certification_country": {},
"certification": {},
"certification.lte": {},
"include_adult": {},
"include_video": {},
"language": {},
"page": {},
"primary_release_year": {},
"primary_release_date.gte": {},
"primary_release_date.lte": {},
"release_date.gte": {},
"release_date.lte": {},
"sort_by": {},
"vote_count.gte": {},
"vote_count.lte": {},
"vote_average.gte": {},
"vote_average.lte": {},
"with_cast": {},
"with_crew": {},
"with_companies": {},
"with_genres": {},
"with_keywords": {},
"with_people": {},
"year": {}}
optionsString := getOptionsString(options, availableOptions)
var results MoviePagedResults
uri := fmt.Sprintf("%s/discover/movie?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &results)
return result.(*MoviePagedResults), err
}
// DiscoverTV discovers TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates
// http://docs.themoviedb.apiary.io/#reference/discover/discovertv/get
func (tmdb *TMDb) DiscoverTV(options map[string]string) (*TvPagedResults, error) {
var availableOptions = map[string]struct{}{
"page": {},
"language": {},
"sort_by": {},
"first_air_date_year": {},
"first_air_date.gte": {},
"first_air_date.lte": {},
"vote_count.gte": {},
"vote_average.gte": {},
"with_genres": {},
"with_networks": {}}
optionsString := getOptionsString(options, availableOptions)
var results TvPagedResults
uri := fmt.Sprintf("%s/discover/tv?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &results)
return result.(*TvPagedResults), err
}