aboutsummaryrefslogtreecommitdiff
path: root/mal/search.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2023-08-15 10:57:27 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2023-08-15 10:57:27 +0530
commitfff3dadabc321871e6819392efc605c6dffe2e69 (patch)
tree25aceed23b73b2ad975a06d73fad091d0886a2a6 /mal/search.go
parenta44d6eb2fdddc75983c735e1a0fa744014db9593 (diff)
migrated from MAL2Go to mg package
Diffstat (limited to 'mal/search.go')
-rw-r--r--mal/search.go31
1 files changed, 21 insertions, 10 deletions
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 <http://www.gnu.org/licenses/>.
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)