-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.go
105 lines (83 loc) · 2.1 KB
/
show.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
package trakt
import (
"encoding/json"
"time"
)
type Airs struct {
Day string
Time string
Timezone string
}
type Show struct {
commonElements `json:",inline"`
Year int64 `json:"-"`
FirstAired time.Time `json:"first_aired"`
Airs *Airs `json:"airs"`
Certification string `json:"certification"`
Country string `json:"country"`
TrailerURL string `json:"trailer"`
HomepageURL string `json:"homepage"`
Status Status `json:"status"`
Genres []string `json:"genre"`
AiredEpisodes int64 `json:"aired_episodes"`
Language string `json:"language"`
}
func (s *Show) UnmarshalJSON(bytes []byte) error {
type B Show
type A struct {
B
Year interface{} `json:"year"`
}
var a = new(A)
err := json.Unmarshal(bytes, a)
if err != nil {
return nil
}
a.B.Year, err = parseYear(a.Year)
if err != nil {
return err
}
*s = Show(a.B)
return nil
}
type ShowIterator struct{ Iterator }
func (s *ShowIterator) Show() (*Show, error) {
rcv := &Show{}
return rcv, s.Scan(rcv)
}
type TrendingShow struct {
Show `json:"show"`
Watchers int64 `json:"watchers"`
}
type TrendingShowIterator struct{ Iterator }
func (t *TrendingShowIterator) Trending() (*TrendingShow, error) {
rcv := &TrendingShow{}
return rcv, t.Scan(rcv)
}
type RecentlyUpdatedShow struct {
Show `json:"show"`
UpdatedAt time.Time `json:"updated_at"`
}
type RecentlyUpdatedShowIterator struct{ Iterator }
func (r *RecentlyUpdatedShowIterator) Show() (*RecentlyUpdatedShow, error) {
rcv := &RecentlyUpdatedShow{}
return rcv, r.Scan(rcv)
}
type ShowWithStatistics struct {
statistics
Show `json:"show"`
}
type ShowWithStatisticsIterator struct{ Iterator }
func (s *ShowWithStatisticsIterator) Show() (*ShowWithStatistics, error) {
rcv := &ShowWithStatistics{}
return rcv, s.Scan(rcv)
}
type AnticipatedShow struct {
Show `json:"show"`
ListCount int64 `json:"list_count"`
}
type AnticipatedShowIterator struct{ Iterator }
func (a *AnticipatedShowIterator) Show() (*AnticipatedShow, error) {
rcv := &AnticipatedShow{}
return rcv, a.Scan(rcv)
}