diff options
Diffstat (limited to 'mal')
-rw-r--r-- | mal/mal.go | 1 | ||||
-rw-r--r-- | mal/search.go | 16 |
2 files changed, 15 insertions, 2 deletions
@@ -39,6 +39,7 @@ var ( SearchLength, SearchOffset int SearchNSFW bool + AutoSel int ) // init() would kill the program prematurely on `macli login` command diff --git a/mal/search.go b/mal/search.go index 1bad114..e6e416a 100644 --- a/mal/search.go +++ b/mal/search.go @@ -28,7 +28,13 @@ import ( func SearchAnime(searchString string, fields []string) []a.Anime { fields = append([]string{"title", "id"}, fields...) - res, err := animeClient.SearchAnime(searchString, SearchLength, SearchOffset, SearchNSFW, fields) + searchLength, searchOffset := SearchLength, SearchOffset + if AutoSel > 0 { + searchLength = 1 + searchOffset = AutoSel - 1 + } + + res, err := animeClient.SearchAnime(searchString, searchLength, searchOffset, SearchNSFW, fields) if err != nil { fmt.Println("MyAnimeList reported error while searching:", err.Error()) os.Exit(1) @@ -40,7 +46,13 @@ func SearchAnime(searchString string, fields []string) []a.Anime { func SearchManga(searchString string, fields []string) []m.Manga { fields = append([]string{"title", "id"}, fields...) - res, err := mangaClient.SearchManga(searchString, SearchLength, SearchOffset, SearchNSFW, fields) + searchLength, searchOffset := SearchLength, SearchOffset + if AutoSel > 0 { + searchLength = 1 + searchOffset = AutoSel - 1 + } + + res, err := mangaClient.SearchManga(searchString, searchLength, searchOffset, SearchNSFW, fields) if err != nil { fmt.Println("MyAnimeList reported error while searching:", err.Error()) os.Exit(1) |