diff options
-rw-r--r-- | README.md | 18 | ||||
-rw-r--r-- | anime/README.md | 151 | ||||
-rw-r--r-- | manga/README.md | 104 | ||||
-rw-r--r-- | user/README.md | 33 | ||||
-rw-r--r-- | user/anime/README.md | 174 | ||||
-rw-r--r-- | user/manga/README.md | 185 |
6 files changed, 4 insertions, 661 deletions
@@ -1,19 +1,9 @@ # MAL2Go MyAnimeList V2 API wrapper for GoLang -## Installation -MAL2Go is divided into multiple packages. Each package needs to be installed manually. -In a terminal, run -``` fish -go get github.com/MikunoNaka/MAL2Go/v2/anime -go get github.com/MikunoNaka/MAL2Go/v2/manga -go get github.com/MikunoNaka/MAL2Go/v2/user -go get github.com/MikunoNaka/MAL2Go/v2/user/anime -go get github.com/MikunoNaka/MAL2Go/v2/user/manga -``` -To install the packages you'd usually need. To find out more about what each package does, refer to [Package Structure](#Package-Structure) - -Go needs to be installed and `$GOPATH` should be set up +## How to use + +Documentation is on my website: <https://vidhukant.xyz/docs/mal2go/> ## Package Structure [anime](anime) package @@ -54,8 +44,6 @@ way to generate a token is to use [my script](https://github.com/MikunoNaka/mal- Each package has a Client struct that needs an `AuthToken: string` among other (optional) values that don't do anything yet. -**NOTE:** I'm new to OAuth and might make changes to the Client struct in each package. - ## Licence Licenced under GNU General Public Licence diff --git a/anime/README.md b/anime/README.md index 84c3cf1..46d7c2c 100644 --- a/anime/README.md +++ b/anime/README.md @@ -3,157 +3,6 @@ MAL2Go `anime` package has functionality related to getting data about anime. To *update* anime status (score, status, etc) refer to [`user/anime`](../user/anime) package. -## Installation -In a terminal, run -``` fish -go get "github.com/MikunoNaka/MAL2Go/v2/anime" -``` - -## Usage -Firstly, import this package and instanciate the client. -``` go -import ( - "github.com/MikunoNaka/MAL2Go/v2/anime" -) -``` - -Now instanciate with -``` go -myClient := anime.Client { - AuthToken: "Bearer " + yourTokenHere, -} -``` - -- ### Searching for an anime -``` go -searchString := "mushishi" // your search string here - -// max amount of results to pull. Max is 500 -limit := 10 - -// if the offset is 2 it will skip the first 2 results, then pull the next 10 -offset := 0 - -// the API by default only returns some basic data -// you can specify some fields as a []string slice. -// it will return the default fields even if they aren't specified -fields := []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_episodes", - "start_season", "broadcast", "source", - "average_episode_duration", "rating", - "pictures", "background", "related_anime", - "related_manga", "recommendations", - "studios", "statistics", -} // for all default fields fields := []string{} will also work - -// finally making the API request -searchResults, err := myClient.SearchAnime(searchString, limit, offset, fields) - -fmt.Println(searchResults.Animes) // print list of the search results -``` - -- ### Getting an anime's info -Each anime on MyAnimeList has a unique ID, which you need to find it - -Refer to [anime.structs.go](anime.structs.go) to find out all the keys the Anime struct has - -``` go -animeId := 42351 -fields := []string{} // pull every field - -anime, err := myClient.GetAnimeById(animeId, fields) -if err != nil { - fmt.Println(err) -} - -fmt.Println(anime.Title, anime.MeanScore, anime.ListStatus.Status) -``` - -- ### Get anime ranking -Ranking is a list of anime sorted by their rank - -Possible ranking types are: -- `all` -- `airing` -- `upcoming` -- `tv` -- `ova` -- `movie` -- `special` -- `bypopularity` -- `favorite` - -``` go -rankingType := "favorite" -limit, offset := 10, 0 -fields := []string{"title"} - -ranking, err := myClient.GetAnimeRanking(rankingType, limit, offset, fields) - -// loop over the array of animes returned by the API -for _, anime := range ranking.Animes { - fmt.Printf("Title: %s, Rank Number: %d", anime.Title, anime.RankNum) -} -``` - -- ### Get seasonal anime -Get a list of anime from a particular season/year - -Possible seasons are: -- `winter` -- `spring` -- `summer` -- `fall` - -Possible ways to sort are: -- `anime_score` -- `anime_num_list_users` - -``` go -year := "2021" -season := "winter" -sort := "anime_score" - -limit, offset := 10, 0 - -fields := []string{"title"} - -seasonalAnime, err := myClient.GetSeasonalAnime(year, season, sort, limit, offset, fields) -if err != nil { - fmt.Println(err) -} - -for _, anime := range seasonalAnime.Animes { - fmt.Println(anime.Title) -} - -fmt.Println(seaonalAnime.Season) -``` - -- ### Get suggested anime -Returns suggestions related to the authenticated user - -``` go -limit, offset := 10, 0 -fields := []string{"title"} - -suggestedAnime, err := myClient.GetSuggestedAnime(limit, offset, fields) -if err != nil { - fmt.Println(err) -} - -for _, anime := range suggestedAnime.Animes { - fmt.Println(anime.Titile) -} - -``` - ## Structure - [anime.go](anime.go) Contains all the exported functions for pulling data from the API. diff --git a/manga/README.md b/manga/README.md index f3ad654..43c47b7 100644 --- a/manga/README.md +++ b/manga/README.md @@ -3,110 +3,6 @@ MAL2Go `manga` package has functionality related to getting data about manga. To *update* manga status (score, status, etc) refer to [`user/manga`](../user/manga) package. -## Installation -In a terminal, run -``` fish -go get "github.com/MikunoNaka/MAL2Go/v2/manga" -``` - -## Usage -Firstly, import this package and instanciate the client. -``` go -import ( - "github.com/MikunoNaka/MAL2Go/v2/manga" -) -``` - -Now instanciate with -``` go -myClient := manga.Client { - AuthToken: "Bearer " + yourTokenHere, -} -``` - -- ### Searching for a manga -``` go -searchString := "kanojo okarishimasu" // your search string here - -// max amount of results to pull. Max is 500 -limit := 10 - -// if the offset is 2 it will skip the first 2 results, then pull the next 10 -offset := 0 - -// the API by default only returns some basic data -// you can specify some fields as a []string slice. -// it will return the default fields even if they aren't specified -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", "media_type", - "status", "genres", "my_list_status", - "num_volumes", "num_chapters", "authors", - "pictures", "background", "related_anime", - "related_manga", "recommendations", "serialization", -} // for all default fields fields := []string{} will also work - -// finally making the API request -searchResults, err := myClient.SearchManga(searchString, limit, offset, fields) - -// searchResults.Mangas is a list of all the Mangas returned by the API as search results -// print list of the search results -for _, manga := range searchResults.Mangas { - fmt.Println(manga.Title) -} - -// results have page numbers -fmt.Println(searchResults.Paging.NextPage, searchResults.Paging.PrevPage) -``` - -- ### Getting a manga's info -Each manga on MyAnimeList has a unique ID, which you need to find it - -``` go -mangaId := 108407 -fields := []string{} // pull every field - -manga, err := myClient.GetMangaById(mangaId, fields) -if err != nil { - fmt.Println(err) -} - -fmt.Println(manga.Title, manga.MeanScore, manga.ListStatus.Status) -``` - -- ### Get manga ranking -Ranking is a list of mangas sorted by their rank - -Possible ranking types are: -- `all` -- `manga` -- `novels` -- `oneshots` -- `doujin` -- `manhwa` -- `manhua` -- `bypopularity` -- `favorite` - -``` go -rankingType := "favorite" -limit, offset := 10, 0 -fields := []string{"title"} - -ranking, err := myClient.GetMangaRanking(rankingType, limit, offset, fields) - -// loop over the array mangas returned by the API -for _, manga := range ranking.Mangas { - fmt.Printf("Title: %s, Rank Number: %d", manga.Title, manga.RankNum) -} - -// ranking lists have page numbers -fmt.Println(ranking.Paging.NextPage, ranking.Paging.PrevPage) -``` - ## Structure - [manga.go](anime.go) Contains all the exported functions for pulling data from the API. diff --git a/user/README.md b/user/README.md index 2717835..ba76847 100644 --- a/user/README.md +++ b/user/README.md @@ -1,39 +1,6 @@ # MAL2Go/user MAL2Go `user` package has functionality related to getting data about the authenticated user. -## Usage -Firstly, import this package and instanciate the client. -``` go -import ( - "github.com/MikunoNaka/MAL2Go/v2/user" -) -``` - -Now instanciate with -``` go -myClient := user.Client { - AuthToken: "Bearer " + yourTokenHere, -} -``` - -- ### Get authenticated user's info -``` go -userData := myClient.GetSelfUserInfo() - -fmt.Println(userData.Name, userData.Picture) -``` - -The `User` datatype has the following fields: -- `Id` `int` -- `Name` `string` -- `Picture` `string` -- `Gender` `string` -- `Birthday` `string` -- `Location` `string` -- `JoinedAt` `string` -- `TimeZone` `string` -- `IsSupporter` `bool` - ## Structure - [user.go](user.go) Contains all the exported functions for pulling data from the API. diff --git a/user/anime/README.md b/user/anime/README.md index 4b8bfe8..df3449f 100644 --- a/user/anime/README.md +++ b/user/anime/README.md @@ -3,180 +3,6 @@ MAL2Go `user/anime` package has functionality related to updating the user's ani To *get* anime data, refer to the [`anime`](../../anime) package. -**There are multiple possible server responses and errors currently haven't been implemented yet.** - -## Installation -In a terminal, run -``` fish -go get "github.com/MikunoNaka/MAL2Go/v2/user/anime" -``` - -## Usage -Firstly, import this package and instanciate the client. -``` go -import ( - "github.com/MikunoNaka/MAL2Go/v2/user/anime" -) -``` - -Now instanciate with -``` go -myClient := anime.Client { - AuthToken: "Bearer " + yourTokenHere, -} -``` - -- ### Delete an anime from user's anime list -``` go -animeId := 457 // anime's ID - -resp := myClient.DeleteAnime(animeId) - -/* if anime is successfully deleted, resp is 200 - * if anime isn't in the list resp is 404 */ -fmt.Println(resp) -``` - -- ### Get user's anime list -Possible statuses are: -- `watching` -- `completed` -- `on_hold` -- `dropped` -- `plan_to_watch` - -Leaving blank (`""`) gets all the anime - -Possible sorts are: -- `list_score` -- `list_updated_at` -- `anime_title` -- `anime_start_date` -- `anime_id` (beta) - -Leaving user blank (`""`) or as `"@me"` returns the authenticated user's list - -``` go -user := "0ZeroTsu" -status := "watching" -sort := "list_score" - -limit := 1000 // max is 1000 -offset := 0 - -// fields := []string{} means get all the fields -fields := []string{"title"} - -animeList, err := myClient.GetAnimeList(user, status, sort, limit, offset, fields) -if err != nil { - fmt.Println(err) -} - -// animeList.Animes is an array of the animes in the list -for _, anime := range animeList.Animes { - fmt.Println(anime.Title) -} - -fmt.Println(animeList.Paging.NextPage, animeList.Paging.PrevPage) -``` - -- ### Set an anime's status -``` go -animeId := 457 // anime's ID -status := "dropped" -resp, _ := myClient.SetStatus(animeId, status) -fmt.Println(resp.Error, resp.Message) -``` - -- ### Set watched episodes -``` go -animeId := 457 // anime's ID -epWatched := 22 -resp, _ := myClient.SetWatchedEpisodes(animeId, epWatched) -fmt.Println(resp.Error, resp.Message) -``` - -- ### Set is rewatching status -``` go -animeId := 457 // anime's ID -isRewatching := true -_, _ := myClient.SetIsRewatching(animeId, isRewatching) -``` - -- ### Set an anime's score -``` go -animeId := 457 // anime's ID -score := 10 -_, _ := myClient.SetScore(animeId, score) -``` - -- ### Set an anime's priority -Priority on MyAnimeList ranges from 0 to 2 -``` go -animeId := 457 // anime's ID -priority := 2 -_, _ := myClient.SetPriority(animeId, priority) -``` - -- ### Set an anime's rewatch value -Rewatch value on MyAnimeList ranges from 0 to 5 -``` go -animeId := 457 // anime's ID -rewatchValue := 4 -_, _ := myClient.SetRewatchValue(animeId, rewatchValue) -``` - -- ### Set an anime's rewatch count -Number of times user has rewatched the anime. There is no limit -``` go -animeId := 457 // anime's ID -rewatchCount := 69 -_, _ := myClient.SetRewatchCount(animeId, rewatchCount) -``` - -- ### Set an anime's tags -``` go -animeId := 457 // anime's ID -tags := "tags" -_, _ := myClient.UpdateTags(animeId, tags) -``` - -- ### Set an anime's comments -``` go -animeId := 457 // anime's ID -comments := "I love this" -_, _ := myClient.UpdateComments(animeId, comments) -``` - -- ### Update all fields of an anime -WARNING: this function can overwrite any data and set it to null -if you don't specify a value to it. - -Refrain/use it carefully to avoid data loss. - -``` go -updateData := anime.UpdateAnimeData { - Status: "watching", - IsRewatching: true, - Score: 10, - EpWatched: 22, - Priority: 2, - TimesRewatched: 69, - RewatchValue: 4, - Tags: "tags", - Comments: "I love this", -} - -animeId := 457 // anime's ID - -resp, err := myClient.UpdateAnime(animeId, updateData) -if err != nil { - fmt.Println(err) -} - -fmt.Println(resp.Error, resp.Message) -``` - ## Structure - [animelist.go](animelist.go) Contains the exported functions to do some basic functions with anime lists. diff --git a/user/manga/README.md b/user/manga/README.md index 01fc8f0..cc93d9a 100644 --- a/user/manga/README.md +++ b/user/manga/README.md @@ -1,190 +1,7 @@ # MAL2Go/user/manga MAL2Go `user/manga` package has functionality related to updating the user's manga list. -To *get* anime data, refer to the [`manga`](../../manga) package. - -**There are multiple possible server responses and errors currently haven't been implemented yet.** - -## Installation -In a terminal, run -``` fish -go get "github.com/MikunoNaka/MAL2Go/v2/user/manga" -``` - -## Usage -Firstly, import this package and instanciate the client. -``` go -import ( - "github.com/MikunoNaka/MAL2Go/v2/user/manga" -) -``` - -Now instanciate with -``` go -myClient := manga.Client { - AuthToken: "Bearer " + yourTokenHere, -} -``` - -- ### Delete a manga from user's anime list -``` go -mangaId := 108407 // manga's ID - -resp := myClient.DeleteManga(mangaId) - -/* if manga is successfully deleted, resp is 200 - * if manga isn't in the list resp is 404 */ -fmt.Println(resp) -``` - -- ### Get user's manga list -Possible statuses are: -- `reading` -- `completed` -- `on_hold` -- `dropped` -- `plan_to_watch` - -Leaving blank (`""`) gets all the anime - -Possible sorts are: -- `list_score` -- `list_updated_at` -- `manga_title` -- `manga_start_date` -- `manga_id` (beta) - -Leaving user blank (`""`) or as `"@me"` returns the authenticated user's list - -``` go -user := "0ZeroTsu" -status := "reading" -sort := "list_score" - -limit := 1000 // max is 1000 -offset := 0 - -// fields := []string{} means get all the fields -fields := []string{"title"} - -mangaList, err := myClient.GetMangaList(user, status, sort, limit, offset, fields) -if err != nil { - fmt.Println(err) -} - -// mangaList.Mangas is an array of the mangas in the list -for _, manga := range mangaList.Mangas { - fmt.Println(manga.Title) -} - -fmt.Println(mangaList.Paging.NextPage, mangaList.Paging.PrevPage) -``` - -- ### Set a manga's status -``` go -mangaId := 108407 // manga's ID -status := "dropped" -resp, _ := myClient.SetStatus(mangaId, status) -fmt.Println(resp.Error, resp.Message) -``` - -- ### Set read volumes -``` go -mangaId := 108407 // manga's ID -volumesRead := 10 -resp, _ := myClient.SetVolumesRead(mangaId, volumesRead) -fmt.Println(resp.Error, resp.Message) -``` - -- ### Set read chapters -``` go -mangaId := 108407 // manga's ID -chaptersRead := 150 -resp, _ := myClient.SetChaptersread(mangaId, chaptersRead) -fmt.Println(resp.Error, resp.Message) -``` - -- ### Set is rereading status -``` go -mangaId := 108407 // manga's ID -isRereading := true -_, _ := myClient.SetIsRereading(mangaId, isRereading) -``` - -- ### Set a manga's score -``` go -mangaId := 108407 // manga's ID -score := 1 -_, _ := myClient.SetScore(mangaId, score) -``` - -- ### Set a manga's priority -Priority on MyAnimeList ranges from 0 to 2 -``` go -mangaId := 108407 // manga's ID -priority := 2 -_, _ := myClient.SetPriority(mangaId, priority) -``` - -- ### Set a manga's reread value -Reread value on MyAnimeList ranges from 0 to 5 -``` go -mangaId := 108407 // manga's ID -rereadValue := 4 -_, _ := myClient.SetRereadValue(mangaId, rereadValue) -``` - -- ### Set a manga's reread count -Number of times user has reread the manga. There is no limit -``` go -mangaId := 108407 // manga's ID -rereadCount := 69 -_, _ := myClient.SetRereadCount(mangaId, rereadCount) -``` - -- ### Set a manga's tags -``` go -mangaId := 108407 // manga's ID -tags := "tags" -_, _ := myClient.UpdateTags(mangaId, tags) -``` - -- ### Set a manga's comments -``` go -mangaId := 108407 // manga's ID -comments := "I hate but love this" -_, _ := myClient.UpdateComments(mangaId, comments) -``` - -- ### Update all fields of a manga -WARNING: this function can overwrite any data and set it to null -if you don't specify a value to it. - -Refrain/use it carefully to avoid data loss. - -``` go -updateData := manga.UpdateMangaData { - Status: "dropped", - IsRereading: true, - Score: 1, - VolumesRead: 10, - ChaptersRead: 150, - Priority: 2, - TimesReread: 69, - RereadValue: 4, - Tags: "tags", - Comments: "I hate but love this", -} - -mangaId := 108407 // manga's ID - -resp, err := myClient.UpdateManga(mangaId, updateData) -if err != nil { - fmt.Println(err) -} - -fmt.Println(resp.Error, resp.Message) -``` +To *get* manga data, refer to the [`manga`](../../manga) package. ## Structure - [mangalist.go](mangalist.go) |