-
Notifications
You must be signed in to change notification settings - Fork 35
/
genres.go
53 lines (49 loc) · 1.21 KB
/
genres.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
package tmdb
import "fmt"
// GenreMovieList type is a struct for genres movie list JSON response.
type GenreMovieList struct {
Genres []struct {
ID int64 `json:"id"`
Name string `json:"name"`
} `json:"genres"`
}
// GetGenreMovieList get the list of official genres for movies.
//
// https://developers.themoviedb.org/3/genres/get-movie-list
func (c *Client) GetGenreMovieList(
urlOptions map[string]string,
) (*GenreMovieList, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%smovie/list?api_key=%s%s",
baseURL,
genreURL,
c.apiKey,
options,
)
genreMovieList := GenreMovieList{}
if err := c.get(tmdbURL, &genreMovieList); err != nil {
return nil, err
}
return &genreMovieList, nil
}
// GetGenreTVList get the list of official genres for TV shows.
//
// https://developers.themoviedb.org/3/genres/get-tv-list
func (c *Client) GetGenreTVList(
urlOptions map[string]string,
) (*GenreMovieList, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%stv/list?api_key=%s%s",
baseURL,
genreURL,
c.apiKey,
options,
)
genreTVList := GenreMovieList{}
if err := c.get(tmdbURL, &genreTVList); err != nil {
return nil, err
}
return &genreTVList, nil
}