From d5df42a97e86e043bb7d8df63892f3e43643b6c1 Mon Sep 17 00:00:00 2001 From: Apologieze <47333595+Apologieze@users.noreply.github.com> Date: Fri, 24 Jan 2025 23:49:28 -0500 Subject: [PATCH] client token and adding begin --- anilist/anilist.go | 16 +++++++++++++--- main.go | 9 ++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/anilist/anilist.go b/anilist/anilist.go index f87da47..e1f67e6 100644 --- a/anilist/anilist.go +++ b/anilist/anilist.go @@ -48,10 +48,10 @@ var categoriesToInt = make(map[string]int) "Planning": 3, }*/ -func GetData(radio *widget.RadioGroup, username string, delete func()) { - v := verniy.New() +var Client *verniy.Client = verniy.New() - typeAnime, err := v.GetUserAnimeList(username, fields...) +func GetData(radio *widget.RadioGroup, username string, delete func()) { + typeAnime, err := Client.GetUserAnimeList(username, fields...) if err != nil { typeAnime = make([]verniy.MediaListGroup, 4) log.Error("Invalid token") @@ -128,3 +128,13 @@ func IdToUrl(id int) *url.URL { } return u } + +func SearchFromQuery(strQuery string) *[]verniy.Media { + query := verniy.PageParamMedia{Search: strQuery} + result, err := Client.SearchAnime(query, 1, 10) + if err != nil { + log.Error("Error searching anime:", err) + return nil + } + return &result.Media +} diff --git a/main.go b/main.go index fcdf440..72adfed 100644 --- a/main.go +++ b/main.go @@ -153,6 +153,7 @@ func changeEpisodeInApp(variation int) { func initMainApp() { secondCurdInit() + anilist.Client.AccessToken = user.Token window.SetTitle("AnimeGUI") fmt.Println(localAnime) @@ -190,7 +191,13 @@ func initMainApp() { radiobox.Horizontal = true toolbar := widget.NewToolbar( - widget.NewToolbarAction(theme.ContentAddIcon(), func() {}), + widget.NewToolbarAction(theme.ContentAddIcon(), func() { + result := anilist.SearchFromQuery(input.Text) + if result == nil { + return + } + fmt.Printf("Result: %+v\n", *result) + }), widget.NewToolbarSeparator(), widget.NewToolbarAction(theme.ViewRefreshIcon(), func() {}), widget.NewToolbarSeparator(),