anilist

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const GetUserByName_Operation = `
query GetUserByName ($name: String!) {
	User(name: $name) {
		id
	}
}
`

The query or mutation executed by GetUserByName.

View Source
const GetWatching_Operation = `` /* 239-byte string literal not displayed */

The query or mutation executed by GetWatching.

Variables

This section is empty.

Functions

func New

func New(anilistEndpoint string, pageSize int) usecases.Tracker

New creates an Anilist Tracker and its GraphQL client

func NewGraphQLClient

func NewGraphQLClient(anilistEndpoint string) graphql.Client

func NewRatedClient

func NewRatedClient(interval time.Duration, requests int, base *http.Client) graphql.Doer

NewRatedClient creates a GraphQL-compatible HTTP client with rate-limiting restrictions. Useful to avoid blacklisting on upstream services.

Types

type GetUserByNameResponse

type GetUserByNameResponse struct {
	// User query
	User GetUserByNameUser `json:"User"`
}

GetUserByNameResponse is returned by GetUserByName on success.

func GetUserByName

func GetUserByName(
	ctx context.Context,
	client graphql.Client,
	name string,
) (*GetUserByNameResponse, error)

func (*GetUserByNameResponse) GetUser

GetUser returns GetUserByNameResponse.User, and is useful for accessing the field via an interface.

type GetUserByNameUser

type GetUserByNameUser struct {
	// The id of the user
	Id int `json:"id"`
}

GetUserByNameUser includes the requested fields of the GraphQL type User. The GraphQL type's documentation follows.

A user

func (*GetUserByNameUser) GetId

func (v *GetUserByNameUser) GetId() int

GetId returns GetUserByNameUser.Id, and is useful for accessing the field via an interface.

type GetWatchingPage

type GetWatchingPage struct {
	MediaList []GetWatchingPageMediaList `json:"mediaList"`
}

GetWatchingPage includes the requested fields of the GraphQL type Page. The GraphQL type's documentation follows.

Page of data

func (*GetWatchingPage) GetMediaList

func (v *GetWatchingPage) GetMediaList() []GetWatchingPageMediaList

GetMediaList returns GetWatchingPage.MediaList, and is useful for accessing the field via an interface.

type GetWatchingPageMediaList

type GetWatchingPageMediaList struct {
	Media GetWatchingPageMediaListMedia `json:"media"`
}

GetWatchingPageMediaList includes the requested fields of the GraphQL type MediaList. The GraphQL type's documentation follows.

List of anime or manga

func (*GetWatchingPageMediaList) GetMedia

GetMedia returns GetWatchingPageMediaList.Media, and is useful for accessing the field via an interface.

type GetWatchingPageMediaListMedia

type GetWatchingPageMediaListMedia struct {
	// The id of the media
	Id int `json:"id"`
	// The mal id of the media
	IdMal int `json:"idMal"`
	// The official titles of the media in various languages
	Title GetWatchingPageMediaListMediaTitle `json:"title"`
}

GetWatchingPageMediaListMedia includes the requested fields of the GraphQL type Media. The GraphQL type's documentation follows.

Anime or Manga

func (*GetWatchingPageMediaListMedia) GetId

GetId returns GetWatchingPageMediaListMedia.Id, and is useful for accessing the field via an interface.

func (*GetWatchingPageMediaListMedia) GetIdMal

func (v *GetWatchingPageMediaListMedia) GetIdMal() int

GetIdMal returns GetWatchingPageMediaListMedia.IdMal, and is useful for accessing the field via an interface.

func (*GetWatchingPageMediaListMedia) GetTitle

GetTitle returns GetWatchingPageMediaListMedia.Title, and is useful for accessing the field via an interface.

type GetWatchingPageMediaListMediaTitle

type GetWatchingPageMediaListMediaTitle struct {
	// The romanization of the native language title
	Romaji string `json:"romaji"`
}

GetWatchingPageMediaListMediaTitle includes the requested fields of the GraphQL type MediaTitle. The GraphQL type's documentation follows.

The official titles of the media in various languages

func (*GetWatchingPageMediaListMediaTitle) GetRomaji

GetRomaji returns GetWatchingPageMediaListMediaTitle.Romaji, and is useful for accessing the field via an interface.

type GetWatchingResponse

type GetWatchingResponse struct {
	Page GetWatchingPage `json:"Page"`
}

GetWatchingResponse is returned by GetWatching on success.

func GetWatching

func GetWatching(
	ctx context.Context,
	client graphql.Client,
	userId int,
	page int,
	perPage int,
) (*GetWatchingResponse, error)

func (*GetWatchingResponse) GetPage

func (v *GetWatchingResponse) GetPage() GetWatchingPage

GetPage returns GetWatchingResponse.Page, and is useful for accessing the field via an interface.

type Tracker

type Tracker struct {
	Client   graphql.Client
	PageSize int
}

Tracker abstracts an Anilist GraphQL client and provides the common requests needed by MediaLister

func (*Tracker) Close

func (tracker *Tracker) Close() error

func (*Tracker) GetMediaListIDs

func (tracker *Tracker) GetMediaListIDs(ctx context.Context, userId string) ([]string, error)

func (*Tracker) GetUserID

func (tracker *Tracker) GetUserID(ctx context.Context, name string) (string, error)

Jump to

Keyboard shortcuts

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