diff options
Diffstat (limited to 'mal/search.go')
-rw-r--r-- | mal/search.go | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/mal/search.go b/mal/search.go index 2968611..703cdb4 100644 --- a/mal/search.go +++ b/mal/search.go @@ -19,24 +19,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. package mal import ( - "log" + "fmt" + "os" a "github.com/MikunoNaka/MAL2Go/anime" + m "github.com/MikunoNaka/MAL2Go/manga" ) -func SearchAnime(searchString string, extraFields []string) []a.Anime { - // TODO: load limit, offset and (maybe) fields from config +func SearchAnime(searchString string) []a.Anime { + // TODO: read limit, offset from flags limit, offset := 10, 0 - - fields := []string{"title", "id"} - for _, i := range extraFields { - fields = append(fields, i) - } + fields := []string{"title", "id", "my_list_status"} res, err := animeClient.SearchAnime(searchString, limit, offset, fields) if err != nil { - log.Println(err) - return []a.Anime{} + fmt.Println("MyAnimeList reported error while searching:", err.Error()) + os.Exit(1) } return res.Animes } + +func SearchManga(searchString string) []m.Manga { + // TODO: read limit, offset from flags + limit, offset := 10, 0 + fields := []string{"title", "id", "my_list_status"} + + res, err := mangaClient.SearchManga(searchString, limit, offset, fields) + if err != nil { + fmt.Println("MyAnimeList reported error while searching:", err.Error()) + os.Exit(1) + } + + return res.Mangas +} |