215 lines
6.9 KiB
Go
215 lines
6.9 KiB
Go
package anilist
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type User struct {
|
|
ID int `json:"id,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
}
|
|
|
|
type Media struct {
|
|
ID int `json:"id"`
|
|
Title MediaTitle `json:"title"`
|
|
Type MediaType `json:"type"`
|
|
Format MediaFormat `json:"format"`
|
|
Status MediaStatus `json:"status"`
|
|
Description string `json:"description"`
|
|
StartDate FuzzyDate `json:"startDate"`
|
|
EndDate FuzzyDate `json:"endDate"`
|
|
Season MediaSeason `json:"season"`
|
|
SeasonYear int `json:"seasonYear"`
|
|
SeasonInt int `json:"seasonInt"`
|
|
Episodes int `json:"episodes"`
|
|
Duration Minutes `json:"duration"`
|
|
Chapters int `json:"chapters"`
|
|
Volumes int `json:"volumes"`
|
|
CountryOfOrigin string `json:"countryOfOrigin"`
|
|
Licensed bool `json:"isLicensed"`
|
|
Source MediaSource `json:"source"`
|
|
Hashtag string `json:"hashtag"`
|
|
Trailer MediaTrailer `json:"trailer"`
|
|
UpdatedAt UnixTime `json:"updatedAt"`
|
|
CoverImage MediaCoverImage `json:"coverImage"`
|
|
BannerImage string `json:"bannerImage"`
|
|
Genres []string `json:"genres"`
|
|
Synonyms []string `json:"synonyms"`
|
|
AverageScore int `json:"averageScore"`
|
|
MeanScore int `json:"meanScore"`
|
|
Popularity int `json:"popularity"`
|
|
Locked bool `json:"isLocked"`
|
|
Trending int `json:"trending"`
|
|
Favourites int `json:"favourites"`
|
|
Tags []MediaTag `json:"tags"`
|
|
NextAiringEpisode AiringSchedule `json:"nextAiringEpisode"`
|
|
//TODO
|
|
}
|
|
|
|
type MediaTitle struct {
|
|
Romaji string `json:"romaji"`
|
|
English string `json:"english"`
|
|
Native string `json:"native"`
|
|
UserPreferred string `json:"userPreferred"`
|
|
}
|
|
|
|
type MediaType string
|
|
|
|
const (
|
|
MediaTypeAnime MediaType = "ANIME"
|
|
MediaTypeManga MediaType = "MANGA"
|
|
)
|
|
|
|
type MediaFormat string
|
|
|
|
const (
|
|
MediaFormatTV MediaFormat = "TV"
|
|
MediaFormatTVShort MediaFormat = "TV_SHORT"
|
|
MediaFormatMovie MediaFormat = "MOVIE"
|
|
MediaFormatSpecial MediaFormat = "SPECIAL"
|
|
MediaFormatOVA MediaFormat = "OVA"
|
|
MediaFormatONA MediaFormat = "ONA"
|
|
MediaFormatMusic MediaFormat = "MUSIC"
|
|
MediaFormatManga MediaFormat = "MANGA"
|
|
MediaFormatNovel MediaFormat = "NOVEL"
|
|
MediaFormatOneShot MediaFormat = "ONE_SHOT"
|
|
)
|
|
|
|
type MediaStatus string
|
|
|
|
const (
|
|
MediaStatusFinished MediaStatus = "FINISHED"
|
|
MediaStatusReleasing MediaStatus = "RELEASING"
|
|
MediaStatusNotYetReleased MediaStatus = "NOT_YET_RELEASED"
|
|
MediaStatusCancelled MediaStatus = "CANCELLED"
|
|
)
|
|
|
|
type MediaSeason string
|
|
|
|
const (
|
|
MediaSeasonWinter MediaSeason = "WINTER"
|
|
MediaSeasonSpring MediaSeason = "SPRING"
|
|
MediaSeasonSummer MediaSeason = "SUMMER"
|
|
MediaSeasonFall MediaSeason = "FALL"
|
|
)
|
|
|
|
type MediaSource string
|
|
|
|
const (
|
|
MediaSourceOriginal MediaSource = "ORIGINAL"
|
|
MediaSourceManga MediaSource = "MANGA"
|
|
MediaSourceLightNovel MediaSource = "LIGHT_NOVEL"
|
|
MediaSourceVisualNovel MediaSource = "VISUAL_NOVEL"
|
|
MediaSourceVideoGame MediaSource = "VIDEO_GAME"
|
|
MediaSourceOther MediaSource = "OTHER"
|
|
MediaSourceNovel MediaSource = "NOVEL"
|
|
MediaSourceDoujinshi MediaSource = "DOUJINSHI"
|
|
MediaSourceAnime MediaSource = "ANIME"
|
|
MediaSourceWebNovel MediaSource = "WEB_NOVEL"
|
|
MediaSourceLiveAction MediaSource = "LIVE_ACTION"
|
|
MediaSourceGame MediaSource = "GAME"
|
|
MediaSourceComic MediaSource = "COMIC"
|
|
MediaSourceMultimediaProject MediaSource = "MULTIMEDIA_PROJECT"
|
|
MediaSourcePictureBook MediaSource = "PICTURE_BOOK"
|
|
)
|
|
|
|
type MediaTrailer struct {
|
|
ID string `json:"id"`
|
|
Site string `json:"site"`
|
|
Thumbnail string `json:"thumbnail"`
|
|
}
|
|
|
|
type MediaCoverImage struct {
|
|
ExtraLarge string `json:"extraLarge"`
|
|
Large string `json:"large"`
|
|
Medium string `json:"medium"`
|
|
Color string `json:"color"`
|
|
}
|
|
|
|
type MediaTag struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Category string `json:"category"`
|
|
Rank int `json:"rank"`
|
|
GeneralSpoiler bool `json:"isGeneralSpoiler"`
|
|
MediaSpoiler bool `json:"isMediaSpoiler"`
|
|
Adult bool `json:"isAdult"`
|
|
UserID int `json:"userId"`
|
|
}
|
|
|
|
type FuzzyDate struct {
|
|
Year int `json:"year"`
|
|
Month int `json:"month"`
|
|
Day int `json:"day"`
|
|
}
|
|
|
|
func (d FuzzyDate) Time() time.Time {
|
|
return time.Date(d.Year, time.Month(d.Month), d.Day, 0, 0, 0, 0, time.UTC)
|
|
}
|
|
|
|
type FuzzyDateInt int // YYYYMMDD
|
|
|
|
func (d FuzzyDateInt) Time() time.Time {
|
|
year, month, day := int(d/10000), int(d/100%100), int(d%100)
|
|
return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
|
|
}
|
|
|
|
type UnixTime int64
|
|
|
|
func (t UnixTime) Time() time.Time {
|
|
return time.Unix(int64(t), 0)
|
|
}
|
|
|
|
type Minutes int
|
|
|
|
func (d Minutes) Duration() time.Duration {
|
|
return time.Duration(d) * time.Minute
|
|
}
|
|
|
|
type Seconds int
|
|
|
|
func (d Seconds) Duration() time.Duration {
|
|
return time.Duration(d) * time.Second
|
|
}
|
|
|
|
type MediaList struct {
|
|
ID int `json:"id"`
|
|
UserID int `json:"userId"`
|
|
MediaID int `json:"mediaId"`
|
|
Status MediaListStatus `json:"status"`
|
|
Score float64 `json:"score"`
|
|
Progress int `json:"progress"`
|
|
ProgressVolumes int `json:"progressVolumes"`
|
|
Repeat int `json:"repeat"`
|
|
Priority int `json:"priority"`
|
|
Private bool `json:"private"`
|
|
Notes string `json:"notes"`
|
|
HiddenFromStatusLists bool `json:"hiddenFromStatusLists"`
|
|
StartedAt FuzzyDate `json:"startedAt"`
|
|
CompletedAt FuzzyDate `json:"completedAt"`
|
|
UpdatedAt UnixTime `json:"updatedAt"`
|
|
CreatedAt UnixTime `json:"createdAt"`
|
|
Media *Media `json:"media"`
|
|
User *User `json:"user"`
|
|
}
|
|
|
|
type MediaListStatus string
|
|
|
|
const (
|
|
MediaListStatusCurrent MediaListStatus = "CURRENT"
|
|
MediaListStatusPlanning MediaListStatus = "PLANNING"
|
|
MediaListStatusCompleted MediaListStatus = "COMPLETED"
|
|
MediaListStatusDropped MediaListStatus = "DROPPED"
|
|
MediaListStatusPaused MediaListStatus = "PAUSED"
|
|
MediaListStatusRepeating MediaListStatus = "REPEATING"
|
|
)
|
|
|
|
type AiringSchedule struct {
|
|
ID int `json:"id"`
|
|
MediaID int `json:"mediaId"`
|
|
AiringAt UnixTime `json:"airingAt"`
|
|
TimeUntilAiring Seconds `json:"timeUntilAiring"`
|
|
Episode int `json:"episode"`
|
|
}
|