internal/structs.go

150 lines · 3848 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	ProviderId     string // Can be populated as necessary
 21	ProviderName   string // newly added for history migration
 22	FillerEpisodes []int
 23	IsAiring       bool
 24}
 25
 26type FuzzyDate struct {
 27	Year  int `json:"year"`
 28	Month int `json:"month"`
 29	Day   int `json:"day"`
 30}
 31
 32type Skip struct {
 33	Start int `json:"start"`
 34	End   int `json:"end"`
 35}
 36
 37type SkipTimes struct {
 38	Op Skip `json:"op"`
 39	Ed Skip `json:"ed"`
 40}
 41
 42type Episode struct {
 43	Title          AnimeTitle   `json:"title"`
 44	Number         int          `json:"number"`
 45	SkipTimes      SkipTimes    `json:"skip_times"`
 46	Player         playingVideo `json:"player"`
 47	Resume         bool         `json:"resume"`
 48	Started        bool         `json:"started"`
 49	Duration       int          `json:"duration"`
 50	Links          []string     `json:"links"`
 51	NextEpisode    NextEpisode  `json:"next_episode"`
 52	IsFiller       bool         `json:"filler"`
 53	IsRecap        bool         `json:"recap"`
 54	Aired          string       `json:"aired"`
 55	Synopsis       string       `json:"synopsis"`
 56	ContinueLast   bool
 57	LastWasSkipped bool // used in filler check
 58	IsCompleted    bool
 59}
 60
 61type NextEpisode struct {
 62	Number int
 63	Links  []string
 64}
 65
 66type playingVideo struct {
 67	Url          string
 68	Speed        float64 `json:"speed"`
 69	PlaybackTime int     `json:"playback_time"`
 70	SocketPath   string
 71}
 72
 73type User struct {
 74	Token     string
 75	Username  string
 76	Id        int
 77	AnimeList AnimeList
 78	ListSync  *AnimeListSync
 79}
 80
 81// AniListAnime is the struct for the API response
 82type AniListAnime struct {
 83	ID    int `json:"id"`
 84	Title struct {
 85		Romaji  string `json:"romaji"`
 86		English string `json:"english"`
 87		Native  string `json:"native"`
 88	} `json:"title"`
 89	CoverImage struct {
 90		Large string `json:"large"`
 91	} `json:"coverImage"`
 92}
 93
 94// Page represents the page in AniList response
 95type Page struct {
 96	Media []AniListAnime `json:"media"`
 97}
 98
 99// ResponseData represents the full response structure
100type ResponseData struct {
101	Page Page `json:"Page"`
102}
103
104type Media struct {
105	Duration int        `json:"duration"`
106	Episodes int        `json:"episodes"`
107	ID       int        `json:"id"`
108	Title    AnimeTitle `json:"title"`
109	Status   string     `json:"status"`
110}
111
112type Entry struct {
113	Media       Media     `json:"media"`
114	Progress    int       `json:"progress"`
115	Repeat      int       `json:"repeat"`
116	Score       float64   `json:"score"`
117	Status      string    `json:"status"`
118	StartedAt   FuzzyDate `json:"startedAt"`
119	CompletedAt FuzzyDate `json:"completedAt"`
120	CoverImage  string    `json:"coverImage"`
121}
122
123type AnimeList struct {
124	Watching   []Entry `json:"watching"`
125	Completed  []Entry `json:"completed"`
126	Paused     []Entry `json:"paused"`
127	Dropped    []Entry `json:"dropped"`
128	Planning   []Entry `json:"planning"`
129	Rewatching []Entry `json:"rewatching"`
130}
131
132type RofiSelectPreview struct {
133	Title      string `json:"title"`
134	CoverImage string `json:"coverImage"`
135}
136
137type SelectionOptionImage struct {
138	Key        string
139	Label      string
140	CoverImage string
141}
142
143// SelectionOption holds the label and the internal key
144type SelectionOption struct {
145	Title     string
146	Label     string
147	Key       string
148	Thumbnail string
149	ExtraData interface{}
150}