37 lines
779 B
Go
37 lines
779 B
Go
package tmdb
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type Config struct {
|
|
Image Image `json:"images"`
|
|
}
|
|
|
|
type Image struct {
|
|
BaseURL string `json:"base_url"`
|
|
SecureBaseURL string `json:"secure_base_url"`
|
|
BackdropSizes []string `json:"backdrop_sizes"`
|
|
LogoSizes []string `json:"logo_sizes"`
|
|
PosterSizes []string `json:"poster_sizes"`
|
|
ProfileSizes []string `json:"profile_sizes"`
|
|
StillSizes []string `json:"still_sizes"`
|
|
}
|
|
|
|
func (api *API) getConfig() error {
|
|
url := requestURL("configuration")
|
|
data, err := api.get(url)
|
|
if err != nil {
|
|
return errors.Wrap(err, "api.get")
|
|
}
|
|
config := Config{}
|
|
err = json.Unmarshal(data, &config)
|
|
if err != nil {
|
|
return errors.Wrap(err, "json.Unmarshal")
|
|
}
|
|
api.Config = &config
|
|
return nil
|
|
}
|