anilist/queries.go
2022-02-03 17:23:29 +01:00

258 lines
10 KiB
Go

package anilist
import "time"
type MediaListQuery struct {
ID int
UserID int
UserName string
Type MediaType
Status MediaListStatus
MediaID int
Following bool
Notes string
UserIdIn []int
StatusIn []MediaListStatus
StatusNotIn []MediaListStatus
StatusNot MediaListStatus
MediaIdIn []int
MediaIdNotIn []int
Sort []MediaListSort
}
func (q *MediaListQuery) toMap() map[string]interface{} {
m := map[string]interface{}{}
addValue2InterfaceMap(m, "id", q.ID)
addValue2InterfaceMap(m, "userId", q.UserID)
addValue2InterfaceMap(m, "userName", q.UserName)
addValue2InterfaceMap(m, "type", q.Type)
addValue2InterfaceMap(m, "status", q.Status)
addValue2InterfaceMap(m, "mediaId", q.MediaID)
addValue2InterfaceMap(m, "isFollowing", q.Following)
addValue2InterfaceMap(m, "notes", q.Notes)
addSlice2InterfaceMap(m, "userId_in", q.UserIdIn)
addSlice2InterfaceMap(m, "status_in", q.StatusIn)
addSlice2InterfaceMap(m, "status_not_in", q.StatusNotIn)
addValue2InterfaceMap(m, "status_not", q.StatusNot)
addSlice2InterfaceMap(m, "mediaId_in", q.MediaIdIn)
addSlice2InterfaceMap(m, "mediaId_not_in", q.MediaIdNotIn)
addSlice2InterfaceMap(m, "sort", q.Sort)
return m
}
type MediaListSort string
const (
MediaListSortMediaId MediaListSort = "MEDIA_ID"
MediaListSortMediaIdDesc MediaListSort = "MEDIA_ID_DESC"
MediaListSortScore MediaListSort = "SCORE"
MediaListSortScoreDesc MediaListSort = "SCORE_DESC"
MediaListSortStatus MediaListSort = "STATUS"
MediaListSortStatusDesc MediaListSort = "STATUS_DESC"
MediaListSortProgress MediaListSort = "PROGRESS"
MediaListSortProgressDesc MediaListSort = "PROGRESS_DESC"
MediaListSortProgressVolumes MediaListSort = "PROGRESS_VOLUMES"
MediaListSortProgressVolumesDesc MediaListSort = "PROGRESS_VOLUMES_DESC"
MediaListSortRepeat MediaListSort = "REPEAT"
MediaListSortRepeatDesc MediaListSort = "REPEAT_DESC"
MediaListSortPriority MediaListSort = "PRIORITY"
MediaListSortPriorityDesc MediaListSort = "PRIORITY_DESC"
MediaListSortStartedOn MediaListSort = "STARTED_ON"
MediaListSortStartedOnDesc MediaListSort = "STARTED_ON_DESC"
MediaListSortFinishedOn MediaListSort = "FINISHED_ON"
MediaListSortFinishedOnDesc MediaListSort = "FINISHED_ON_DESC"
MediaListSortAddedTime MediaListSort = "ADDED_TIME"
MediaListSortAddedTimeDesc MediaListSort = "ADDED_TIME_DESC"
MediaListSortUpdatedTime MediaListSort = "UPDATED_TIME"
MediaListSortUpdatedTimeDesc MediaListSort = "UPDATED_TIME_DESC"
MediaListSortMediaTitleRomaji MediaListSort = "MEDIA_TITLE_ROMAJI"
MediaListSortMediaTitleRomajiDesc MediaListSort = "MEDIA_TITLE_ROMAJI_DESC"
MediaListSortMediaTitleEnglish MediaListSort = "MEDIA_TITLE_ENGLISH"
MediaListSortMediaTitleEnglishDesc MediaListSort = "MEDIA_TITLE_ENGLISH_DESC"
MediaListSortMediaTitleNative MediaListSort = "MEDIA_TITLE_NATIVE"
MediaListSortMediaTitleNativeDesc MediaListSort = "MEDIA_TITLE_NATIVE_DESC"
MediaListSortMediaPopularity MediaListSort = "MEDIA_POPULARITY"
MediaListSortMediaPopularityDesc MediaListSort = "MEDIA_POPULARITY_DESC"
)
type AiringScheduleQuery struct {
ID int
MediaID int
Episode int
AiringAt time.Time
NotYetAired bool
IdIn []int
IdNotIn []int
MediaIdIn []int
MediaIdNotIn []int
EpisodeIn []int
EpisodeNotIn []int
EpisodeGreater int
EpisodeLesser int
AiringAtGreater time.Time
AiringAtLesser time.Time
Sort []AiringSort
}
func (q *AiringScheduleQuery) toMap() map[string]interface{} {
m := map[string]interface{}{}
addValue2InterfaceMap(m, "id", q.ID)
addValue2InterfaceMap(m, "mediaId", q.MediaID)
addValue2InterfaceMap(m, "episode", q.Episode)
addValue2InterfaceMap(m, "airingAt", q.AiringAt)
addValue2InterfaceMap(m, "notYetAired", q.NotYetAired)
addSlice2InterfaceMap(m, "id_in", q.IdIn)
addSlice2InterfaceMap(m, "id_not_in", q.IdNotIn)
addSlice2InterfaceMap(m, "mediaId_in", q.MediaIdIn)
addSlice2InterfaceMap(m, "mediaId_not_in", q.MediaIdNotIn)
addSlice2InterfaceMap(m, "episode_in", q.EpisodeIn)
addSlice2InterfaceMap(m, "episode_not_in", q.EpisodeNotIn)
addValue2InterfaceMap(m, "episode_greater", q.EpisodeGreater)
addValue2InterfaceMap(m, "episode_lesser", q.EpisodeLesser)
addValue2InterfaceMap(m, "airingAt_greater", q.AiringAtGreater)
addValue2InterfaceMap(m, "airingAt_lesser", q.AiringAtLesser)
addSlice2InterfaceMap(m, "sort", q.Sort)
return m
}
type AiringSort string
const (
AiringSortId AiringSort = "ID"
AiringSortIdDesc AiringSort = "ID_DESC"
AiringSortMediaId AiringSort = "MEDIA_ID"
AiringSortMediaIdDesc AiringSort = "MEDIA_ID_DESC"
AiringSortTime AiringSort = "TIME"
AiringSortTimeDesc AiringSort = "TIME_DESC"
AiringSortEpisode AiringSort = "EPISODE"
AiringSortEpisodeDesc AiringSort = "EPISODE_DESC"
)
type MediaQuery struct {
ID int
StartDate time.Time
EndDate time.Time
Season MediaSeason
SeasonYear int
Type MediaType
Format MediaFormat
Status MediaStatus
Episodes int
Duration time.Duration
Chapters int
Volumes int
IsAdult bool
Genre string
Tag string
Source MediaSource
Search string
IdIn []int
IdNotIn []int
StartDateGreater time.Time
StartDateLesser time.Time
EndDateGreater time.Time
EndDateLesser time.Time
FormatIn []MediaFormat
FormatNotIn []MediaFormat
StatusIn []MediaStatus
StatusNotIn []MediaStatus
EpisodesGreater int
EpisodesLesser int
DurationGreater time.Duration
DurationLesser time.Duration
VolumesGreater int
VolumesLesser int
GenreIn []string
GenreNotIn []string
TagIn []string
TagNotIn []string
SourceIn []MediaSource
Sort []MediaSort
}
func (q *MediaQuery) toMap() map[string]interface{} {
m := map[string]interface{}{}
addValue2InterfaceMap(m, "id", q.ID)
addValue2InterfaceMap(m, "startDate", q.StartDate)
addValue2InterfaceMap(m, "endDate", q.EndDate)
addValue2InterfaceMap(m, "season", q.Season)
addValue2InterfaceMap(m, "seasonYear", q.SeasonYear)
addValue2InterfaceMap(m, "type", q.Type)
addValue2InterfaceMap(m, "format", q.Format)
addValue2InterfaceMap(m, "status", q.Status)
addValue2InterfaceMap(m, "episodes", q.Episodes)
addValue2InterfaceMap(m, "duration", q.Duration.Minutes())
addValue2InterfaceMap(m, "chapters", q.Chapters)
addValue2InterfaceMap(m, "volumes", q.Volumes)
addValue2InterfaceMap(m, "isAdult", q.IsAdult)
addValue2InterfaceMap(m, "genre", q.Genre)
addValue2InterfaceMap(m, "tag", q.Tag)
addValue2InterfaceMap(m, "source", q.Source)
addValue2InterfaceMap(m, "search", q.Search)
addSlice2InterfaceMap(m, "id_in", q.IdIn)
addSlice2InterfaceMap(m, "id_not_in", q.IdNotIn)
addValue2InterfaceMap(m, "startDateGreater", q.StartDateGreater)
addValue2InterfaceMap(m, "startDateLesser", q.StartDateLesser)
addValue2InterfaceMap(m, "endDateGreater", q.EndDateGreater)
addValue2InterfaceMap(m, "endDateLesser", q.EndDateLesser)
addSlice2InterfaceMap(m, "format_in", q.FormatIn)
addSlice2InterfaceMap(m, "format_not_in", q.FormatNotIn)
addSlice2InterfaceMap(m, "status_in", q.StatusIn)
addSlice2InterfaceMap(m, "status_not_in", q.StatusNotIn)
addValue2InterfaceMap(m, "episodesGreater", q.EpisodesGreater)
addValue2InterfaceMap(m, "episodesLesser", q.EpisodesLesser)
addValue2InterfaceMap(m, "durationGreater", q.DurationGreater.Minutes())
addValue2InterfaceMap(m, "durationLesser", q.DurationLesser.Minutes())
addValue2InterfaceMap(m, "volumesGreater", q.VolumesGreater)
addValue2InterfaceMap(m, "volumesLesser", q.VolumesLesser)
addSlice2InterfaceMap(m, "genre_in", q.GenreIn)
addSlice2InterfaceMap(m, "genre_not_in", q.GenreNotIn)
addSlice2InterfaceMap(m, "tag_in", q.TagIn)
addSlice2InterfaceMap(m, "tag_not_in", q.TagNotIn)
addSlice2InterfaceMap(m, "source_in", q.SourceIn)
addSlice2InterfaceMap(m, "sort", q.Sort)
return m
}
type MediaSort string
const (
MediaSortId MediaSort = "ID"
MediaSortIdDesc MediaSort = "ID_DESC"
MediaSortTitleRomaji MediaSort = "TITLE_ROMAJI"
MediaSortTitleRomajiDesc MediaSort = "TITLE_ROMAJI_DESC"
MediaSortTitleEnglish MediaSort = "TITLE_ENGLISH"
MediaSortTitleEnglishDesc MediaSort = "TITLE_ENGLISH_DESC"
MediaSortTitleNative MediaSort = "TITLE_NATIVE"
MediaSortTitleNativeDesc MediaSort = "TITLE_NATIVE_DESC"
MediaSortType MediaSort = "TYPE"
MediaSortTypeDesc MediaSort = "TYPE_DESC"
MediaSortFormat MediaSort = "FORMAT"
MediaSortFormatDesc MediaSort = "FORMAT_DESC"
MediaSortStartDate MediaSort = "START_DATE"
MediaSortStartDateDesc MediaSort = "START_DATE_DESC"
MediaSortEndDate MediaSort = "END_DATE"
MediaSortEndDateDesc MediaSort = "END_DATE_DESC"
MediaSortScore MediaSort = "SCORE"
MediaSortScoreDesc MediaSort = "SCORE_DESC"
MediaSortPopularity MediaSort = "POPULARITY"
MediaSortPopularityDesc MediaSort = "POPULARITY_DESC"
MediaSortTrending MediaSort = "TRENDING"
MediaSortTrendingDesc MediaSort = "TRENDING_DESC"
MediaSortEpisodes MediaSort = "EPISODES"
MediaSortEpisodesDesc MediaSort = "EPISODES_DESC"
MediaSortDuration MediaSort = "DURATION"
MediaSortDurationDesc MediaSort = "DURATION_DESC"
MediaSortStatus MediaSort = "STATUS"
MediaSortStatusDesc MediaSort = "STATUS_DESC"
MediaSortChapters MediaSort = "CHAPTERS"
MediaSortChaptersDesc MediaSort = "CHAPTERS_DESC"
MediaSortVolumes MediaSort = "VOLUMES"
MediaSortVolumesDesc MediaSort = "VOLUMES_DESC"
MediaSortUpdatedAt MediaSort = "UPDATED_AT"
MediaSortUpdatedAtDesc MediaSort = "UPDATED_AT_DESC"
MediaSortSearchMatch MediaSort = "SEARCH_MATCH"
MediaSortFavourites MediaSort = "FAVOURITES"
MediaSortFavouritesDesc MediaSort = "FAVOURITES_DESC"
)