mal

package
v0.0.0-...-cb5d4ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(logger *zap.Logger)

Types

type AlternativeTitles

type AlternativeTitles struct {
	Synonyms []string `json:"synonyms,omitempty"`
	En       string   `json:"en,omitempty"`
	Ja       string   `json:"ja,omitempty"`
}

type Anime

type Anime struct {
	ID                     int               `json:"id,omitempty"`
	Title                  string            `json:"title,omitempty"`
	MainPicture            Picture           `json:"main_picture,omitempty"`
	AlternativeTitles      AlternativeTitles `json:"alternative_titles,omitempty"`
	StartDate              string            `json:"start_date,omitempty"`
	EndDate                string            `json:"end_date,omitempty"`
	Synopsis               string            `json:"synopsis,omitempty"`
	Mean                   float64           `json:"mean,omitempty"`
	Rank                   int               `json:"rank,omitempty"`
	Popularity             int               `json:"popularity,omitempty"`
	NumListUsers           int               `json:"num_list_users,omitempty"`
	NumScoringUsers        int               `json:"num_scoring_users,omitempty"`
	Nsfw                   string            `json:"nsfw,omitempty"`
	Genres                 []Genre           `json:"genres,omitempty"`
	CreatedAt              string            `json:"created_at,omitempty"`
	UpdatedAt              string            `json:"updated_at,omitempty"`
	MediaType              string            `json:"media_type,omitempty"`
	Status                 string            `json:"status,omitempty"`
	MyListStatus           MyListStatus      `json:"my_list_status,omitempty"`
	NumEpisodes            int               `json:"num_episodes,omitempty"`
	StartSeason            SeasonInfo        `json:"start_season,omitempty"`
	Broadcast              Broadcast         `json:"broadcast,omitempty"`
	Source                 string            `json:"source,omitempty"`
	AverageEpisodeDuration int               `json:"average_episode_duration,omitempty"`
	Rating                 string            `json:"rating,omitempty"`
	Studios                []AnimeStudio     `json:"studios,omitempty"`
}

type AnimeListOptions

type AnimeListOptions struct {
	Status StatusOpt
	Sort   SortOpt
}

func (AnimeListOptions) Set

func (opts AnimeListOptions) Set(v url.Values)

type AnimeRanking

type AnimeRanking struct {
	Node    Anime `json:"node,omitempty"`
	Ranking struct {
		Rank int `json:"rank,omitempty"`
	} `json:"ranking,omitempty"`
}

type AnimeRankingPage

type AnimeRankingPage struct {
	Data   []AnimeRanking `json:"data,omitempty"`
	Paging Paging         `json:"paging,omitempty"`
}

func (*AnimeRankingPage) NextPage

func (ranking *AnimeRankingPage) NextPage(client *Client) (*AnimeRankingPage, error)

func (*AnimeRankingPage) PrevPage

func (ranking *AnimeRankingPage) PrevPage(client *Client) (*AnimeRankingPage, error)

type AnimeSearch

type AnimeSearch struct {
	Node Anime `json:"node,omitempty"`
}

type AnimeSearchPage

type AnimeSearchPage struct {
	Data   []AnimeSearch `json:"data,omitempty"`
	Paging Paging        `json:"paging,omitempty"`
}

func (*AnimeSearchPage) NextPage

func (search *AnimeSearchPage) NextPage(client *Client) (*AnimeSearchPage, error)

func (*AnimeSearchPage) PrevPage

func (search *AnimeSearchPage) PrevPage(client *Client) (*AnimeSearchPage, error)

type AnimeStatistics

type AnimeStatistics struct {
	NumItemsWatching    int     `json:"num_items_watching,omitempty"`
	NumItemsCompleted   int     `json:"num_items_completed,omitempty"`
	NumItemsOnHold      int     `json:"num_items_on_hold,omitempty"`
	NumItemsDropped     int     `json:"num_items_dropped,omitempty"`
	NumItemsPlanToWatch int     `json:"num_items_plan_to_watch,omitempty"`
	NumItems            int     `json:"num_items,omitempty"`
	NumDaysWatched      float64 `json:"num_days_watched,omitempty"`
	NumDaysWatching     float64 `json:"num_days_watching,omitempty"`
	NumDaysCompleted    float64 `json:"num_days_completed,omitempty"`
	NumDaysOnHold       int     `json:"num_days_on_hold,omitempty"`
	NumDaysDropped      int     `json:"num_days_dropped,omitempty"`
	NumDays             float64 `json:"num_days,omitempty"`
	NumEpisodes         int     `json:"num_episodes,omitempty"`
	NumTimesRewatched   int     `json:"num_times_rewatched,omitempty"`
	MeanScore           float64 `json:"mean_score,omitempty"`
}

type AnimeStudio

type AnimeStudio struct {
	ID   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type AnimeUpdateResponse

type AnimeUpdateResponse struct {
	Status             string   `json:"status,omitempty"`
	Score              int      `json:"score,omitempty"`
	NumEpisodesWatched int      `json:"num_episodes_watched,omitempty"`
	IsRewatching       bool     `json:"is_rewatching,omitempty"`
	UpdatedAt          string   `json:"updated_at,omitempty"`
	Priority           int      `json:"priority,omitempty"`
	NumTimesRewatched  int      `json:"num_times_rewatched,omitempty"`
	RewatchValue       int      `json:"rewatch_value,omitempty"`
	Tags               []string `json:"tags,omitempty"`
	Comments           string   `json:"comments,omitempty"`
}

type ApiError

type ApiError struct {
	ErrorType  string `json:"error,omitempty"`
	Message    string `json:"message,omitempty"`
	StatusCode int    `json:"-"`
}

func (*ApiError) Error

func (apiErr *ApiError) Error() string

type Broadcast

type Broadcast struct {
	DayOfTheWeek string `json:"day_of_the_week,omitempty"`
	StartTime    string `json:"start_time,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token *oauth2.Token) (*Client, error)

func (*Client) DeleteAnimeListItem

func (client *Client) DeleteAnimeListItem(animeID int) error

func (*Client) GetAnimeDetails

func (client *Client) GetAnimeDetails(animeID int, opts ...OptFn) (*Anime, error)

func (*Client) GetAnimeRanking

func (client *Client) GetAnimeRanking(ranking RankingType, opts ...OptFn) (*AnimeRankingPage, error)

func (*Client) GetMyAnimeList

func (client *Client) GetMyAnimeList(opts AnimeListOptions, commonOpts ...OptFn) (*UserAnimePage, error)

func (*Client) GetMyUserInformation

func (client *Client) GetMyUserInformation(opts ...OptFn) (*AnimeStatistics, error)

func (*Client) GetSeasonalAnime

func (client *Client) GetSeasonalAnime(
	year int,
	season Season,
	opts ...OptFn,
) (*SeasonalAnimePage, error)

func (*Client) GetSuggestedAnime

func (client *Client) GetSuggestedAnime(opts ...OptFn) (*SuggestedAnimePage, error)

func (*Client) GetUserAnimeList

func (client *Client) GetUserAnimeList(user string, opts AnimeListOptions, commonOpts ...OptFn) (*UserAnimePage, error)

func (*Client) SearchAnime

func (client *Client) SearchAnime(q string, opts ...OptFn) (*AnimeSearchPage, error)

func (*Client) SetDebug

func (client *Client) SetDebug(b bool)

func (*Client) UpdateAnimeList

func (client *Client) UpdateAnimeList(animeID int, opts *UpdateListOptsBuilder) (*AnimeUpdateResponse, error)

type Genre

type Genre struct {
	Id   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type MyListStatus

type MyListStatus struct {
	Status string `json:"status,omitempty"`
	Score  int    `json:"score,omitempty"`
	// TODO: num_episodes_watched or num_watched_episodes
	NumEpisodesWatched int      `json:"num_episodes_watched,omitempty"`
	IsRewatching       bool     `json:"is_rewatching,omitempty"`
	StartDate          string   `json:"start_date,omitempty"`
	FinishDate         string   `json:"finish_date,omitempty"`
	Priority           int      `json:"priority,omitempty"`
	NumTimesRewatched  int      `json:"num_times_rewatched,omitempty"`
	RewatchValue       int      `json:"rewatch_value,omitempty"`
	Tags               []string `json:"tags,omitempty"`
	Comments           string   `json:"comments,omitempty"`
	UpdatedAt          string   `json:"updated_at,omitempty"`
}

type MyUserInformation

type MyUserInformation struct {
	ID              int             `json:"id,omitempty"`
	Name            string          `json:"name,omitempty"`
	Location        string          `json:"location,omitempty"`
	JoinedAt        string          `json:"joined_at,omitempty"`
	AnimeStatistics AnimeStatistics `json:"anime_statistics,omitempty"`
}

type OAuth

type OAuth struct {
	// contains filtered or unexported fields
}

func NewOauth

func NewOauth(clientID string) *OAuth

52fbc429dc04c003c905a3b1a44269b7

func (*OAuth) AuthCodeURL

func (auth *OAuth) AuthCodeURL(state string, challenge string) string

func (*OAuth) Exchange

func (auth *OAuth) Exchange(ctx context.Context, code, verifier string) (*oauth2.Token, error)

func (*OAuth) NewCodeVerifier

func (auth *OAuth) NewCodeVerifier() string

type OptFn

type OptFn func(url.Values)

func Fields

func Fields(fields ...string) OptFn

func Limit

func Limit(n int) OptFn

func Nsfw

func Nsfw() OptFn

func Offset

func Offset(n int) OptFn

func SortSeasonalAnime

func SortSeasonalAnime(sort SeasonalSort) OptFn

type Paging

type Paging struct {
	Previous string `json:"previous,omitempty"`
	Next     string `json:"next,omitempty"`
}

func (Paging) HasNext

func (p Paging) HasNext() bool

func (Paging) HasPrev

func (p Paging) HasPrev() bool

type Picture

type Picture struct {
	Large  string `json:"large,omitempty"`
	Medium string `json:"medium,omitempty"`
}

type RankingType

type RankingType string
const (
	RankingAll          RankingType = "all"
	RankingAiring       RankingType = "airing"
	RankingUpcoming     RankingType = "upcoming"
	RankingTV           RankingType = "tv"
	RankingOVA          RankingType = "ova"
	RankingMovie        RankingType = "movie"
	RankingSpecial      RankingType = "special"
	RankingByPopularity RankingType = "bypopularity"
	RankingFavorite     RankingType = "favorite"
)

type Season

type Season string
const (
	SeasonWinter Season = "winter"
	SeasonSpring Season = "spring"
	SeasonSummer Season = "summer"
	SeasonFall   Season = "fall"
)

type SeasonInfo

type SeasonInfo struct {
	Year   int    `json:"year,omitempty"`
	Season string `json:"season,omitempty"`
}

type SeasonalAnime

type SeasonalAnime struct {
	Node Anime `json:"node,omitempty"`
}

type SeasonalAnimePage

type SeasonalAnimePage struct {
	Data   []AnimeSearch `json:"data,omitempty"`
	Paging Paging        `json:"paging,omitempty"`
	Season Season        `json:"season,omitempty"`
}

func (*SeasonalAnimePage) NextPage

func (seasonal *SeasonalAnimePage) NextPage(client *Client) (*SeasonalAnimePage, error)

func (*SeasonalAnimePage) PrevPage

func (seasonal *SeasonalAnimePage) PrevPage(client *Client) (*SeasonalAnimePage, error)

type SeasonalSort

type SeasonalSort string
const (
	SeasonalSortAnimeScore        SeasonalSort = "anime_score"
	SeasonalSortAnimeNumListUsers SeasonalSort = "anime_num_list_users"
)

type SortOpt

type SortOpt string
const (
	SortListScore      SortOpt = "list_score"
	SortListUpdatedAt  SortOpt = "list_updated_at"
	SortAnimeTitle     SortOpt = "anime_title"
	SortAnimeStartDate SortOpt = "anime_start_date"
	SortAnimeID        SortOpt = "anime_id"
)

type StatusOpt

type StatusOpt string
const (
	StatusWatching    StatusOpt = "watching"
	StatusCompleted   StatusOpt = "completed"
	StatusOnHold      StatusOpt = "on_hold"
	StatusDropped     StatusOpt = "dropped"
	StatusPlanToWatch StatusOpt = "plan_to_watch"
)

type SuggestedAnime

type SuggestedAnime struct {
	Node Anime `json:"node,omitempty"`
}

type SuggestedAnimePage

type SuggestedAnimePage struct {
	Data   []SuggestedAnime `json:"data,omitempty"`
	Paging Paging           `json:"paging,omitempty"`
}

func (*SuggestedAnimePage) NextPage

func (suggested *SuggestedAnimePage) NextPage(client *Client) (*SuggestedAnimePage, error)

func (*SuggestedAnimePage) PrevPage

func (suggested *SuggestedAnimePage) PrevPage(client *Client) (*SuggestedAnimePage, error)

type UpdateListOptsBuilder

type UpdateListOptsBuilder struct {
	// contains filtered or unexported fields
}

func UpdateListOpts

func UpdateListOpts() *UpdateListOptsBuilder

func (*UpdateListOptsBuilder) Comments

func (b *UpdateListOptsBuilder) Comments(comments string) *UpdateListOptsBuilder

func (*UpdateListOptsBuilder) IsRewatching

func (b *UpdateListOptsBuilder) IsRewatching(rewatching bool) *UpdateListOptsBuilder

func (*UpdateListOptsBuilder) NumTimesRewatched

func (b *UpdateListOptsBuilder) NumTimesRewatched(n int) *UpdateListOptsBuilder

func (*UpdateListOptsBuilder) NumWatchedEpisodes

func (b *UpdateListOptsBuilder) NumWatchedEpisodes(eps int) *UpdateListOptsBuilder

func (*UpdateListOptsBuilder) Priority

func (*UpdateListOptsBuilder) RewatchValue

func (b *UpdateListOptsBuilder) RewatchValue(v int) *UpdateListOptsBuilder

func (*UpdateListOptsBuilder) Score

func (*UpdateListOptsBuilder) Status

func (*UpdateListOptsBuilder) Tags

type UserAnime

type UserAnime struct {
	Node       Anime        `json:"node,omitempty"`
	ListStatus MyListStatus `json:"list_status,omitempty"`
}

type UserAnimePage

type UserAnimePage struct {
	Data   []UserAnime `json:"data,omitempty"`
	Paging Paging      `json:"paging,omitempty"`
}

func (*UserAnimePage) NextPage

func (userAnime *UserAnimePage) NextPage(client *Client) (*UserAnimePage, error)

func (*UserAnimePage) PrevPage

func (userAnime *UserAnimePage) PrevPage(client *Client) (*UserAnimePage, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL