anilist

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Unlicense Imports: 12 Imported by: 6

Documentation

Index

Constants

View Source
const (
	OAuthBaseURL      = "https://anilist.co/api/v2/oauth/"
	OAuthPinURL       = OAuthBaseURL + "pin"
	OAuthTokenURL     = OAuthBaseURL + "token"
	OAuthAuthorizeURL = OAuthBaseURL + "authorize"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Anilist

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

Anilist is the Anilist client.

func NewAnilist

func NewAnilist(options Options) (*Anilist, error)

NewAnilist constructs new Anilist client.

func (*Anilist) Authenticated added in v0.19.0

func (p *Anilist) Authenticated() bool

Authenticated returns true if the Provider is currently authenticated (user logged in).

func (*Anilist) Info added in v0.20.0

func (p *Anilist) Info() metadata.ProviderInfo

Info information about Provider.

func (*Anilist) Logger added in v0.20.0

func (p *Anilist) Logger() *logger.Logger

Logger returns the set logger.

Always returns a non-nil logger.

func (*Anilist) Login added in v0.20.0

func (p *Anilist) Login(ctx context.Context, token string) error

Login authorizes an user with the given access token.

func (*Anilist) Logout

func (p *Anilist) Logout() error

Logout de-authorizes the currently authorized user.

func (*Anilist) Search added in v0.20.0

func (p *Anilist) Search(ctx context.Context, query string) ([]metadata.Metadata, error)

Search for metadata with the given query.

Implementation should only handle the request and and marshaling.

func (*Anilist) SearchByID

func (p *Anilist) SearchByID(ctx context.Context, id int) (metadata.Metadata, bool, error)

SearchByID for metadata with the given id.

Implementation should only handle the request and and marshaling.

func (*Anilist) SetLogger added in v0.20.0

func (p *Anilist) SetLogger(_logger *logger.Logger)

SetLogger sets logger to use for this provider.

func (*Anilist) SetMangaProgress

func (p *Anilist) SetMangaProgress(ctx context.Context, id, chapterNumber int) error

SetMangaProgress sets the reading progress for a given manga metadata id.

func (*Anilist) String added in v0.20.0

func (p *Anilist) String() string

func (*Anilist) User added in v0.20.0

func (p *Anilist) User() metadata.User

User returns the currently authenticated user.

nil User means non-authenticated.

type Error

type Error string

Error is a general error for Anilist operations.

func (Error) Error

func (e Error) Error() string

type Manga

type Manga struct {
	TitleGroup struct {
		English string `json:"english" jsonschema:"description=English title of the manga."`
		Romaji  string `json:"romaji" jsonschema:"description=Romanized title of the manga."`
		Native  string `json:"native" jsonschema:"description=Native title of the manga. Usually in kanji."`
	} `json:"title"`
	AverageScore int    `json:"averageScore" jsonschema:"description=Average score of the manga on Anilist."`
	Summary      string `json:"description" jsonschema:"description=Description of the manga in html format."`
	CoverImage   struct {
		ExtraLarge string `` /* 137-byte string literal not displayed */
		Large      string `json:"large" jsonschema:"description=URL of the large cover image."`
		Medium     string `json:"medium" jsonschema:"description=URL of the medium cover image."`
		Color      string `json:"color" jsonschema:"description=Average color of the cover image."`
	} `json:"coverImage" jsonschema:"description=Cover image of the manga."`
	BannerImage string `json:"bannerImage" jsonschema:"description=Banner image of the manga."`
	TagList     []struct {
		Name        string `json:"name" jsonschema:"description=Name of the tag."`
		Description string `json:"description" jsonschema:"description=Description of the tag."`
		Rank        int    `json:"rank" jsonschema:"description=Rank of the tag. How relevant it is to the manga from 1 to 100."`
	} `json:"tags"`
	GenreList     []string `json:"genres" jsonschema:"description=Genres of the manga."`
	CharacterList struct {
		Nodes []struct {
			Name struct {
				Full   string `json:"full" jsonschema:"description=Full name of the character."`
				Native string `json:"native" jsonschema:"description=Native name of the character. Usually in kanji."`
			} `json:"name"`
		} `json:"nodes"`
	} `json:"characters"`
	Staff struct {
		Edges []struct {
			Role string `json:"role" jsonschema:"description=Role of the staff member."`
			Node struct {
				Name struct {
					Full string `json:"full" jsonschema:"description=Full name of the staff member."`
				} `json:"name"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"staff"`
	DateStart         metadata.Date   `json:"startDate" jsonschema:"description=Date the manga started publishing."`
	DateEnd           metadata.Date   `json:"endDate" jsonschema:"description=Date the manga ended publishing."`
	Synonyms          []string        `json:"synonyms" jsonschema:"description=Synonyms of the manga (Alternative titles)."`
	PublicationStatus metadata.Status `json:"status" jsonschema:"enum=FINISHED,enum=RELEASING,enum=NOT_YET_RELEASED,enum=CANCELLED,enum=HIATUS"`
	ChapterCount      int             `json:"chapters" jsonschema:"description=Amount of chapters the manga has when complete."`
	SiteURL           string          `json:"siteUrl" jsonschema:"description=URL of the manga on AnilistSearch."`
	CountryOfOrigin   string          `json:"countryOfOrigin" jsonschema:"description=Country of origin of the manga. ISO 3166-1 alpha-2 country code."`
	IDProvider        int             `json:"id" jsonschema:"description=ID of the manga on AnilistSearch."`
	IDMal             int             `json:"idMal" jsonschema:"description=ID of the manga on MyAnimeList."`
	External          []struct {
		URL string `json:"url" jsonschema:"description=URL of the external link."`
	} `json:"externalLinks" jsonschema:"description=External links related to the manga."`
}

Manga is a metadata.Metadata implementation for Anilist manga metadata.

Note that Manga fields don't match the incoming json fields to avoid collisions with the interface.

func (*Manga) AlternateTitles added in v0.17.0

func (m *Manga) AlternateTitles() []string

AlternateTitles is a list of alternative titles in order of relevance.

func (*Manga) Artists added in v0.17.0

func (m *Manga) Artists() []string

Artists is the list of artists, in order of relevance.

func (*Manga) Authors added in v0.17.0

func (m *Manga) Authors() []string

Authors (or Writers) is the list of authors, in order of relevance. Must contain at least one artist.

func (*Manga) Banner added in v0.17.0

func (m *Manga) Banner() string

Banner is the banner image of the manga.

func (*Manga) Chapters

func (m *Manga) Chapters() int

Chapter count until this point.

func (*Manga) Characters

func (m *Manga) Characters() []string

Characters is the list of characters, in order of relevance.

func (*Manga) Country

func (m *Manga) Country() string

Country of origin of the manga. ISO 3166-1 alpha-2 country code.

func (*Manga) Cover added in v0.17.0

func (m *Manga) Cover() string

Cover is the cover image of the manga.

func (*Manga) Description

func (m *Manga) Description() string

Description is the description/summary for the manga.

func (*Manga) EndDate

func (m *Manga) EndDate() metadata.Date

EndDate is the date the manga ended publishing.

func (*Manga) ExtraIDs added in v0.17.0

func (m *Manga) ExtraIDs() []metadata.ID

ExtraIDs is a list of extra available IDs in the metadata provider. Each extra ID must be valid (ID.Validate).

func (*Manga) Format added in v0.17.0

func (m *Manga) Format() string

Format the original publication.

For example: TBP, HC, Web, Digital, etc..

func (*Manga) Genres

func (m *Manga) Genres() []string

Genres is the list of genres associated with the manga.

func (*Manga) ID

func (m *Manga) ID() metadata.ID

ID is the ID information of the metadata. Must be valid (ID.Validate).

func (*Manga) Letterers added in v0.17.0

func (m *Manga) Letterers() []string

Letterers is the list of letterers, in order of relevance.

func (*Manga) Notes added in v0.17.0

func (m *Manga) Notes() string

Extra notes to be added.

func (*Manga) Publisher added in v0.17.0

func (m *Manga) Publisher() string

Publisher of the manga.

func (*Manga) Score added in v0.17.0

func (m *Manga) Score() float32

Score is the community score for the manga.

Accepted values are between 0.0 and 5.0.

func (*Manga) StartDate

func (m *Manga) StartDate() metadata.Date

StartDate is the date the manga started publishing. Must be non-zero.

func (*Manga) Status

func (m *Manga) Status() metadata.Status

Current status of the manga. Must be non-empty.

One of: FINISHED, RELEASING, NOT_YET_RELEASED, CANCELLED, HIATUS

func (*Manga) String

func (m *Manga) String() string

String is the short representation of the manga. Must be non-empty.

At the minimum it should return "`Title` (`Year`)", else "`Title` (`Year`) [`IDCode`id-`ID`]" if available.

func (*Manga) Tags

func (m *Manga) Tags() []string

Tags is the list of tags associated with the manga.

func (*Manga) Title

func (m *Manga) Title() string

Title is the English title of the manga. Must be non-empty.

If English is not available, then in in order of availability: Romaji (the romanized title) or Native (usually Kanji).

func (*Manga) Translators added in v0.17.0

func (m *Manga) Translators() []string

Translators is the list of translators, in order of relevance.

func (*Manga) URL added in v0.17.0

func (m *Manga) URL() string

URL is the source URL of the metadata.

type Options

type Options struct {
	// HTTPClient is a http client used for Anilist API.
	HTTPClient *http.Client

	// LogWriter used for logs progress.
	Logger *logger.Logger
}

Options is options for Anilist client.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions constructs default AnilistOptions.

type User added in v0.19.0

type User struct {
	IDProvider     int    `json:"id" jsonschema:"description=The ID of the user."`
	NameProvider   string `json:"name" jsonschema:"description=The name of the user."`
	AboutProvider  string `json:"about" jsonschema:"description=The bio written by user (Markdown)."`
	AvatarProvider struct {
		Large  string `json:"large" jsonschema:"description=The avatar of user at its largest size."`
		Medium string `json:"medium" jsonschema:"description=The avatar of user at medium size."`
	} `json:"avatar" jsonschema:"description=The user's avatar images."`
	BannerImage string `json:"bannerImage" jsonschema:"description=The user's banner images."`
	Options     struct {
		TitleLanguage       string `` /* 134-byte string literal not displayed */
		DisplayAdultContent bool   `json:"displayAdultContent" jsonschema:"description=Whether the user has enabled viewing of 18+ content."`
		ProfileColor        string `json:"profileColor" jsonschema:"description=Profile highlight color (blue, purple, pink, orange, red, green, gray)."`
		Timezone            string `json:"timezone" jsonschema:"description=The user's timezone offset (Auth user only)."`
	} `json:"options" jsonschema:"The user's general options."`
	SiteURL       string `json:"siteUrl" jsonschema:"description=The URL for the user page on the AniList website."`
	CreatedAt     int    `` /* 129-byte string literal not displayed */
	UpdatedAt     int    `json:"updatedAt" jsonschema:"description=When the user's data was last updated."`
	PreviousNames []struct {
		Name      string `json:"name" jsonschema:"description=The name of the user."`
		CreatedAt int    `json:"createdAt" jsonschema:"description=When the user first changed from this name."`
		UpdatedAt int    `json:"updatedAt" jsonschema:"description=When the user most recently changed from this name."`
	} `json:"previous_names" jsonschema:"description=The user's previously used names."`
}

User is the user model for Anilist.

Note that User fields don't match the incoming json fields to avoid collisions with the interface.

func (*User) About added in v0.19.0

func (u *User) About() string

About is the about section of the user.

func (*User) Avatar added in v0.19.0

func (u *User) Avatar() string

Avatar is the URL of the avatar image.

func (*User) ID added in v0.19.0

func (u *User) ID() int

ID is the id of the user.

func (*User) Name added in v0.19.0

func (u *User) Name() string

Name of the user.

func (*User) Source added in v0.20.0

func (u *User) Source() metadata.IDSource

Source provider of the user.

For example if coming from Anilist: IDSourceAnilist.

func (*User) String added in v0.20.0

func (u *User) String() string

String is the short representation of the user. Must be non-empty.

For example "`Name` (`ID`)".

func (*User) URL added in v0.20.0

func (u *User) URL() string

URL is the user's URL on the metadata provider website.

Jump to

Keyboard shortcuts

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