internal/structs.go

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