56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package tmdb
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strconv"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type Credits struct {
|
|
ID int32 `json:"id"`
|
|
Cast []Cast `json:"cast"`
|
|
Crew []Crew `json:"crew"`
|
|
}
|
|
|
|
type Cast struct {
|
|
Adult bool `json:"adult"`
|
|
Gender int `json:"gender"`
|
|
ID int32 `json:"id"`
|
|
KnownFor string `json:"known_for_department"`
|
|
Name string `json:"name"`
|
|
OriginalName string `json:"original_name"`
|
|
Popularity int `json:"popularity"`
|
|
Profile string `json:"profile_path"`
|
|
CastID int32 `json:"cast_id"`
|
|
Character string `json:"character"`
|
|
CreditID string `json:"credit_id"`
|
|
Order int `json:"order"`
|
|
}
|
|
|
|
type Crew struct {
|
|
Adult bool `json:"adult"`
|
|
Gender int `json:"gender"`
|
|
ID int32 `json:"id"`
|
|
KnownFor string `json:"known_for_department"`
|
|
Name string `json:"name"`
|
|
OriginalName string `json:"original_name"`
|
|
Popularity int `json:"popularity"`
|
|
Profile string `json:"profile_path"`
|
|
CreditID string `json:"credit_id"`
|
|
Department string `json:"department"`
|
|
Job string `json:"job"`
|
|
}
|
|
|
|
func (api *API) GetCredits(movieid int64) (*Credits, error) {
|
|
path := []string{"movie", strconv.FormatInt(movieid, 10), "credits"}
|
|
url := buildURL(path, nil)
|
|
data, err := api.get(url)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "api.get")
|
|
}
|
|
credits := Credits{}
|
|
json.Unmarshal(data, &credits)
|
|
return &credits, nil
|
|
}
|