|
|
@ -1,16 +1,22 @@ |
|
|
|
package tmdb |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"git.realxlfd.cc/RealXLFD/golib/urlbuilder" |
|
|
|
"strconv" |
|
|
|
) |
|
|
|
|
|
|
|
type RespTVDetails struct { |
|
|
|
Id string `json:"_id"` |
|
|
|
AirDate string `json:"air_date"` |
|
|
|
Episodes []struct { |
|
|
|
} `json:"episodes"` |
|
|
|
Name string `json:"name"` |
|
|
|
Overview string `json:"overview"` |
|
|
|
Id1 int `json:"id"` |
|
|
|
PosterPath string `json:"poster_path"` |
|
|
|
SeasonNumber int `json:"season_number"` |
|
|
|
VoteAverage int `json:"vote_average"` |
|
|
|
Id string `json:"_id"` |
|
|
|
AirDate string `json:"air_date"` |
|
|
|
Episodes []RespTVEpisodeDetails `json:"episodes"` |
|
|
|
Name string `json:"name"` |
|
|
|
Overview string `json:"overview"` |
|
|
|
Id1 int `json:"id"` |
|
|
|
PosterPath string `json:"poster_path"` |
|
|
|
SeasonNumber int `json:"season_number"` |
|
|
|
VoteAverage float32 `json:"vote_average"` |
|
|
|
} |
|
|
|
|
|
|
|
type RespTVEpisodeDetails struct { |
|
|
@ -25,7 +31,7 @@ type RespTVEpisodeDetails struct { |
|
|
|
SeasonNumber int `json:"season_number"` |
|
|
|
ShowId int `json:"show_id"` |
|
|
|
StillPath interface{} `json:"still_path"` |
|
|
|
VoteAverage int `json:"vote_average"` |
|
|
|
VoteAverage float64 `json:"vote_average"` |
|
|
|
VoteCount int `json:"vote_count"` |
|
|
|
Crew []struct { |
|
|
|
Department string `json:"department"` |
|
|
@ -55,6 +61,39 @@ type RespTVEpisodeDetails struct { |
|
|
|
} `json:"guest_stars"` |
|
|
|
} |
|
|
|
|
|
|
|
func ListTVEpisodes(id int) (*RespTVDetails, []error) { |
|
|
|
|
|
|
|
func ListTVEpisodes(id, season int) (*RespTVDetails, []error) { |
|
|
|
targetURL, _ := urlbuilder.New(baseURL.String()).AddPath( |
|
|
|
strconv.Itoa( |
|
|
|
ApiVersion, |
|
|
|
), |
|
|
|
).AddPath(path_TV).AddPath(strconv.Itoa(id)).AddPath(`season`).AddPath(strconv.Itoa(season)).AddQuery( |
|
|
|
`language`, |
|
|
|
string(ZH_CN), |
|
|
|
).AddQuery( |
|
|
|
`api_key`, |
|
|
|
api_key, |
|
|
|
).Get() |
|
|
|
content, errs := sendRequest(targetURL) |
|
|
|
if errs != nil { |
|
|
|
if content != nil { |
|
|
|
errMsg := &RespErrorInfo{} |
|
|
|
_ = json.Unmarshal( |
|
|
|
content, |
|
|
|
errMsg, |
|
|
|
) |
|
|
|
return nil, []error{ |
|
|
|
errors.New(errMsg.StatusMessage), |
|
|
|
} |
|
|
|
} |
|
|
|
return nil, errs |
|
|
|
} |
|
|
|
result := &RespTVDetails{} |
|
|
|
err := json.Unmarshal( |
|
|
|
content, |
|
|
|
result, |
|
|
|
) |
|
|
|
if err != nil { |
|
|
|
return nil, []error{err} |
|
|
|
} |
|
|
|
return result, nil |
|
|
|
} |
|
|
|