internal/structs.go
169 lines · 4212 bytes · executable
1package internal
2
3import "time"
4
5type AnimeTitle struct {
6 Romaji string `json:"title_romanji"`
7 English string `json:"title"`
8 Japanese string `json:"title_japanese"`
9}
10
11type Anime struct {
12 Title AnimeTitle `json:"title"`
13 Ep Episode `json:"ep"`
14 CoverImage string `json:"url"` // Assuming this field corresponds to the cover image URL
15 TotalEpisodes int `json:"total_episodes"` // If provided by the API
16 MalId int `json:"mal_id"`
17 AnilistId int `json:"anilist_id"` // Assuming you have an Anilist ID in your struct
18 Rewatching bool
19 Repeat int
20 StartedAt FuzzyDate
21 CompletedAt FuzzyDate
22 ProviderId string // Can be populated as necessary
23 ProviderName string // newly added for history migration
24 FillerEpisodes []int
25 IsAiring bool
26 SkipRemoteSync bool `json:"-"`
27}
28
29type FuzzyDate struct {
30 Year int `json:"year"`
31 Month int `json:"month"`
32 Day int `json:"day"`
33}
34
35type Skip struct {
36 Start int `json:"start"`
37 End int `json:"end"`
38}
39
40type SkipTimes struct {
41 Op Skip `json:"op"`
42 Ed Skip `json:"ed"`
43}
44
45type Episode struct {
46 Title AnimeTitle `json:"title"`
47 Number int `json:"number"`
48 SkipTimes SkipTimes `json:"skip_times"`
49 Player playingVideo `json:"player"`
50 Resume bool `json:"resume"`
51 Started bool `json:"started"`
52 Duration int `json:"duration"`
53 Links []string `json:"links"`
54 NextEpisode NextEpisode `json:"next_episode"`
55 IsFiller bool `json:"filler"`
56 IsRecap bool `json:"recap"`
57 Aired string `json:"aired"`
58 Synopsis string `json:"synopsis"`
59 ContinueLast bool
60 LastWasSkipped bool // used in filler check
61 IsCompleted bool
62}
63
64type NextEpisode struct {
65 Number int
66 Links []string
67 ProviderName string
68 ProviderId string
69 Mode string
70}
71
72type playingVideo struct {
73 Url string
74 Speed float64 `json:"speed"`
75 PlaybackTime int `json:"playback_time"`
76 SocketPath string
77}
78
79type User struct {
80 Token string
81 Username string
82 Id int
83 AnimeList AnimeList
84 ListSync *AnimeListSync
85}
86
87var globalUser *User
88
89func SetGlobalUser(user *User) {
90 globalUser = user
91}
92
93func GetGlobalUser() *User {
94 return globalUser
95}
96
97// AniListAnime is the struct for the API response
98type AniListAnime struct {
99 ID int `json:"id"`
100 Title struct {
101 Romaji string `json:"romaji"`
102 English string `json:"english"`
103 Native string `json:"native"`
104 } `json:"title"`
105 CoverImage struct {
106 Large string `json:"large"`
107 } `json:"coverImage"`
108}
109
110// Page represents the page in AniList response
111type Page struct {
112 Media []AniListAnime `json:"media"`
113}
114
115// ResponseData represents the full response structure
116type ResponseData struct {
117 Page Page `json:"Page"`
118}
119
120type Media struct {
121 Duration int `json:"duration"`
122 Episodes int `json:"episodes"`
123 ID int `json:"id"`
124 MalID int `json:"mal_id"`
125 Title AnimeTitle `json:"title"`
126 Status string `json:"status"`
127}
128
129type Entry struct {
130 ListID int `json:"id"`
131 Media Media `json:"media"`
132 Progress int `json:"progress"`
133 Repeat int `json:"repeat"`
134 Score float64 `json:"score"`
135 Status string `json:"status"`
136 StartedAt FuzzyDate `json:"startedAt"`
137 CompletedAt FuzzyDate `json:"completedAt"`
138 CoverImage string `json:"coverImage"`
139 UpdatedAt time.Time `json:"updatedAt"`
140}
141
142type AnimeList struct {
143 Watching []Entry `json:"watching"`
144 Completed []Entry `json:"completed"`
145 Paused []Entry `json:"paused"`
146 Dropped []Entry `json:"dropped"`
147 Planning []Entry `json:"planning"`
148 Rewatching []Entry `json:"rewatching"`
149}
150
151type RofiSelectPreview struct {
152 Title string `json:"title"`
153 CoverImage string `json:"coverImage"`
154}
155
156type SelectionOptionImage struct {
157 Key string
158 Label string
159 CoverImage string
160}
161
162// SelectionOption holds the label and the internal key
163type SelectionOption struct {
164 Title string
165 Label string
166 Key string
167 Thumbnail string
168 ExtraData interface{}
169}