From fdd266052a6f64e67712a0bffdfca5469bef23c7 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 21 Sep 2022 20:02:49 +0530 Subject: added MAL2Go/user/anime docs --- content/docs/mal2go/v4/user/anime/_index.md | 3 -- content/docs/mal2go/v4/user/anime/delete-anime.md | 44 ++++++++++++++++ .../docs/mal2go/v4/user/anime/get-anime-list.md | 53 +++++++++++++++++++ content/docs/mal2go/v4/user/anime/set-priority.md | 48 +++++++++++++++++ .../docs/mal2go/v4/user/anime/set-rewatch-count.md | 41 +++++++++++++++ .../docs/mal2go/v4/user/anime/set-rewatch-value.md | 51 ++++++++++++++++++ .../mal2go/v4/user/anime/set-rewatching-status.md | 42 +++++++++++++++ content/docs/mal2go/v4/user/anime/set-score.md | 41 +++++++++++++++ content/docs/mal2go/v4/user/anime/set-status.md | 41 +++++++++++++++ .../mal2go/v4/user/anime/set-watched-episodes.md | 41 +++++++++++++++ content/docs/mal2go/v4/user/anime/setting-up.md | 34 ++++++++++++ content/docs/mal2go/v4/user/anime/types.md | 36 +++++++++++++ content/docs/mal2go/v4/user/anime/update-anime.md | 60 ++++++++++++++++++++++ .../docs/mal2go/v4/user/anime/update-comments.md | 41 +++++++++++++++ content/docs/mal2go/v4/user/anime/update-tags.md | 41 +++++++++++++++ content/docs/mal2go/v4/user/manga/_index.md | 2 - 16 files changed, 614 insertions(+), 5 deletions(-) create mode 100644 content/docs/mal2go/v4/user/anime/delete-anime.md create mode 100644 content/docs/mal2go/v4/user/anime/get-anime-list.md create mode 100644 content/docs/mal2go/v4/user/anime/set-priority.md create mode 100644 content/docs/mal2go/v4/user/anime/set-rewatch-count.md create mode 100644 content/docs/mal2go/v4/user/anime/set-rewatch-value.md create mode 100644 content/docs/mal2go/v4/user/anime/set-rewatching-status.md create mode 100644 content/docs/mal2go/v4/user/anime/set-score.md create mode 100644 content/docs/mal2go/v4/user/anime/set-status.md create mode 100644 content/docs/mal2go/v4/user/anime/set-watched-episodes.md create mode 100644 content/docs/mal2go/v4/user/anime/setting-up.md create mode 100644 content/docs/mal2go/v4/user/anime/types.md create mode 100644 content/docs/mal2go/v4/user/anime/update-anime.md create mode 100644 content/docs/mal2go/v4/user/anime/update-comments.md create mode 100644 content/docs/mal2go/v4/user/anime/update-tags.md (limited to 'content/docs/mal2go/v4') diff --git a/content/docs/mal2go/v4/user/anime/_index.md b/content/docs/mal2go/v4/user/anime/_index.md index 0728945..4e48940 100644 --- a/content/docs/mal2go/v4/user/anime/_index.md +++ b/content/docs/mal2go/v4/user/anime/_index.md @@ -5,6 +5,3 @@ weight: 3 --- The `MAL2Go/user/anime` package supports updating the currently authenticated user's anime list along with reading the anime lists of the current user as well as other users. - - -## coming soon! diff --git a/content/docs/mal2go/v4/user/anime/delete-anime.md b/content/docs/mal2go/v4/user/anime/delete-anime.md new file mode 100644 index 0000000..b3476cb --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/delete-anime.md @@ -0,0 +1,44 @@ +--- +title: "Delete Anime" +description: "Delete an anime from the user's animelist" +weight: 3 +--- + +Use the `DeleteAnime` method to remove an entry from the user's animelist. +This method takes these arguments: + +- `id int` ID of the anime + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.DeleteAnime(50172) + if err != nil { + log.Fatal(err) + } + + if res == "200" { + fmt.Println("Anime successfully deleted from your list") + } else { + fmt.Println("Something went wrong. Is the anime even in your list?") + } +} +``` + +The above example deletes "Summertime Render" from your list + +This method returns `"200"` on a successful attempt in deleting the anime from your list. It returns `"404"` if the anime is not in your list. diff --git a/content/docs/mal2go/v4/user/anime/get-anime-list.md b/content/docs/mal2go/v4/user/anime/get-anime-list.md new file mode 100644 index 0000000..22f6f4a --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/get-anime-list.md @@ -0,0 +1,53 @@ +--- +title: "Get anime list" +description: "Get an arbitrary user's animelist" +weight: 2 +--- + +Use the `GetAnimeList` method to get the animelist of a user. +This method takes these arguments: + +- `username string` Username of the user to get animelist of. An empty string or `"@me"` will return the logged-in user's list +- `status string` Status of the animes, accepted values are `watching`, `completed`, `on_hold`, `dropped` and `plan_to_watch` +- `sort string` How to sort the list, accepted values are `list_score`, `list_updated_at`, `anime_title`, `anime_start_date` and `anime_id` +- `limit int` Limit of results to pull, Max is 1000 +- `offset int` Offset for the results +- `nsfw bool` To include NSFW elements or not +- `fields []string` Specify which fields to get for each anime. [List of valid fields](/docs/mal2go/v4/anime/types/#mal2goanimeanime) + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + animeList, nextPageExists, err := myClient.GetAnimeList("0ZeroTsu", "completed", "list_score", 1000, 0, true, []string{"title"}) + if err != nil { + log.Fatal(err) + } + + for _, i := range animeList { + fmt.Println(i.Title) + } + + if nextPageExists { + fmt.Println("This user has even more animes in their animelist.") + fmt.Println("Please increase the offset to look at the hidden entries.") + } +} +``` + +The above example prints the first 1000 entries from 0ZeroTsu's (mine) completed anime list. +If the list has more than 1000 items, the `nextPageExists` becomes true, which can be used to show +a notice like this, or maybe append the remaining items to animeList by calling `anime.GetAnimeList` with a higher offset. diff --git a/content/docs/mal2go/v4/user/anime/set-priority.md b/content/docs/mal2go/v4/user/anime/set-priority.md new file mode 100644 index 0000000..50788f1 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/set-priority.md @@ -0,0 +1,48 @@ +--- +title: "Set Priority" +description: "Set Priority of The Anime" +weight: 9 +--- + +Use the `SetPriority` method to set the priority of the anime. +This method takes these arguments: + +- `id int` ID of the anime +- `priority int` Self explanatory + +The accepted values for priority are integers 1 to 2. Each meaning: + +0. Low +1. Medium +2. High + + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.SetPriority(47194, 2) + if err != nil { + log.Fatal(err) + } + + fmt.Println("Priority has been set to", res.Priority) +} +``` + +The above example sets the priority of "Summertime Render" to 2 (High). + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/set-rewatch-count.md b/content/docs/mal2go/v4/user/anime/set-rewatch-count.md new file mode 100644 index 0000000..0f11590 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/set-rewatch-count.md @@ -0,0 +1,41 @@ +--- +title: "Set Rewatch Count" +description: "Set times rewatched" +weight: 10 +--- + +Use the `SetRewatchCount` method to set the number of times the user has rewatched this anime. +This method takes these arguments: + +- `id int` ID of the anime +- `rewatchCount int` Self explanatory + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.SetRewatchCount(47194, 2) + if err != nil { + log.Fatal(err) + } + + fmt.Println("You have rewatched this anime", res.TimesRewatched, "times.") +} +``` + +The above example sets the number of times rewatched for "Summertime Render" to 2. + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/set-rewatch-value.md b/content/docs/mal2go/v4/user/anime/set-rewatch-value.md new file mode 100644 index 0000000..10e0b76 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/set-rewatch-value.md @@ -0,0 +1,51 @@ +--- +title: "Set Rewatch Value" +description: "Set Rewatch Value of The Anime" +weight: 8 +--- + +Use the `SetRewatchValue` method to set the rewatch value. +This method takes these arguments: + +- `id int` ID of the anime +- `rewatchValue int` Self explanatory + +The accepted values for rewatchValue are integers 1 to 5. Each meaning: + +0. Never +1. Very Low +2. Low +3. Medium +4. High +5. Very High + + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.SetRewatchValue(47194, 3) + if err != nil { + log.Fatal(err) + } + + fmt.Println("Rewatch Value has been set to", res.RewatchValue) +} +``` + +The above example sets the rewatch value of "Summertime Render" to 3 (Medium). + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/set-rewatching-status.md b/content/docs/mal2go/v4/user/anime/set-rewatching-status.md new file mode 100644 index 0000000..3c4a767 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/set-rewatching-status.md @@ -0,0 +1,42 @@ +--- +title: "Set Rewatching Status" +description: "Set Rewatching to true or false" +weight: 7 +--- + +Use the `SetIsRewatching` method to set the rewatching status. +This method takes these arguments: + +- `id int` ID of the anime +- `isRewatching bool` Self explanatory + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" + "strconv" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.SetIsRewatching(47194, true) + if err != nil { + log.Fatal(err) + } + + fmt.Println("Rewatching status has been set to ", strconv.FormatBool(res.IsRewatching)) +} +``` + +The above example sets the rewatching status of "Summertime Render" to true. + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/set-score.md b/content/docs/mal2go/v4/user/anime/set-score.md new file mode 100644 index 0000000..1268f9c --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/set-score.md @@ -0,0 +1,41 @@ +--- +title: "Set Anime Score" +description: "Set Score of The Anime" +weight: 6 +--- + +Use the `SetScore` method to set the score. +This method takes these arguments: + +- `id int` ID of the anime +- `score int` Self explanatory + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.SetScore(47194, 10) + if err != nil { + log.Fatal(err) + } + + fmt.Println("Score has been set to", res.Score) +} +``` + +The above example sets the score of "Summertime Render" to 10. + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/set-status.md b/content/docs/mal2go/v4/user/anime/set-status.md new file mode 100644 index 0000000..72256e9 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/set-status.md @@ -0,0 +1,41 @@ +--- +title: "Set Anime Status" +description: "Set anime's status" +weight: 4 +--- + +Use the `SetStatus` method to set the status of an anime. +This method takes these arguments: + +- `id int` ID of the anime +- `status string` Status to set. Accepted values are `watching`, `completed`, `on_hold`, `dropped`, `plan_to_watch` + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.SetStatus(47194, "plan_to_watch") + if err != nil { + log.Fatal(err) + } + + fmt.Println("Status has been set to", res.Status) +} +``` + +The above example adds "Summertime Render" to your plan to watch list. + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/set-watched-episodes.md b/content/docs/mal2go/v4/user/anime/set-watched-episodes.md new file mode 100644 index 0000000..b2ced63 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/set-watched-episodes.md @@ -0,0 +1,41 @@ +--- +title: "Set Watched Episodes" +description: "Set Number of Episodes Watched" +weight: 5 +--- + +Use the `SetWatchedEpisodes` method to set the number of episodes watched. +This method takes these arguments: + +- `id int` ID of the anime +- `episodesWatched int` Self explanatory + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.SetWatchedEpisodes(47194, 3) + if err != nil { + log.Fatal(err) + } + + fmt.Println("Number of episodes has been set to", res.EpWatched) +} +``` + +The above example sets the episodes watched of "Summertime Render" to 3. + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/setting-up.md b/content/docs/mal2go/v4/user/anime/setting-up.md new file mode 100644 index 0000000..397955e --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/setting-up.md @@ -0,0 +1,34 @@ +--- +title: "Setting up" +description: "Install MAL2Go/user/anime and write some boilerplate" +weight: 1 +--- + +How to use the anime package: + +1. Install the anime package using this command + +``` fish +go get github.com/MikunoNaka/MAL2Go/v4/user/anime +``` + +2. Import and initialise the anime client. The client holds the authentication token of the user. The OAuth token should be set as "Bearer TOKEN". Refer to below example + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" +) + +func main() { + // you should never hard-code tokens. This is just an example + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } +} +``` + +Every program using MAL2Go needs something like this to initialise everything (that you need). +And now we are ready to use the MAL2Go/anime package! diff --git a/content/docs/mal2go/v4/user/anime/types.md b/content/docs/mal2go/v4/user/anime/types.md new file mode 100644 index 0000000..e9383da --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/types.md @@ -0,0 +1,36 @@ +--- +title: "Types" +description: "The structs defined in this package" +weight: 14 +--- + +## MAL2Go/user/anime/UpdateAnimedata + +| Struct Field | Type | Description | +|----------------|----------|----------------------------| +| Status | `string` | Status to be set | +| IsRewatching | `bool` | Rewatching status | +| Score | `int` | Score of the anime | +| EpWatched | `int` | Number of episodes watched | +| Priority | `int` | Priority of the anime | +| TimesRewatched | `int` | Number of times rewatched | +| RewatchValue | `int` | Frequency of rewatches | +| Tags | `string` | Tags for the anime | +| Comments | `string` | Comments for the anime | + +## MAL2Go/user/anime/UpdateResponse + +| Struct Field | Type | Description | +|----------------|----------|----------------------------------------------------| +| Status | `string` | Status of the anime | +| Score | `int` | Score of the anime | +| EpWatched | `int` | Number of episodes watched | +| IsRewatching | `bool` | true if user is rewatching this anime | +| StartDate | `string` | Date user started watching this | +| FinishDate | `string` | Date user finished watching this | +| Priority | `string` | Priority of this anime | +| TimesRewatched | `string` | Number of times rewatched | +| RewatchValue | `string` | Frequency of rewatches | +| Tags | `string` | Tags set for this anime | +| Comments | `string` | Comments set for this anime | +| UpdatedAt | `string` | Time stamp of the last time this entry was updated | diff --git a/content/docs/mal2go/v4/user/anime/update-anime.md b/content/docs/mal2go/v4/user/anime/update-anime.md new file mode 100644 index 0000000..b2cfbce --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/update-anime.md @@ -0,0 +1,60 @@ +--- +title: "Update Anime" +description: "Update every field of an anime" +weight: 13 +--- + +The `UpdateAnime` method combines all the other methods used to update any of the fields of an entry in the animelist. + +**Warning: This method will overwrite every field of the specified anime. +If you don't specify a field it'd be set back to the default option. +Use it with caution at your own risk.** + +- `id int` ID of the anime +- `updateData `[`UpdateAnimeData`](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateanimedata) +A struct containing all the fields that need to be updated. **If a field is missing it will be set to the default option.** + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + updateData := anime.UpdateAnimeData { + Status: "watching", + IsRewatching: false, + Score: 10, + EpWatched: 20, + Priority: 2, + TimesRewatched: 0, + RewatchValue: 0, + Tags: "", + Comments: "", + } + + res, err := myClient.UpdateAnime(47194, updateData) + if err != nil { + log.Fatal(err) + } + + fmt.Println(res) +} +``` + +This is useful if you want to update many things without making too many API calls. +You can get the previously set data with the `GetAnimeById` method, if a value needs to be +unchanged, just use the previously set value returned by GetAnimeById. This way, +you can update multiple fields with only two API calls. + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/update-comments.md b/content/docs/mal2go/v4/user/anime/update-comments.md new file mode 100644 index 0000000..18d1775 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/update-comments.md @@ -0,0 +1,41 @@ +--- +title: "Update Comments" +description: "Update the Comments for this anime" +weight: 12 +--- + +Use the `UpdateComments` method to set the comments for this anime. +This method takes these arguments: + +- `id int` ID of the anime +- `comments string` Self explanatory + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.UpdateComments(47194, "This is a comment.") + if err != nil { + log.Fatal(err) + } + + fmt.Println("Comments have been set to \"", res.Comments, "\"" ) +} +``` + +The above example sets the comments for "Summertime Render" to "This is a comment.". + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/anime/update-tags.md b/content/docs/mal2go/v4/user/anime/update-tags.md new file mode 100644 index 0000000..8792151 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/update-tags.md @@ -0,0 +1,41 @@ +--- +title: "Update Tags" +description: "Update tags for this anime" +weight: 11 +--- + +Use the `UpdateTags` method to set the tags for this anime. +This method takes these arguments: + +- `id int` ID of the anime +- `tags string` Self explanatory + +Example: + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user/anime" + "log" + "fmt" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := anime.Client { + AuthToken: "Bearer " + authToken, + } + + res, err := myClient.UpdateTags(47194, "tag1, tag2") + if err != nil { + log.Fatal(err) + } + + fmt.Println("Tags have been set to \"", res.Tags, "\"" ) +} +``` + +The above example sets the tags for "Summertime Render" to "tag1, tag2". + +The [response](/docs/mal2go/v4/user/anime/types/#mal2gouseranimeupdateresponse) from the API can be used to show the information of the anime after being updated. diff --git a/content/docs/mal2go/v4/user/manga/_index.md b/content/docs/mal2go/v4/user/manga/_index.md index fd87fc8..c2060d8 100644 --- a/content/docs/mal2go/v4/user/manga/_index.md +++ b/content/docs/mal2go/v4/user/manga/_index.md @@ -5,5 +5,3 @@ weight: 4 --- The `MAL2Go/user/manga` package supports updating the currently authenticated user's manga list along with reading the manga lists of the current user as well as other users. - -## coming soon! -- cgit v1.2.3