mal

package
v0.0.0-...-28a87cb Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BaseMALAddress            = "https://myanimelist.net"
	ApiEndpoint               = BaseMALAddress + "/api"
	VerifyCredentialsEndpoint = ApiEndpoint + "/account/verify_credentials.xml"
)
View Source
const (
	UpdateEndpoint = ApiEndpoint + "/animelist/update/%d.xml" //%d - anime database ID
	DeleteEndpoint = ApiEndpoint + "/animelist/delete/%d.xml" //%d - anime database ID

	UserAnimeListEndpoint = BaseMALAddress + "/malappinfo.php?u=%s&status=%s&type=anime" //%s - username %s - status

	AnimePage = BaseMALAddress + "/anime/%d" //%d - anime database ID
)

For using as a printf format

View Source
const AnimeXMLTemplate = `` /* 389-byte string literal not displayed */

Variables

This section is empty.

Functions

func AnimeSortByLastUpdated

func AnimeSortByLastUpdated(list []*Anime) sort.Interface

func AnimeSortByScore

func AnimeSortByScore(list []*Anime) sort.Interface

func AnimeSortByTitle

func AnimeSortByTitle(list []*Anime) sort.Interface

func AnimeSortByWatchedEpisodes

func AnimeSortByWatchedEpisodes(list []*Anime) sort.Interface

func UpdateEntryWithAnimation

func UpdateEntryWithAnimation(c *Client, entry *Anime) error

func VerifyCredentials

func VerifyCredentials(credentials string) bool

Types

type Anime

type Anime struct {
	ID          int         `xml:"series_animedb_id"`
	Title       string      `xml:"series_title"`
	Synonyms    string      `xml:"series_synonyms"`
	Type        AnimeType   `xml:"series_type"`
	Episodes    int         `xml:"series_episodes"`
	Status      AnimeStatus `xml:"series_status"`
	SeriesStart string      `xml:"series_start"`
	SeriesEnd   string      `xml:"series_end"`
	ImageURL    string      `xml:"series_image"`

	MyID                int        `xml:"my_id"`
	WatchedEpisodes     int        `xml:"my_watched_episodes"`
	MyStart             string     `xml:"my_start_date"`
	MyFinish            string     `xml:"my_finish_date"`
	MyScore             AnimeScore `xml:"my_score"`
	MyStatus            MyStatus   `xml:"my_status"`
	MyRewatching        int        `xml:"my_rewatching"`
	MyRewatchingEpisode int        `xml:"my_rewatching_ep"`
	LastUpdated         int64      `xml:"my_last_updated"`
	MyTags              string     `xml:"my_tags"`
}

type AnimeCustomSort

type AnimeCustomSort struct {
	List  []*Anime
	LessF func(x, y *Anime) bool
}

func (AnimeCustomSort) Len

func (acs AnimeCustomSort) Len() int

func (AnimeCustomSort) Less

func (acs AnimeCustomSort) Less(i, j int) bool

func (AnimeCustomSort) Swap

func (acs AnimeCustomSort) Swap(i, j int)

type AnimeDetails

type AnimeDetails struct {
	JapaneseTitle string
	Related       []Related
	Synopsis      string
	Background    string
	Characters    []Character
	Staff         []Staff
	OpeningThemes []string
	EndingThemes  []string
	Premiered     string
	Broadcast     string
	Producers     []string
	Licensors     []string
	Studios       []string
	Source        string
	Genres        []string
	Duration      string
	Rating        string
	Score         float64
	ScoreVoters   int
	Ranked        int
	Popularity    int
	Members       int
	Favorites     int
}

func FetchDetailsWithAnimation

func FetchDetailsWithAnimation(c *Client, entry *Anime) (*AnimeDetails, error)

type AnimeList

type AnimeList []*Anime

func (AnimeList) DeleteByID

func (list AnimeList) DeleteByID(id int) AnimeList

func (AnimeList) FilterByStatus

func (list AnimeList) FilterByStatus(status MyStatus) AnimeList

func (AnimeList) GetByID

func (list AnimeList) GetByID(id int) *Anime

type AnimeScore

type AnimeScore int
const (
	NotRatedYet AnimeScore = iota
	Appalling
	Horrible
	VeryBad
	Bad
	Average
	Fine
	Good
	VeryGood
	Great
	Masterpiece
)

func ParseScore

func ParseScore(score int) (AnimeScore, error)

type AnimeStatus

type AnimeStatus int
const (
	CurrentlyAiring AnimeStatus = iota + 1
	FinishedAiring
	NotYetAired
)

func (AnimeStatus) String

func (status AnimeStatus) String() string

type AnimeType

type AnimeType int
const (
	Tv AnimeType = iota + 1
	Ova
	Movie
	Special
	Ona
	Music
)

func (AnimeType) String

func (t AnimeType) String() string

type Character

type Character struct {
	Name             string
	Role             string
	VoiceActor       string
	VoiceActorOrigin string
}

type Client

type Client struct {
	Username string

	ID          string `xml:"user_id"`
	Watching    int    `xml:"user_watching"`
	Completed   int    `xml:"user_completed"`
	OnHold      int    `xml:"user_onhold"`
	Dropped     int    `xml:"user_dropped"`
	PlanToWatch int    `xml:"user_plantowatch"`

	DaysSpentWatching float64 `xml:"user_days_spent_watching"`
	// contains filtered or unexported fields
}

func NewClient

func NewClient(credentials string) *Client

credentials should be username + password encoded in the basic auth standard

func (*Client) AnimeList

func (c *Client) AnimeList(status MyStatus) ([]*Anime, error)

Note: Since anime list endpoint, besides anime list, returns account stats, this method also updates Client with them

func (*Client) Delete

func (c *Client) Delete(entry *Anime) error

func (*Client) FetchDetails

func (c *Client) FetchDetails(entry *Anime) (*AnimeDetails, error)

This works by scraping the normal MAL website for given entry. It means that this method will stop working when they change something

func (*Client) Update

func (c *Client) Update(entry *Anime) error

type MyStatus

type MyStatus int
const (
	All MyStatus = iota
	Watching
	Completed
	OnHold
	Dropped
	PlanToWatch MyStatus = 6 //Apparently MAL stores this as 6
)

func ParseStatus

func ParseStatus(status string) MyStatus

func (MyStatus) String

func (status MyStatus) String() string
type Related struct {
	Relation string
	Title    string
	Url      string
}

type Staff

type Staff struct {
	Name     string
	Position string
}

Jump to

Keyboard shortcuts

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