aboutsummaryrefslogtreecommitdiff
path: root/manga/manga.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-04 00:54:35 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-04 00:54:35 +0530
commit72989b8e2fb6060f89cee60d32a0c84660792116 (patch)
treeb3de54f1f2476dd0da831f0a5b9409ea31f4387d /manga/manga.go
parent2a1dc51d0bf9e4d440e33dc01f86947985aff787 (diff)
Breaking Change: supporting NSFW titles
Diffstat (limited to 'manga/manga.go')
-rw-r--r--manga/manga.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/manga/manga.go b/manga/manga.go
index 576526c..a4a1505 100644
--- a/manga/manga.go
+++ b/manga/manga.go
@@ -19,14 +19,14 @@ package manga
import (
"encoding/json"
"strconv"
- e "github.com/MikunoNaka/MAL2Go/v2/errhandlers"
- u "github.com/MikunoNaka/MAL2Go/v2/util"
+ e "github.com/MikunoNaka/MAL2Go/v3/errhandlers"
+ u "github.com/MikunoNaka/MAL2Go/v3/util"
)
const BASE_URL string = "https://api.myanimelist.net/v2/manga"
// in MAL documentation this is named Get Manga List
-func (c Client) SearchManga(searchString string, limit, offset int, fields []string) ([]Manga, error) {
+func (c Client) SearchManga(searchString string, limit, offset int, nsfw bool, fields []string) ([]Manga, error) {
var searchResults []Manga
// error handling for limit
@@ -44,8 +44,8 @@ func (c Client) SearchManga(searchString string, limit, offset int, fields []str
// generate endpoint url with custom params
endpoint, _ := u.UrlGenerator(
BASE_URL,
- []string{"q", "limit", "offset", "fields"},
- [][]string{{searchString}, {strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields},
+ []string{"q", "limit", "offset", "fields", "nsfw"},
+ [][]string{{searchString}, {strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields, {strconv.FormatBool(nsfw)}},
true,
)
@@ -91,7 +91,7 @@ func (c Client) GetMangaById(mangaId int, fields []string) (Manga, error) {
}
// Ranking is a list of manga sorted by their rank
-func (c Client) GetMangaRanking(rankingType string, limit, offset int, fields []string) ([]rManga, error) {
+func (c Client) GetMangaRanking(rankingType string, limit, offset int, nsfw bool, fields []string) ([]rManga, error) {
var mangaRanking []rManga
// error handling for limit
@@ -113,8 +113,8 @@ func (c Client) GetMangaRanking(rankingType string, limit, offset int, fields []
endpoint, _ := u.UrlGenerator(
BASE_URL + "/ranking",
- []string{"ranking_type", "limit", "offset", "fields"},
- [][]string{{rankingType}, {strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields},
+ []string{"ranking_type", "limit", "offset", "fields", "nsfw"},
+ [][]string{{rankingType}, {strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields, {strconv.FormatBool(nsfw)}},
true,
)