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