internal/structs.go

98 lines · 2479 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}
50
51type User struct {
52	Token 		string
53	Username 	string
54	Id 			int
55	AnimeList 	AnimeList
56}
57
58// AniListAnime is the struct for the API response
59type AniListAnime struct {
60	ID    int `json:"id"`
61	Title struct {
62		Romaji  string `json:"romaji"`
63		English string `json:"english"`
64		Native  string `json:"native"`
65	} `json:"title"`
66}
67
68// Page represents the page in AniList response
69type Page struct {
70	Media []AniListAnime `json:"media"`
71}
72
73// ResponseData represents the full response structure
74type ResponseData struct {
75	Page Page `json:"Page"`
76}
77
78type Media struct {
79	Duration int    `json:"duration"`
80	Episodes int    `json:"episodes"`
81	ID       int    `json:"id"`
82	Title    AnimeTitle  `json:"title"`
83}
84
85type Entry struct {
86	Media    Media `json:"media"`
87	Progress int   `json:"progress"`
88	Score    float64 `json:"score"`
89	Status   string `json:"status"`
90}
91
92type AnimeList struct {
93	Watching	[]Entry `json:"watching"`
94	Completed	[]Entry `json:"completed"`
95	Paused		[]Entry `json:"paused"`
96	Dropped 	[]Entry `json:"dropped"`
97	Planning 	[]Entry `json:"planning"`
98}