From fff3dadabc321871e6819392efc605c6dffe2e69 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Tue, 15 Aug 2023 10:57:27 +0530 Subject: migrated from MAL2Go to mg package --- mal/search.go | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'mal/search.go') diff --git a/mal/search.go b/mal/search.go index e6e416a..b8dafb9 100644 --- a/mal/search.go +++ b/mal/search.go @@ -19,22 +19,27 @@ along with this program. If not, see . package mal import ( + "vidhukant.com/mg" "fmt" "os" - a "github.com/MikunoNaka/MAL2Go/v4/anime" - m "github.com/MikunoNaka/MAL2Go/v4/manga" ) -func SearchAnime(searchString string, fields []string) []a.Anime { - fields = append([]string{"title", "id"}, fields...) - +func SearchAnime(searchString string, fields []string) []mg.Anime { searchLength, searchOffset := SearchLength, SearchOffset if AutoSel > 0 { searchLength = 1 searchOffset = AutoSel - 1 } - res, err := animeClient.SearchAnime(searchString, searchLength, searchOffset, SearchNSFW, fields) + var res []mg.Anime + err := MALClient.SearchAnime(&res, &mg.SearchParams{ + Limit: searchLength, + Offset: searchOffset, + NSFW: SearchNSFW, + SearchString: searchString, + Fields: append([]string{"title", "id"}, fields...), + }) + if err != nil { fmt.Println("MyAnimeList reported error while searching:", err.Error()) os.Exit(1) @@ -43,16 +48,22 @@ func SearchAnime(searchString string, fields []string) []a.Anime { return res } -func SearchManga(searchString string, fields []string) []m.Manga { - fields = append([]string{"title", "id"}, fields...) - +func SearchManga(searchString string, fields []string) []mg.Manga { searchLength, searchOffset := SearchLength, SearchOffset if AutoSel > 0 { searchLength = 1 searchOffset = AutoSel - 1 } - res, err := mangaClient.SearchManga(searchString, searchLength, searchOffset, SearchNSFW, fields) + var res []mg.Manga + err := MALClient.SearchManga(&res, &mg.SearchParams{ + Limit: searchLength, + Offset: searchOffset, + NSFW: SearchNSFW, + SearchString: searchString, + Fields: append([]string{"title", "id"}, fields...), + }) + if err != nil { fmt.Println("MyAnimeList reported error while searching:", err.Error()) os.Exit(1) -- cgit v1.2.3