diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-07-04 00:54:35 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-07-04 00:54:35 +0530 |
commit | 72989b8e2fb6060f89cee60d32a0c84660792116 (patch) | |
tree | b3de54f1f2476dd0da831f0a5b9409ea31f4387d /anime | |
parent | 2a1dc51d0bf9e4d440e33dc01f86947985aff787 (diff) |
Breaking Change: supporting NSFW titles
Diffstat (limited to 'anime')
-rw-r--r-- | anime/anime.go | 28 | ||||
-rw-r--r-- | anime/anime.structs.go | 2 | ||||
-rw-r--r-- | anime/client.go | 2 | ||||
-rw-r--r-- | anime/request_handler.go | 2 |
4 files changed, 17 insertions, 17 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" ) |