internal/structs.go

148 lines · 3765 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	ListSync  *AnimeListSync
 78}
 79
 80// AniListAnime is the struct for the API response
 81type AniListAnime struct {
 82	ID    int `json:"id"`
 83	Title struct {
 84		Romaji  string `json:"romaji"`
 85		English string `json:"english"`
 86		Native  string `json:"native"`
 87	} `json:"title"`
 88	CoverImage struct {
 89		Large string `json:"large"`
 90	} `json:"coverImage"`
 91}
 92
 93// Page represents the page in AniList response
 94type Page struct {
 95	Media []AniListAnime `json:"media"`
 96}
 97
 98// ResponseData represents the full response structure
 99type ResponseData struct {
100	Page Page `json:"Page"`
101}
102
103type Media struct {
104	Duration int        `json:"duration"`
105	Episodes int        `json:"episodes"`
106	ID       int        `json:"id"`
107	Title    AnimeTitle `json:"title"`
108	Status   string     `json:"status"`
109}
110
111type Entry struct {
112	Media       Media     `json:"media"`
113	Progress    int       `json:"progress"`
114	Repeat      int       `json:"repeat"`
115	Score       float64   `json:"score"`
116	Status      string    `json:"status"`
117	StartedAt   FuzzyDate `json:"startedAt"`
118	CompletedAt FuzzyDate `json:"completedAt"`
119	CoverImage  string    `json:"coverImage"`
120}
121
122type AnimeList struct {
123	Watching   []Entry `json:"watching"`
124	Completed  []Entry `json:"completed"`
125	Paused     []Entry `json:"paused"`
126	Dropped    []Entry `json:"dropped"`
127	Planning   []Entry `json:"planning"`
128	Rewatching []Entry `json:"rewatching"`
129}
130
131type RofiSelectPreview struct {
132	Title      string `json:"title"`
133	CoverImage string `json:"coverImage"`
134}
135
136type SelectionOptionImage struct {
137	Key        string
138	Label      string
139	CoverImage string
140}
141
142// SelectionOption holds the label and the internal key
143type SelectionOption struct {
144	Title     string
145	Label     string
146	Key       string
147	Thumbnail string
148}