-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathdiscover.go
89 lines (84 loc) · 2.85 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
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
package tmdb
import "fmt"
// DiscoverMovie type is a struct for movie JSON response.
type DiscoverMovie struct {
Page int64 `json:"page"`
TotalResults int64 `json:"total_results"`
TotalPages int64 `json:"total_pages"`
*DiscoverMovieResults
}
// GetDiscoverMovie discover movies by different types of data like
// average rating, number of votes, genres and certifications. You can
// get a valid list of certifications from the method.
//
// Discover also supports a nice list of sort options.
// See below for all of the available options.
//
// Please note, when using certification \ certification.lte you must
// also specify certification_country. These two parameters work together
// in order to filter the results. You can only filter results with the
// countries we have added to our certifications list.
//
// If you specify the region parameter, the regional release date will be
// used instead of the primary release date. The date returned will be the
// first date based on your query (ie. if a with_release_type is specified).
// It's important to note the order of the release types that are used.
// Specifying "2|3" would return the limited theatrical release date as
// opposed to "3|2" which would return the theatrical date.
//
// Also note that a number of filters support being comma (,) or pipe (|)
// separated. Comma's are treated like an AND and query while pipe's
// are an OR.
//
// https://developers.themoviedb.org/3/discover/movie-discover
func (c *Client) GetDiscoverMovie(
urlOptions map[string]string,
) (*DiscoverMovie, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%smovie?api_key=%s%s",
baseURL,
discoverURL,
c.apiKey,
options,
)
discoverMovie := DiscoverMovie{}
if err := c.get(tmdbURL, &discoverMovie); err != nil {
return nil, err
}
return &discoverMovie, nil
}
// DiscoverTV type is a struct for tv JSON response.
type DiscoverTV struct {
Page int64 `json:"page"`
TotalResults int64 `json:"total_results"`
TotalPages int64 `json:"total_pages"`
*DiscoverTVResults
}
// GetDiscoverTV Discover TV shows by different types of data like average
// rating, number of votes, genres, the network they aired on and air dates.
//
// Discover also supports a nice list of sort options. See below for all of
// the available options.
//
// Also note that a number of filters support being comma (,) or pipe (|)
// separated. Comma's are treated like an AND and query while pipe's are an OR.
//
// https://developers.themoviedb.org/3/discover/tv-discover
func (c *Client) GetDiscoverTV(
urlOptions map[string]string,
) (*DiscoverTV, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%stv?api_key=%s%s",
baseURL,
discoverURL,
c.apiKey,
options,
)
discoverTV := DiscoverTV{}
if err := c.get(tmdbURL, &discoverTV); err != nil {
return nil, err
}
return &discoverTV, nil
}