aboutsummaryrefslogtreecommitdiff
path: root/mal/search.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-15 12:59:22 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-15 12:59:22 +0530
commitab3db8a4ca89293ce0928177e8845d622f13755f (patch)
treee5331856b39b43cfea422f806aa046b0925e92e4 /mal/search.go
parent5eb7a3cd41826fccdc432d049dd85a31b4b56073 (diff)
added pretty template for TextInput
Diffstat (limited to 'mal/search.go')
-rw-r--r--mal/search.go32
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
+}