mg

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: GPL-3.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// used by UpdateAnime
	IsRewatching    = "is_rewatching"
	EpisodesWatched = "num_watched_episodes"
	TimesRewatched  = "num_times_rewatched"
	RewatchValue    = "rewatch_value"

	// used by UpdateManga
	IsRereading  = "is_rereading"
	VolumesRead  = "num_volumes_read"
	ChaptersRead = "num_chapters_read"
	TimesReread  = "num_times_reread"
	RereadValue  = "reread_value"

	// used by both
	Status   = "status"
	Score    = "score"
	Priority = "priority"
	Tags     = "tags"
	Comments = "comments"
)

for UpdateAnime/UpdateManga

View Source
const (
	// for anime only
	RankingTypeAiring   = "airing"
	RankingTypeUpcoming = "upcoming"
	RankingTypeTV       = "tv"
	RankingTypeOVA      = "ova"
	RankingTypeMovie    = "movie"
	RankingTypeSpecial  = "special"

	// for manga only
	RankingTypeManga   = "manga"
	RankingTypeNovel   = "novels"
	RankingTypeOneShot = "oneshots"
	RankingTypeDoujin  = "doujin"
	RankingTypeManhwa  = "manhwa"
	RankingTypeManhua  = "manhua"

	// for both
	RankingTypeAll          = "all"
	RankingTypeByPopularity = "bypopularity"
	RankingTypeFavorite     = "favorite"
)

for getting ranking list

View Source
const (
	// for anime only
	SortByAnimeTitle     = "anime_title"
	SortByAnimeStartDate = "anime_start_date"
	SortByAnimeId        = "anime_id"

	// for manga only
	SortByMangaTitle     = "manga_title"
	SortByMangaStartDate = "manga_start_date"
	SortByMangaId        = "manga_id"

	// for both
	SortByListScore     = "list_score"
	SortByListUpdatedAt = "list_updated_at"
)

for anime/manga list sort

View Source
const (
	// for anime only
	ListStatusWatching = "watching"
	ListStatusPTW      = "plan_to_watch"

	// for manga only
	ListStatusReading = "reading"
	ListStatusPTR     = "plan_to_read"

	// for both
	ListStatusCompleted = "completed"
	ListStatusOnHold    = "on_hold"
	ListStatusDropped   = "dropped"
	ListStatusAll       = "" // for getting user lists only
)

for anime/manga list status

View Source
const (
	// season names
	SeasonWinter = "winter"
	SeasonSpring = "spring"
	SeasonSummer = "summer"
	SeasonFall   = "fall"

	// sorting
	SeasonSortByAnimeScore   = "anime_score"
	SeasonSortByNumListUsers = "num_list_users"
)

for anime seasons

View Source
const ANIME_BASE_URL string = BASE_URL + "/anime"
View Source
const BASE_URL string = "https://api.myanimelist.net/v2"
View Source
const MANGA_BASE_URL string = BASE_URL + "/manga"

Variables

View Source
var (
	ErrLimitOutOfRange        = errors.New("mg: invalid limit (out of range)")
	ErrInvalidField           = errors.New("mg: invalid field passed")
	ErrInvalidRankingType     = errors.New("mg: invalid ranking type")
	ErrInvalidSeason          = errors.New("mg: invalid season")
	ErrInvalidSort            = errors.New("mg: invalid sort")
	ErrInvalidStatus          = errors.New("mg: invalid status")
	ErrInvalidScore           = errors.New("mg: invalid score")
	ErrInvalidPriority        = errors.New("mg: invalid priority")
	ErrInvalidRewatchValue    = errors.New("mg: invalid rewatch value")
	ErrInvalidRereadValue     = errors.New("mg: invalid reread value")
	ErrEmptySearchString      = errors.New("mg: invalid search string (empty string)")
	ErrInvalidYear            = errors.New("mg: invalid year (not integer)")
	ErrUnknownUpdateParam     = errors.New("mg: unknown update param")
	ErrAnimeNotInList         = errors.New("mg: anime is already not in list")
	ErrClientAuthNotSupported = errors.New("mg: function does not support client auth")
)
View Source
var DefaultAnimeFields []string = []string{
	"id",
	"title",
	"main_picture",
	"alternative_titles",
	"start_date",
	"end_date",
	"synopsis",
	"mean",
	"rank",
	"popularity",
	"num_list_users",
	"num_scoring_users",
	"nsfw",
	"created_at",
	"updated_at",
	"media_type",
	"status",
	"genres",
	"my_list_status",
	"list_status",
	"num_episodes",
	"start_season",
	"broadcast",
	"source",
	"average_episode_duration",
	"rating",
	"pictures",
	"background",
	"related_anime",
	"related_manga",
	"recommendations",
	"studios",
	"statistics",
}
View Source
var DefaultMangaFields []string = []string{
	"id",
	"title",
	"main_picture",
	"alternative_titles",
	"start_date",
	"end_date",
	"synopsis",
	"mean",
	"rank",
	"popularity",
	"num_list_users",
	"num_scoring_users",
	"nsfw",
	"created_at",
	"updated_at",
	"media_type",
	"status",
	"genres",
	"my_list_status",
	"num_volumes",
	"num_chapters",
	"authors{first_name,last_name}",
	"pictures",
	"background",
	"related_anime",
	"related_manga",
	"recommendations",
	"serialization",
}

Functions

This section is empty.

Types

type AltTitles

type AltTitles struct {
	Synonyms      []string `json:"synonyms"`
	EnglishTitle  string   `json:"en"`
	JapaneseTitle string   `json:"ja"`
}

type Anime

type Anime struct {
	Id              int                   `json:"id"`
	Title           string                `json:"title"`
	MainPicture     Picture               `json:"main_picture"`
	AltTitles       AltTitles             `json:"alternative_titles"`
	StartDate       string                `json:"start_date"`
	EndDate         string                `json:"end_date"`
	Synopsis        string                `json:"synopsis"`
	MeanScore       float32               `json:"mean"`
	Rank            int                   `json:"rank"`
	Popularity      int                   `json:"popularity"`
	NumListUsers    int                   `json:"num_list_users"`
	NumScoringUsers int                   `json:"num_scoring_users"`
	NSFWStatus      string                `json:"nsfw"`
	CreatedAt       string                `json:"created_at"`
	UpdatedAt       string                `json:"updated_at"`
	MediaType       string                `json:"media_type"`
	Status          string                `json:"status"`
	Genres          []Genre               `json:"genres"`
	MyListStatus    AnimeListStatus       `json:"my_list_status"`
	ListStatus      AnimeListStatus       `json:"list_status"`
	NumEpisodes     int                   `json:"num_episodes"`
	Season          Season                `json:"start_season"`
	Broadcast       Broadcast             `json:"broadcast"`
	Source          string                `json:"source"`
	DurationSeconds int                   `json:"average_episode_duration"`
	ParentalRating  string                `json:"rating"`
	Pictures        []Picture             `json:"pictures"`
	Background      string                `json:"background"`
	RelatedAnime    []RelatedAnime        `json:"related_anime"`
	Recommendations []AnimeRecommendation `json:"recommendations"`
	Studios         []Studio              `json:"studios"`
	Statistics      AnimeStatistics       `json:"statistics"`
}

type AnimeListStatus

type AnimeListStatus struct {
	EpWatched      int  `json:"num_episodes_watched"`
	IsRewatching   bool `json:"is_rewatching"`
	TimesRewatched int  `json:"num_times_rewatched"`
	RewatchValue   int  `json:"rewatch_value"`
	// contains filtered or unexported fields
}

type AnimeRecommendation

type AnimeRecommendation struct {
	Anime            Anime `json:"node"`
	TimesRecommended int   `json:"num_recommendations"`
}

type AnimeStatistics

type AnimeStatistics struct {
	NumListUsers int              `json:"num_list_users"`
	Status       StatusStatistics `json:"status"`
}

type AnimeUpdateResponse

type AnimeUpdateResponse struct {
	Status         string `json:"status"`
	Score          int    `json:"score"`
	EpWatched      int    `json:"num_episodes_watched"`
	IsRewatching   bool   `json:"is_rewatching"`
	StartDate      string `json:"start_date"`
	FinishDate     string `json:"finish_date"`
	Priority       string `json:"priority"`
	TimesRewatched int    `json:"num_times_rewatched"`
	RewatchValue   int    `json:"rewatch_value"`
	Tags           string `json:"tags"`
	Comments       string `json:"comments"`
	UpdatedAt      string `json:"updated_at"`
}

type Author

type Author struct {
	Details struct {
		Id        int    `json:"id"`
		FirstName string `json:"first_name"`
		LastName  string `json:"last_name"`
	} `json:"node"`
	Role string `json:"role"`
}

type Broadcast

type Broadcast struct {
	Day  string `json:"day_of_the_week"`
	Time string `json:"start_time"`
}

type Client

type Client struct {
	MainAuth       string
	ClientAuth     string
	ClientAuthOnly bool
	// contains filtered or unexported fields
}

func (Client) DeleteAnime

func (c Client) DeleteAnime(id int) error

func (Client) DeleteManga

func (c Client) DeleteManga(id int) error

func (Client) GetAnimeById

func (c Client) GetAnimeById(anime *Anime, id int, fields []string) error

func (Client) GetAnimeList

func (c Client) GetAnimeList(animes *[]Anime, params *ListParams) (bool, error)

func (Client) GetAnimeRanking

func (c Client) GetAnimeRanking(animes *[]RankedAnime, params *RankingParams) error

func (Client) GetMangaById

func (c Client) GetMangaById(manga *Manga, id int, fields []string) error

func (Client) GetMangaList

func (c Client) GetMangaList(mangas *[]Manga, params *ListParams) (bool, error)

func (Client) GetMangaRanking

func (c Client) GetMangaRanking(mangas *[]RankedManga, params *RankingParams) error

func (Client) GetSeasonalAnime

func (c Client) GetSeasonalAnime(animes *[]Anime, params *SeasonalParams) error

func (Client) GetSelfInfo

func (c Client) GetSelfInfo(user *User, getStatistics bool) error

func (Client) GetSuggestedAnime

func (c Client) GetSuggestedAnime(animes *[]Anime, params *SuggestedParams) error

func (Client) SearchAnime

func (c Client) SearchAnime(animes *[]Anime, params *SearchParams) error

func (Client) SearchManga

func (c Client) SearchManga(mangas *[]Manga, params *SearchParams) error

func (Client) UpdateAnime

func (c Client) UpdateAnime(res *AnimeUpdateResponse, id int, params map[string]interface{}) error

func (Client) UpdateManga

func (c Client) UpdateManga(res *MangaUpdateResponse, id int, params map[string]interface{}) error

type Genre

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

type ListParams

type ListParams struct {
	Username string
	Status   string
	Sort     string
	Limit    int
	Offset   int
	NSFW     bool
	Fields   []string
}

func ListParamsNew

func ListParamsNew() *ListParams

type MALError

type MALError struct {
	Err string `json:"error"`
	Msg string `json:"message"`
}

type Magazine

type Magazine struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type Manga

type Manga struct {
	Id              int                   `json:"id"`
	Title           string                `json:"title"`
	MainPicture     Picture               `json:"main_picture"`
	AltTitles       AltTitles             `json:"alternative_titles"`
	StartDate       string                `json:"start_date"`
	EndDate         string                `json:"end_date"`
	Synopsis        string                `json:"synopsis"`
	MeanScore       float32               `json:"mean"`
	Rank            int                   `json:"rank"`
	Popularity      int                   `json:"popularity"`
	NumListUsers    int                   `json:"num_list_users"`
	NSFWStatus      string                `json:"nsfw"`
	Genres          []Genre               `json:"genres"`
	CreatedAt       string                `json:"created_at"`
	UpdatedAt       string                `json:"updated_at"`
	MediaType       string                `json:"media_type"`
	Status          string                `json:"status"`
	MyListStatus    MangaListStatus       `json:"my_list_status"`
	ListStatus      MangaListStatus       `json:"list_status"`
	NumVolumes      int                   `json:"num_volumes"`
	NumChapters     int                   `json:"num_chapters"`
	Authors         []Author              `json:"authors"`
	Pictures        []Picture             `json:"pictures"`
	Background      string                `json:"background"`
	RelatedAnime    []RelatedAnime        `json:"related_anime"`
	RelatedManga    []RelatedManga        `json:"related_manga"`
	Recommendations []MangaRecommendation `json:"recommendations"`
	Serialization   []Serialization       `json:"serialization"`
}

type MangaListStatus

type MangaListStatus struct {
	VolumesRead  int  `json:"num_volumes_read"`
	ChaptersRead int  `json:"num_chapters_read"`
	IsRereading  bool `json:"is_rereading"`
	TimesReread  int  `json:"num_times_reread"`
	RereadValue  int  `json:"reread_value"`
	// contains filtered or unexported fields
}

type MangaRecommendation

type MangaRecommendation struct {
	Manga            Anime `json:"node"`
	TimesRecommended int   `json:"num_recommendations"`
}

type MangaUpdateResponse

type MangaUpdateResponse struct {
	Status       string `json:"status"`
	Score        int    `json:"score"`
	VolumesRead  int    `json:"num_volumes_read"`
	ChaptersRead int    `json:"num_chapters_read"`
	IsRereading  bool   `json:"is_rereading"`
	StartDate    string `json:"start_date"`
	FinishDate   string `json:"finish_date"`
	Priority     string `json:"priority"`
	TimesReread  int    `json:"num_times_reread"`
	RereadValue  int    `json:"reread_value"`
	Tags         string `json:"tags"`
	Comments     string `json:"comments"`
	UpdatedAt    string `json:"updated_at"`
}

type Picture

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

type RankedAnime

type RankedAnime struct {
	Anime
	RankNum int
}

type RankedManga

type RankedManga struct {
	Manga
	RankNum int
}

type RankingParams

type RankingParams struct {
	Limit  int
	Offset int
	NSFW   bool
	Fields []string

	RankingType string
}

func RankingParamsNew

func RankingParamsNew() *RankingParams

type RelatedAnime

type RelatedAnime struct {
	Anime                 Anime  `json:"node"`
	RelationType          string `json:"relation_type"`
	RelationTypeFormatted string `json:"relation_type_formatted"`
}

type RelatedManga

type RelatedManga struct {
	Manga                 Manga  `json:"node"`
	RelationType          string `json:"relation_type"`
	RelationTypeFormatted string `json:"relation_type_formatted"`
}

type SearchParams

type SearchParams struct {
	Limit  int
	Offset int
	NSFW   bool
	Fields []string

	SearchString string
}

func SearchParamsNew

func SearchParamsNew() *SearchParams

type Season

type Season struct {
	Year int    `json:"year"`
	Name string `json:"season"`
}

type SeasonalParams

type SeasonalParams struct {
	Limit  int
	Offset int
	NSFW   bool
	Fields []string

	Year   string
	Season string
	Sort   string
}

func SeasonalParamsNew

func SeasonalParamsNew() *SeasonalParams

type Serialization

type Serialization struct {
	Magazine Magazine `json:"node"`
	Name     string   `json:"name"`
}

type StatusStatistics

type StatusStatistics struct {
	Watching    int `json:"watching"`
	Completed   int `json:"completed"`
	OnHold      int `json:"on_hold"`
	Dropped     int `json:"dropped"`
	PlanToWatch int `json:"plan_to_watch"`
}

type Studio

type Studio struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type SuggestedParams

type SuggestedParams struct {
	Limit  int
	Offset int
	NSFW   bool
	Fields []string
}

func SuggestedParamsNew

func SuggestedParamsNew() *SuggestedParams

type User

type User struct {
	Id              int                 `json:"id"`
	Name            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"`
	IsSupporter     bool                `json:"is_supporter"`
	AnimeStatistics UserAnimeStatistics `json:"anime_statistics"`
}

type UserAnimeStatistics

type UserAnimeStatistics struct {
	NumWatching    int     `json:"num_items_watching"`
	NumCompleted   int     `json:"num_items_completed"`
	NumOnHold      int     `json:"num_items_on_hold"`
	NumDropped     int     `json:"num_items_dropped"`
	NumPlanned     int     `json:"num_items_plan_to_watch"`
	TotalAnimes    int     `json:"num_items"`
	DaysWatched    float32 `json:"num_days_watched"`
	DaysWatching   float32 `json:"num_days_watching"`
	DaysCompleted  float32 `json:"num_days_completed"`
	DaysOnHold     float32 `json:"num_days_on_hold"`
	DaysDropped    float32 `json:"num_days_dropped"`
	TotalDays      float32 `json:"num_days"`
	TotalEpisodes  int     `json:"num_episodes"`
	TimesRewatched int     `json:"num_times_rewatched"`
	MeanScore      float32 `json:"mean_score"`
}

Jump to

Keyboard shortcuts

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