myanimelist

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: 2

Documentation

Index

Constants

View Source
const (
	OAuthBaseURL      = "https://myanimelist.net/v1/oauth2/"
	OAuthTokenURL     = OAuthBaseURL + "token"
	OAuthAuthorizeURL = OAuthBaseURL + "authorize"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error string

Error is a general error for MyAnimeList operations.

func (Error) Error

func (e Error) Error() string

type Manga

type Manga struct {
	IDProvider    int    `json:"id"`
	TitleProvider string `json:"title"`
	MainPicture   struct {
		Large  string `json:"large"`
		Medium string `json:"medium"`
	} `json:"main_picture"`
	AlternativeTitles struct {
		Synonyms []string `json:"synonyms"`
		En       string   `json:"en"`
		Ja       string   `json:"ja"`
	} `json:"alternative_titles"`
	DateStart  date    `json:"start_date"`
	DateEnd    date    `json:"end_date"`
	Synopsis   string  `json:"synopsis"`
	Mean       float32 `json:"mean"`
	Rank       int     `json:"rank"`
	Popularity int     `json:"popularity"`
	NSFW       string  `json:"nsfw" jsonschema:"enum=white,enum=gray,enum=black"`
	GenreList  []struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"genres"`
	CreatedAt         string `json:"created_at"`
	UpdatedAt         string `json:"updated_at"`
	MediaType         string `` /* 127-byte string literal not displayed */
	PublicationStatus Status `json:"status"`
	NumVolumes        int    `json:"num_volumes"`
	NumChapters       int    `json:"num_chapters"`
	AuthorList        []struct {
		Node authorListNode `json:"node"`
		Role string         `json:"role"`
	} `json:"authors"`
}

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

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

func (*Manga) AlternateTitles

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

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

func (*Manga) Artists

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

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

func (*Manga) Authors

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

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

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

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

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

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

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

func (*Manga) Notes

func (m *Manga) Notes() string

Extra notes to be added.

func (*Manga) Publisher

func (m *Manga) Publisher() string

Publisher of the manga.

func (*Manga) Score

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

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

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

func (*Manga) URL

func (m *Manga) URL() string

URL is the source URL of the metadata.

type MyAnimeList

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

MyAnimeList is a metadata.Provider implementation for MyAnimeList.

func NewMAL

func NewMAL(options Options) (*MyAnimeList, error)

NewMAL constructs new MyAnimeList client.

func (*MyAnimeList) Authenticated

func (p *MyAnimeList) Authenticated() bool

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

func (*MyAnimeList) Info

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

Info information about Provider.

func (*MyAnimeList) Logger

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

Logger returns the set logger.

Always returns a non-nil logger.

func (*MyAnimeList) Login

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

Login authorizes an user with the given access token.

func (*MyAnimeList) Logout

func (p *MyAnimeList) Logout() error

Logout de-authorizes the currently authorized user.

func (*MyAnimeList) Search

func (p *MyAnimeList) 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 (*MyAnimeList) SearchByID

func (p *MyAnimeList) 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 (*MyAnimeList) SetLogger

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

SetLogger sets logger to use for this provider.

func (*MyAnimeList) SetMangaProgress

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

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

func (*MyAnimeList) String

func (p *MyAnimeList) String() string

func (*MyAnimeList) User

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

User returns the currently authenticated user.

nil User means non-authenticated.

type Options

type Options struct {
	// ClientID of the MyAnimeList API client. Required.
	ClientID string

	// NSFW if NSFW mangas should be included in the searches.
	NSFW bool

	// HTTPClient is a http client used for Anilist API.
	HTTPClient *http.Client

	// LogWriter used for logs progress.
	//
	// If Logger is nil, a new one will be created.
	Logger *logger.Logger
}

func DefaultOptions

func DefaultOptions() Options

DefaultOptions constructs default AnilistOptions.

Note: the ClientID still needs to be passed separately.

type ReadStatus added in v0.20.1

type ReadStatus struct {
	Status          string   `json:"status,omitempty" jsonschema:"enum=reading,enum=completed,enum=on_hold,enum=dropped,enum=plan_to_read"`
	Score           int      `json:"score,omitempty" jsonschema:"description=0-10"`
	NumVolumesRead  int      `json:"num_volumes_read,omitempty" jsonschema:"description=0 or the number of read volumes."`
	NumChaptersRead int      `json:"num_chapters_read,omitempty" jsonschema:"description=0 or the number of read chapters."`
	IsRereading     bool     `` /* 209-byte string literal not displayed */
	StartDate       string   `json:"start_date,omitempty"`
	FinishDate      string   `json:"finish_date,omitempty"`
	Priority        int      `json:"priority,omitempty"`
	NumTimesReread  int      `json:"num_times_reread,omitempty"`
	RereadValue     int      `json:"reread_value,omitempty"`
	Tags            []string `json:"tags,omitempty"`
	Comments        string   `json:"comments,omitempty"`
	UpdatedAt       string   `json:"updated_at,omitempty"`
}

TODO: change field types from string to date/date-time

ReadStatus represents the MyAnimeList manga list read status.

type Status

type Status string
const (
	StatusFinished            Status = "finished"
	StatusCurrentlyPublishing Status = "currently_publishing"
	StatusNotYetPublished     Status = "not_yet_published"
)

type User

type User struct {
	IDProvider   int    `json:"id"`
	NameProvider string `json:"name"`
	Picture      string `json:"picture"`
	Gender       string `json:"gender"`
	Birthday     string `json:"birthday"`
	Location     string `json:"location"`
	JoinedAt     string `json:"joined_at"`
	Timezone     string `json:"time_zone" jsonschema:"For example 'America/Los_Angeles'"`
	IsSupporter  bool   `json:"is_supporter"`
}

TODO: add AnimeStatistics TODO: change field types from string to date/date-time

User is the user model for MyAnimeList.

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

func (*User) About

func (u *User) About() string

About is the about section of the user.

func (*User) Avatar

func (u *User) Avatar() string

Avatar is the URL of the avatar image.

func (*User) ID

func (u *User) ID() int

ID is the id of the user.

func (*User) Name

func (u *User) Name() string

Name of the user.

func (*User) Source

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

Source provider of the user.

For example if coming from Anilist: IDSourceAnilist.

func (*User) String

func (u *User) String() string

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

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

func (*User) URL

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