forked from cyruzin/golang-tmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrending.go
59 lines (56 loc) · 1.34 KB
/
trending.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
package tmdb
import (
"fmt"
)
// Trending type is a struct for trending JSON response.
type Trending struct {
Page int `json:"page"`
*TrendingResults
TotalPages int64 `json:"total_pages"`
TotalResults int64 `json:"total_results"`
}
// GetTrending get the daily or weekly trending items.
//
// The daily trending list tracks items over the period of
// a day while items have a 24 hour half life. The weekly
// list tracks items over a 7 day period, with a 7 day
// half life.
//
// # Valid Media Types
//
// all - Include all movies, TV shows and people in the
// results as a global trending list.
//
// movie - Show the trending movies in the results.
//
// tv - Show the trending TV shows in the results.
//
// person - Show the trending people in the results.
//
// # Valid Time Windows
//
// day - View the trending list for the day.
//
// week - View the trending list for the week.
//
// https://developers.themoviedb.org/3/trending/get-trending
func (c *Client) GetTrending(
mediaType string,
timeWindow string,
urlOptions map[string]string,
) (*Trending, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s/trending/%s/%s?api_key=%s%s",
baseURL,
mediaType,
timeWindow,
c.apiKey,
options,
)
trending := Trending{}
if err := c.get(tmdbURL, &trending); err != nil {
return nil, err
}
return &trending, nil
}