From 937f3b8ada85274dfe3842f3dde8aef45c4f3ae7 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 13 Feb 2022 14:12:45 +0530 Subject: completed (?) the GetAnimeList function --- anime/anime.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'anime/anime.go') diff --git a/anime/anime.go b/anime/anime.go index 323105b..969b04c 100644 --- a/anime/anime.go +++ b/anime/anime.go @@ -27,12 +27,15 @@ import ( const BASE_URL string = "https://api.myanimelist.net/v2/anime" +// MAL Might change this +const maxAnimeLimit int = 500 + // in MAL documentation this is named Get Anime List func (c AnimeClient) SearchAnime(searchString string, limit, offset int, fields []string) (AnimeSearch, error) { var searchResults AnimeSearch // error handling for limit and offset - limitsErr := e.LimitsErrHandler(limit, offset) + limitsErr := e.LimitsErrHandler(limit, offset, maxAnimeLimit) if limitsErr != nil { return searchResults, limitsErr } @@ -102,7 +105,7 @@ func (c AnimeClient) GetAnimeRanking(rankingType string, limit, offset int, fiel var animeRanking AnimeRanking // error handling for limit and offset - limitsErr := e.LimitsErrHandler(limit, offset) + limitsErr := e.LimitsErrHandler(limit, offset, maxAnimeLimit) if limitsErr != nil { return animeRanking, limitsErr } @@ -159,7 +162,7 @@ func (c AnimeClient) GetSeasonalAnime(year, season, sort string, limit, offset i var seasonalAnime SeasonalAnime // error handling for limit and offset - limitsErr := e.LimitsErrHandler(limit, offset) + limitsErr := e.LimitsErrHandler(limit, offset, maxAnimeLimit) if limitsErr != nil { return seasonalAnime, limitsErr } @@ -176,7 +179,7 @@ func (c AnimeClient) GetSeasonalAnime(year, season, sort string, limit, offset i } // checks if valid sort is specified - if !e.IsValidSort(sort) { + if !e.IsValidSeasonalSort(sort) { return seasonalAnime, errors.New(fmt.Sprintf("GetSeasonalAnime: Invalid sort specified: \"%s\"", sort)) } @@ -213,7 +216,7 @@ func (c AnimeClient) GetSuggestedAnime(limit, offset int, fields []string) (Sugg var suggestedAnime SuggestedAnime // error handling for limit and offset - limitsErr := e.LimitsErrHandler(limit, offset) + limitsErr := e.LimitsErrHandler(limit, offset, maxAnimeLimit) if limitsErr != nil { return suggestedAnime, limitsErr } -- cgit v1.2.3