forked from ryanbradynd05/go-tmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find.go
42 lines (39 loc) · 1.46 KB
/
find.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
38
39
40
41
42
package tmdb
import (
"fmt"
)
// FindResults struct
type FindResults struct {
MovieResults []MovieShort `json:"movie_results,omitempty"`
PersonResults []PersonShort `json:"person_results,omitempty"`
TvResults []TvShort `json:"tv_results,omitempty"`
TvEpisodeResults []struct {
AirDate string `json:"air_date"`
EpisodeNumber int `json:"episode_number"`
Name string
ID int
SeasonNumber int `json:"season_number"`
StillPath string `json:"still_path"`
ShowID int `json:"show_id"`
VoteAverage float32 `json:"vote_average"`
VoteCount int `json:"vote_count"`
} `json:"tv_episode_results,omitempty"`
TvSeasonResults []struct {
AirDate string `json:"air_date"`
Name string
ID int
SeasonNumber int `json:"season_number"`
ShowID int `json:"show_id"`
} `json:"tv_season_results,omitempty"`
}
// GetFind makes it easy to search for objects in our database by an external id
// https://developers.themoviedb.org/3/find/find-by-id
func (tmdb *TMDb) GetFind(id, source string, options map[string]string) (*FindResults, error) {
var availableOptions = map[string]struct{}{
"language": {}}
var results FindResults
optionsString := getOptionsString(options, availableOptions)
uri := fmt.Sprintf("%s/find/%s?api_key=%s&external_source=%s%s", baseURL, id, tmdb.apiKey, source, optionsString)
result, err := getTmdb(uri, &results)
return result.(*FindResults), err
}