-
Notifications
You must be signed in to change notification settings - Fork 58
/
genres.go
37 lines (33 loc) · 1.08 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
package tmdb
import (
"fmt"
)
// Genre struct
type Genre struct {
Genres []struct {
ID int
Name string
}
}
// GetMovieGenres gets the list of movie genres
// https://developers.themoviedb.org/3/genres/get-movie-list
func (tmdb *TMDb) GetMovieGenres(options map[string]string) (*Genre, error) {
var availableOptions = map[string]struct{}{
"language": {}}
var movieGenres Genre
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/genre/movie/list?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &movieGenres)
return result.(*Genre), err
}
// GetTvGenres gets the list of TV genres
// https://developers.themoviedb.org/3/genres/get-tv-list
func (tmdb *TMDb) GetTvGenres(options map[string]string) (*Genre, error) {
var availableOptions = map[string]struct{}{
"language": {}}
var tvGenres Genre
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/genre/tv/list?api_key=%s%s", baseURL, tmdb.apiKey, optionsString)
result, err := getTmdb(uri, &tvGenres)
return result.(*Genre), err
}