internal/structs.go
118 lines · 3063 bytes
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 AllanimeId string // Can be populated as necessary
18 FillerEpisodes []int
19}
20
21type Skip struct {
22 Start int `json:"start"`
23 End int `json:"end"`
24}
25
26type SkipTimes struct {
27 Op Skip `json:"op"`
28 Ed Skip `json:"ed"`
29}
30
31type Episode struct {
32 Title AnimeTitle `json:"title"`
33 Number int `json:"number"`
34 SkipTimes SkipTimes `json:"skip_times"`
35 Player playingVideo `json:"player"`
36 Resume bool `json:"resume"`
37 Started bool `json:"started"`
38 Duration int `json:"duration"`
39 Links []string `json:"links"`
40 NextEpisode NextEpisode `json:"next_episode"`
41 IsFiller bool `json:"filler"`
42 IsRecap bool `json:"recap"`
43 Aired string `json:"aired"`
44 Synopsis string `json:"synopsis"`
45 ContinueLast bool
46 LastWasSkipped bool // used in filler check
47 IsCompleted bool
48}
49
50type NextEpisode struct {
51 Number int
52 Links []string
53}
54
55type playingVideo struct {
56 Url string
57 Speed float64 `json:"speed"`
58 PlaybackTime int `json:"playback_time"`
59 SocketPath string
60}
61
62type User struct {
63 Token string
64 Username string
65 Id int
66 AnimeList AnimeList
67}
68
69// AniListAnime is the struct for the API response
70type AniListAnime struct {
71 ID int `json:"id"`
72 Title struct {
73 Romaji string `json:"romaji"`
74 English string `json:"english"`
75 Native string `json:"native"`
76 } `json:"title"`
77 CoverImage struct {
78 Large string `json:"large"`
79 } `json:"coverImage"`
80}
81
82// Page represents the page in AniList response
83type Page struct {
84 Media []AniListAnime `json:"media"`
85}
86
87// ResponseData represents the full response structure
88type ResponseData struct {
89 Page Page `json:"Page"`
90}
91
92type Media struct {
93 Duration int `json:"duration"`
94 Episodes int `json:"episodes"`
95 ID int `json:"id"`
96 Title AnimeTitle `json:"title"`
97}
98
99type Entry struct {
100 Media Media `json:"media"`
101 Progress int `json:"progress"`
102 Score float64 `json:"score"`
103 Status string `json:"status"`
104 CoverImage string `json:"coverImage"`
105}
106
107type AnimeList struct {
108 Watching []Entry `json:"watching"`
109 Completed []Entry `json:"completed"`
110 Paused []Entry `json:"paused"`
111 Dropped []Entry `json:"dropped"`
112 Planning []Entry `json:"planning"`
113}
114
115type RofiSelectPreview struct {
116 Title string `json:"title"`
117 CoverImage string `json:"coverImage"`
118}