internal/structs.go

166 lines · 4137 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}
 68
 69type playingVideo struct {
 70	Url          string
 71	Speed        float64 `json:"speed"`
 72	PlaybackTime int     `json:"playback_time"`
 73	SocketPath   string
 74}
 75
 76type User struct {
 77	Token     string
 78	Username  string
 79	Id        int
 80	AnimeList AnimeList
 81	ListSync  *AnimeListSync
 82}
 83
 84var globalUser *User
 85
 86func SetGlobalUser(user *User) {
 87	globalUser = user
 88}
 89
 90func GetGlobalUser() *User {
 91	return globalUser
 92}
 93
 94// AniListAnime is the struct for the API response
 95type AniListAnime struct {
 96	ID    int `json:"id"`
 97	Title struct {
 98		Romaji  string `json:"romaji"`
 99		English string `json:"english"`
100		Native  string `json:"native"`
101	} `json:"title"`
102	CoverImage struct {
103		Large string `json:"large"`
104	} `json:"coverImage"`
105}
106
107// Page represents the page in AniList response
108type Page struct {
109	Media []AniListAnime `json:"media"`
110}
111
112// ResponseData represents the full response structure
113type ResponseData struct {
114	Page Page `json:"Page"`
115}
116
117type Media struct {
118	Duration int        `json:"duration"`
119	Episodes int        `json:"episodes"`
120	ID       int        `json:"id"`
121	MalID    int        `json:"mal_id"`
122	Title    AnimeTitle `json:"title"`
123	Status   string     `json:"status"`
124}
125
126type Entry struct {
127	ListID      int       `json:"id"`
128	Media       Media     `json:"media"`
129	Progress    int       `json:"progress"`
130	Repeat      int       `json:"repeat"`
131	Score       float64   `json:"score"`
132	Status      string    `json:"status"`
133	StartedAt   FuzzyDate `json:"startedAt"`
134	CompletedAt FuzzyDate `json:"completedAt"`
135	CoverImage  string    `json:"coverImage"`
136	UpdatedAt   time.Time `json:"updatedAt"`
137}
138
139type AnimeList struct {
140	Watching   []Entry `json:"watching"`
141	Completed  []Entry `json:"completed"`
142	Paused     []Entry `json:"paused"`
143	Dropped    []Entry `json:"dropped"`
144	Planning   []Entry `json:"planning"`
145	Rewatching []Entry `json:"rewatching"`
146}
147
148type RofiSelectPreview struct {
149	Title      string `json:"title"`
150	CoverImage string `json:"coverImage"`
151}
152
153type SelectionOptionImage struct {
154	Key        string
155	Label      string
156	CoverImage string
157}
158
159// SelectionOption holds the label and the internal key
160type SelectionOption struct {
161	Title     string
162	Label     string
163	Key       string
164	Thumbnail string
165	ExtraData interface{}
166}