tmdb - keyword.go
1 package tmdb
2
3 import (
4 "fmt"
5 "net/url"
6 )
7
8 // Keyword contains the ID and Name of a keyword
9 type Keyword struct {
10 ID int64 `json:"id"`
11 Name string `json:"string"`
12 }
13
14 // Keyword returns the Keyword specified by the ID given
15 func (t *TMDB) Keyword(id int64) (*Keyword, error) {
16 k := new(Keyword)
17 if err := t.get(k, fmt.Sprintf("/3/keyword/%d", id), url.Values{}); err != nil {
18 return nil, err
19 }
20 return k, nil
21 }
22
23 // KeywordMovies retrieves a list of movies that share the keyword given
24 func (t *TMDB) KeywordMovies(id int64, params ...option) (*SearchMovie, error) {
25 s := new(SearchMovie)
26 if err := t.get(s, fmt.Sprintf("/3/keyword/%d", id), url.Values{}, params...); err != nil {
27 return nil, err
28 }
29 return s, nil
30 }