aboutsummaryrefslogtreecommitdiff
path: root/anime/anime.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-13 14:12:45 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-13 14:12:45 +0530
commit937f3b8ada85274dfe3842f3dde8aef45c4f3ae7 (patch)
tree7de3ab75005620e33f8aac32554695b7eecd552c /anime/anime.go
parent1d3f72c1b48998b86fd1740e893559b6dcaf7663 (diff)
completed (?) the GetAnimeList function
Diffstat (limited to 'anime/anime.go')
-rw-r--r--anime/anime.go13
1 files changed, 8 insertions, 5 deletions
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
}