-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie.go
165 lines (147 loc) · 4.55 KB
/
movie.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package tvdb
import (
"fmt"
"net/http"
"net/url"
)
type MoviesResponse struct {
Data MoviesData `json:"data"`
}
type MoviesData struct {
Artworks []Artworks `json:"artworks"`
Genres []Genres `json:"genres"`
ID int `json:"id"`
People People `json:"people"`
ReleaseDates []ReleaseDates `json:"release_dates"`
RemoteIds []RemoteIds `json:"remoteids"`
Runtime int `json:"runtime"`
Trailers []Trailers `json:"trailers"`
Translations []Translations `json:"translations"`
URL string `json:"url"`
}
type Artworks struct {
ArtworkType string `json:"artwork_type"`
Height int `json:"height"`
ID string `json:"id"`
IsPrimary bool `json:"is_primary"`
Tags string `json:"tags"`
ThumbURL string `json:"thumb_url"`
URL string `json:"url"`
Width int `json:"width"`
}
type Genres struct {
ID int `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
}
type Actors struct {
ID string `json:"id"`
ImdbID string `json:"imdb_id"`
IsFeatured bool `json:"is_featured"`
Name string `json:"name"`
PeopleFacebook string `json:"people_facebook"`
PeopleID string `json:"people_id"`
PeopleImage string `json:"people_image"`
PeopleInstagram string `json:"people_instagram"`
PeopleTwitter string `json:"people_twitter"`
Role string `json:"role"`
RoleImage string `json:"role_image"`
}
type Directors struct {
ID string `json:"id"`
ImdbID string `json:"imdb_id"`
IsFeatured bool `json:"is_featured"`
Name string `json:"name"`
PeopleFacebook string `json:"people_facebook"`
PeopleID string `json:"people_id"`
PeopleImage string `json:"people_image"`
PeopleInstagram string `json:"people_instagram"`
PeopleTwitter string `json:"people_twitter"`
Role string `json:"role"`
RoleImage string `json:"role_image"`
}
type Producers struct {
ID string `json:"id"`
ImdbID string `json:"imdb_id"`
IsFeatured bool `json:"is_featured"`
Name string `json:"name"`
PeopleFacebook string `json:"people_facebook"`
PeopleID string `json:"people_id"`
PeopleImage string `json:"people_image"`
PeopleInstagram string `json:"people_instagram"`
PeopleTwitter string `json:"people_twitter"`
Role string `json:"role"`
RoleImage string `json:"role_image"`
}
type Writers struct {
ID string `json:"id"`
ImdbID string `json:"imdb_id"`
IsFeatured bool `json:"is_featured"`
Name string `json:"name"`
PeopleFacebook string `json:"people_facebook"`
PeopleID string `json:"people_id"`
PeopleImage string `json:"people_image"`
PeopleInstagram string `json:"people_instagram"`
PeopleTwitter string `json:"people_twitter"`
Role string `json:"role"`
RoleImage string `json:"role_image"`
}
type People struct {
Actors []Actors `json:"actors"`
Directors []Directors `json:"directors"`
Producers []Producers `json:"producers"`
Writers []Writers `json:"writers"`
}
type ReleaseDates struct {
Country string `json:"country"`
Date string `json:"date"`
Type string `json:"type"`
}
type RemoteIds struct {
ID string `json:"id"`
SourceID int `json:"source_id"`
SourceName string `json:"source_name"`
SourceURL string `json:"source_url"`
URL string `json:"url"`
}
type Trailers struct {
Name string `json:"name"`
URL string `json:"url"`
}
type Translations struct {
IsPrimary bool `json:"is_primary"`
LanguageCode string `json:"language_code"`
Name string `json:"name"`
Overview string `json:"overview"`
Tagline string `json:"tagline"`
}
type MovieUpdatesResponse struct {
Movies []int `json:"movies"`
}
const Movies string = "/movies/%d"
const MovieUpdates string = "/movieupdates"
func (c *Client) Movie(movieId int) (data *MoviesResponse, err error) {
resp, err := c.doRequest(RequestArgs{
Method: http.MethodGet,
Path: fmt.Sprintf(Movies, movieId),
})
if err != nil {
return
}
data = new(MoviesResponse)
err = parseResponse(resp.Body, data)
return
}
func (c *Client) MovieUpdates(startDateEpochTime string) (data *MovieUpdatesResponse, err error) {
resp, err := c.doRequest(RequestArgs{
Method: http.MethodGet,
Params: url.Values{"since": {startDateEpochTime}},
Path: MovieUpdates,
})
if err != nil {
return
}
data = new(MovieUpdatesResponse)
err = parseResponse(resp.Body, data)
return
}