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 --- anime/anime.go | 28 ++++++++++++++-------------- anime/anime.structs.go | 2 +- anime/client.go | 2 +- anime/request_handler.go | 2 +- errhandlers/errhandlers.go | 2 +- go.mod | 2 +- manga/client.go | 2 +- manga/manga.go | 16 ++++++++-------- manga/manga.structs.go | 2 +- manga/request_handler.go | 2 +- user/anime/animelist.go | 6 +++--- user/anime/animelist.structs.go | 2 +- user/anime/client.go | 2 +- user/anime/update_animelist.go | 2 +- user/client.go | 2 +- user/manga/client.go | 2 +- user/manga/mangalist.go | 6 +++--- user/manga/mangalist.structs.go | 2 +- user/manga/request_handler.go | 2 +- user/manga/update_mangalist.go | 2 +- user/request_handler.go | 2 +- 21 files changed, 45 insertions(+), 45 deletions(-) diff --git a/anime/anime.go b/anime/anime.go index 7181e37..f3bb691 100644 --- a/anime/anime.go +++ b/anime/anime.go @@ -20,14 +20,14 @@ import ( "encoding/json" "fmt" "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/anime" // in MAL documentation this is named Get Anime List -func (c Client) SearchAnime(searchString string, limit, offset int, fields []string) ([]Anime, error) { +func (c Client) SearchAnime(searchString string, limit, offset int, nsfw bool, fields []string) ([]Anime, error) { var searchResults []Anime // error handling for limit @@ -45,8 +45,8 @@ func (c Client) SearchAnime(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, ) @@ -95,7 +95,7 @@ func (c Client) GetAnimeById(animeId int, fields []string) (Anime, error) { } // Ranking is a list of anime sorted by their rank -func (c Client) GetAnimeRanking(rankingType string, limit, offset int, fields []string) ([]rAnime, error) { +func (c Client) GetAnimeRanking(rankingType string, limit, offset int, nsfw bool, fields []string) ([]rAnime, error) { var animeRanking []rAnime // error handling for limit @@ -117,8 +117,8 @@ func (c Client) GetAnimeRanking(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, ) @@ -143,7 +143,7 @@ func (c Client) GetAnimeRanking(rankingType string, limit, offset int, fields [] } // get list of animes from specified season -func (c Client) GetSeasonalAnime(year, season, sort string, limit, offset int, fields []string) (SeasonalAnime, error) { +func (c Client) GetSeasonalAnime(year, season, sort string, limit, offset int, nsfw bool, fields []string) (SeasonalAnime, error) { var seasonalAnime SeasonalAnime // error handling for limit @@ -170,8 +170,8 @@ func (c Client) GetSeasonalAnime(year, season, sort string, limit, offset int, f endpoint, _ := u.UrlGenerator( BASE_URL + fmt.Sprintf("/season/%s/%s", year, season), - []string{"sort", "limit", "offset", "fields"}, - [][]string{{sort}, {strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields}, + []string{"sort", "limit", "offset", "fields", "nsfw"}, + [][]string{{sort}, {strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields, {strconv.FormatBool(nsfw)}}, true, ) @@ -199,7 +199,7 @@ func (c Client) GetSeasonalAnime(year, season, sort string, limit, offset int, f } // get anime suggestions for the user -func (c Client) GetSuggestedAnime(limit, offset int, fields []string) ([]Anime, error){ +func (c Client) GetSuggestedAnime(limit, offset int, nsfw bool, fields []string) ([]Anime, error){ var suggestedAnime []Anime // error handling for limit @@ -217,8 +217,8 @@ func (c Client) GetSuggestedAnime(limit, offset int, fields []string) ([]Anime, endpoint, _ := u.UrlGenerator( BASE_URL + "/suggestions", - []string{"limit", "offset", "fields"}, - [][]string{{strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields}, + []string{"limit", "offset", "fields", "nsfw"}, + [][]string{{strconv.Itoa(limit)}, {strconv.Itoa(offset)}, fields, {strconv.FormatBool(nsfw)}}, true, ) diff --git a/anime/anime.structs.go b/anime/anime.structs.go index 55f2df2..0dd689e 100644 --- a/anime/anime.structs.go +++ b/anime/anime.structs.go @@ -17,7 +17,7 @@ package anime import ( - u "github.com/MikunoNaka/MAL2Go/v2/util" + u "github.com/MikunoNaka/MAL2Go/v3/util" ) type AnimeStatistics struct { diff --git a/anime/client.go b/anime/client.go index 090571b..1ce3dd2 100644 --- a/anime/client.go +++ b/anime/client.go @@ -17,7 +17,7 @@ package anime import ( - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) type Client util.DefaultClient diff --git a/anime/request_handler.go b/anime/request_handler.go index 1aec83b..e5521fd 100644 --- a/anime/request_handler.go +++ b/anime/request_handler.go @@ -21,7 +21,7 @@ import ( "log" "net/http" "encoding/json" - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" "errors" ) diff --git a/errhandlers/errhandlers.go b/errhandlers/errhandlers.go index 425ba99..7b83c74 100644 --- a/errhandlers/errhandlers.go +++ b/errhandlers/errhandlers.go @@ -17,7 +17,7 @@ package errhandlers import ( - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) // this is only for anime fields diff --git a/go.mod b/go.mod index 1f67526..c311947 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/MikunoNaka/MAL2Go/v2 +module github.com/MikunoNaka/MAL2Go/v3 go 1.17 diff --git a/manga/client.go b/manga/client.go index 4622835..5847ed8 100644 --- a/manga/client.go +++ b/manga/client.go @@ -17,7 +17,7 @@ package manga import ( - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) type Client util.DefaultClient 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, ) diff --git a/manga/manga.structs.go b/manga/manga.structs.go index 2e79362..37d69d2 100644 --- a/manga/manga.structs.go +++ b/manga/manga.structs.go @@ -17,7 +17,7 @@ package manga import ( - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) type Author struct { diff --git a/manga/request_handler.go b/manga/request_handler.go index 070ea6b..ae95313 100644 --- a/manga/request_handler.go +++ b/manga/request_handler.go @@ -21,7 +21,7 @@ import ( "log" "net/http" "encoding/json" - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" "errors" ) diff --git a/user/anime/animelist.go b/user/anime/animelist.go index d7a5b41..b950012 100644 --- a/user/anime/animelist.go +++ b/user/anime/animelist.go @@ -20,9 +20,9 @@ import ( "encoding/json" "strconv" "fmt" - a "github.com/MikunoNaka/MAL2Go/v2/anime" - e "github.com/MikunoNaka/MAL2Go/v2/errhandlers" - u "github.com/MikunoNaka/MAL2Go/v2/util" + a "github.com/MikunoNaka/MAL2Go/v3/anime" + e "github.com/MikunoNaka/MAL2Go/v3/errhandlers" + u "github.com/MikunoNaka/MAL2Go/v3/util" ) const BASE_URL string = "https://api.myanimelist.net/v2" diff --git a/user/anime/animelist.structs.go b/user/anime/animelist.structs.go index 9f83f82..3097c12 100644 --- a/user/anime/animelist.structs.go +++ b/user/anime/animelist.structs.go @@ -17,7 +17,7 @@ package anime import ( - "github.com/MikunoNaka/MAL2Go/v2/anime" + "github.com/MikunoNaka/MAL2Go/v3/anime" ) type animeListRaw struct { diff --git a/user/anime/client.go b/user/anime/client.go index 090571b..1ce3dd2 100644 --- a/user/anime/client.go +++ b/user/anime/client.go @@ -17,7 +17,7 @@ package anime import ( - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) type Client util.DefaultClient diff --git a/user/anime/update_animelist.go b/user/anime/update_animelist.go index d8c936a..111572a 100644 --- a/user/anime/update_animelist.go +++ b/user/anime/update_animelist.go @@ -16,7 +16,7 @@ package anime import ( - e "github.com/MikunoNaka/MAL2Go/v2/errhandlers" + e "github.com/MikunoNaka/MAL2Go/v3/errhandlers" "fmt" "net/url" "strconv" diff --git a/user/client.go b/user/client.go index 32bdc34..a26856d 100644 --- a/user/client.go +++ b/user/client.go @@ -17,7 +17,7 @@ package user import ( - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) type Client util.DefaultClient diff --git a/user/manga/client.go b/user/manga/client.go index 4622835..5847ed8 100644 --- a/user/manga/client.go +++ b/user/manga/client.go @@ -17,7 +17,7 @@ package manga import ( - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) type Client util.DefaultClient diff --git a/user/manga/mangalist.go b/user/manga/mangalist.go index 7d7cadc..cde1ede 100644 --- a/user/manga/mangalist.go +++ b/user/manga/mangalist.go @@ -20,9 +20,9 @@ import ( "encoding/json" "strconv" "fmt" - e "github.com/MikunoNaka/MAL2Go/v2/errhandlers" - u "github.com/MikunoNaka/MAL2Go/v2/util" - m "github.com/MikunoNaka/MAL2Go/v2/manga" + e "github.com/MikunoNaka/MAL2Go/v3/errhandlers" + u "github.com/MikunoNaka/MAL2Go/v3/util" + m "github.com/MikunoNaka/MAL2Go/v3/manga" ) const BASE_URL string = "https://api.myanimelist.net/v2" diff --git a/user/manga/mangalist.structs.go b/user/manga/mangalist.structs.go index 7b69586..3f338ae 100644 --- a/user/manga/mangalist.structs.go +++ b/user/manga/mangalist.structs.go @@ -17,7 +17,7 @@ package manga import ( - "github.com/MikunoNaka/MAL2Go/v2/manga" + "github.com/MikunoNaka/MAL2Go/v3/manga" ) type mangaListRaw struct { diff --git a/user/manga/request_handler.go b/user/manga/request_handler.go index edd8de6..7d89402 100644 --- a/user/manga/request_handler.go +++ b/user/manga/request_handler.go @@ -24,7 +24,7 @@ import ( "strconv" "strings" "errors" - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" ) type UpdateResponse struct { diff --git a/user/manga/update_mangalist.go b/user/manga/update_mangalist.go index 7d488dc..f062be9 100644 --- a/user/manga/update_mangalist.go +++ b/user/manga/update_mangalist.go @@ -16,7 +16,7 @@ package manga import ( - e "github.com/MikunoNaka/MAL2Go/v2/errhandlers" + e "github.com/MikunoNaka/MAL2Go/v3/errhandlers" "fmt" "net/url" "strconv" diff --git a/user/request_handler.go b/user/request_handler.go index d2e1c34..df66abf 100644 --- a/user/request_handler.go +++ b/user/request_handler.go @@ -20,7 +20,7 @@ import ( "io/ioutil" "log" "net/http" - "github.com/MikunoNaka/MAL2Go/v2/util" + "github.com/MikunoNaka/MAL2Go/v3/util" "errors" "encoding/json" ) -- cgit v1.2.3