-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwatch.go
77 lines (71 loc) · 1.96 KB
/
watch.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
package jikan
// WatchEpisodes struct
type WatchEpisodes struct {
Data []struct {
Entry EntryTitle3 `json:"entry"`
Episodes []struct {
MalId int `json:"mal_id"`
Url string `json:"url"`
Title string `json:"title"`
Premium bool `json:"premium"`
} `json:"episodes"`
RegionLocked bool `json:"region_locked"`
} `json:"data"`
Pagination Pagination `json:"pagination"`
}
// GetWatchRecentEpisodes returns watch recent episodes
func GetWatchRecentEpisodes() (*WatchEpisodes, error) {
res := &WatchEpisodes{}
err := urlToStruct("/watch/episodes", res)
if err != nil {
return nil, err
}
return res, nil
}
// GetWatchPopularEpisodes returns watch popular episodes
func GetWatchPopularEpisodes() (*WatchEpisodes, error) {
res := &WatchEpisodes{}
err := urlToStruct("/watch/episodes/popular", res)
if err != nil {
return nil, err
}
return res, nil
}
// WatchPromos struct
type WatchPromos struct {
Data []struct {
Title string `json:"title"`
Entry EntryTitle3 `json:"entry"`
Trailer struct {
YoutubeId string `json:"youtube_id"`
Url string `json:"url"`
EmbedUrl string `json:"embed_url"`
Images struct {
ImageUrl string `json:"image_url"`
SmallImageUrl string `json:"small_image_url"`
MediumImageUrl string `json:"medium_image_url"`
LargeImageUrl string `json:"large_image_url"`
MaximumImageUrl string `json:"maximum_image_url"`
} `json:"images"`
} `json:"trailer"`
} `json:"data"`
Pagination Pagination `json:"pagination"`
}
// GetWatchRecentPromos returns watch recent promos
func GetWatchRecentPromos() (*WatchPromos, error) {
res := &WatchPromos{}
err := urlToStruct("/watch/promos", res)
if err != nil {
return nil, err
}
return res, nil
}
// GetWatchPopularPromos returns watch popular promos
func GetWatchPopularPromos() (*WatchPromos, error) {
res := &WatchPromos{}
err := urlToStruct("/watch/promos/popular", res)
if err != nil {
return nil, err
}
return res, nil
}