From 72989b8e2fb6060f89cee60d32a0c84660792116 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 4 Jul 2022 00:54:35 +0530 Subject: Breaking Change: supporting NSFW titles --- manga/manga.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'manga/manga.go') 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, ) -- cgit v1.2.3