-
Notifications
You must be signed in to change notification settings - Fork 36
/
providers.go
90 lines (84 loc) · 2.73 KB
/
providers.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package tmdb
import "fmt"
// WatchRegionList type is a struct for watch region list JSON response.
type WatchRegionList struct {
Regions []struct {
Iso3166_1 string `json:"iso_3166_1"`
EnglishName string `json:"english_name"`
NativeName string `json:"native_name"`
} `json:"results"`
}
// WatchProviderList type is a struct for watch provider list JSON response.
type WatchProviderList struct {
Providers []struct {
ID int64 `json:"id"`
Name string `json:"name"`
DisplayPriorities map[string]int `json:"display_priorities"`
DisplayPriority int64 `json:"display_priority"`
LogoPath string `json:"logo_path"`
ProviderName string `json:"provider_name"`
ProviderID int `json:"provider_id"`
} `json:"results"`
}
// GetAvailableWatchProviderRegions get a list of all of the countries we have watch provider (OTT/streaming) data for.
//
// https://developers.themoviedb.org/3/watch-providers/get-available-regions
func (c *Client) GetAvailableWatchProviderRegions(
urlOptions map[string]string,
) (*WatchRegionList, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%sregions?api_key=%s%s",
baseURL,
watchProvidersURL,
c.apiKey,
options,
)
watchRegionList := WatchRegionList{}
if err := c.get(tmdbURL, &watchRegionList); err != nil {
return nil, err
}
return &watchRegionList, nil
}
// GetWatchProvidersMovie get a list of the watch provider (OTT/streaming) data we have available for movies.
// You can specify a watch_region param if you want to further filter the list by country.
//
// https://developers.themoviedb.org/3/watch-providers/get-movie-providers
func (c *Client) GetWatchProvidersMovie(
urlOptions map[string]string,
) (*WatchProviderList, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%smovie?api_key=%s%s",
baseURL,
watchProvidersURL,
c.apiKey,
options,
)
watchProvider := WatchProviderList{}
if err := c.get(tmdbURL, &watchProvider); err != nil {
return nil, err
}
return &watchProvider, nil
}
// GetWatchProvidersTv get a list of the watch provider (OTT/streaming) data we have available for TV series.
// You can specify a watch_region param if you want to further filter the list by country.
//
// https://developers.themoviedb.org/3/watch-providers/get-tv-providers
func (c *Client) GetWatchProvidersTv(
urlOptions map[string]string,
) (*WatchProviderList, error) {
options := c.fmtOptions(urlOptions)
tmdbURL := fmt.Sprintf(
"%s%stv?api_key=%s%s",
baseURL,
watchProvidersURL,
c.apiKey,
options,
)
watchProvider := WatchProviderList{}
if err := c.get(tmdbURL, &watchProvider); err != nil {
return nil, err
}
return &watchProvider, nil
}