diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-29 23:46:53 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-29 23:46:53 +0530 |
commit | 1395d849470cc564d593bd2074a69f012e4f70ce (patch) | |
tree | c14d064e86122add55340051f98c145b882d4878 | |
parent | ccb1cf8c1679d5e8a401a85151ef9882e4293b81 (diff) |
migrated from MAL2Go v1 to v2
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | mal/delete.go | 14 | ||||
-rw-r--r-- | mal/mal.go | 10 | ||||
-rw-r--r-- | mal/search.go | 8 | ||||
-rw-r--r-- | mal/status.go | 24 | ||||
-rw-r--r-- | mal/user.go | 11 | ||||
-rw-r--r-- | ui/actions.go | 4 | ||||
-rw-r--r-- | ui/episodes.go | 4 | ||||
-rw-r--r-- | ui/search.go | 4 | ||||
-rw-r--r-- | ui/status.go | 4 |
11 files changed, 55 insertions, 34 deletions
@@ -3,7 +3,7 @@ module github.com/MikunoNaka/macli go 1.18 require ( - github.com/MikunoNaka/MAL2Go v1.0.4 + github.com/MikunoNaka/MAL2Go/v2 v2.0.3 github.com/manifoldco/promptui v0.9.0 github.com/spf13/cobra v1.4.0 github.com/zalando/go-keyring v0.2.1 @@ -1,5 +1,5 @@ -github.com/MikunoNaka/MAL2Go v1.0.4 h1:kK2dJQpycACbiw4ePLzVy121AhGF3rNJzFDhT96uVyA= -github.com/MikunoNaka/MAL2Go v1.0.4/go.mod h1:3dRnAROv0KVmgVk3ln2t0u8x+DGQpsPuzPY5nz4TP6A= +github.com/MikunoNaka/MAL2Go/v2 v2.0.3 h1:T3hSc2QL51zi5xZ71l2JwcqO1t7cfFuMvmU9WhOYIlo= +github.com/MikunoNaka/MAL2Go/v2 v2.0.3/go.mod h1:x+DAqTvsWCuETE7q3ndXvaM4epQ3OJ6QauowQ+ftQFQ= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= diff --git a/mal/delete.go b/mal/delete.go index 27ffbe6..863e9f3 100644 --- a/mal/delete.go +++ b/mal/delete.go @@ -21,19 +21,25 @@ package mal import ( "fmt" // "os" - a "github.com/MikunoNaka/MAL2Go/anime" - m "github.com/MikunoNaka/MAL2Go/manga" + a "github.com/MikunoNaka/MAL2Go/v2/anime" + m "github.com/MikunoNaka/MAL2Go/v2/manga" ) func DeleteAnime(anime a.Anime) { - res := userAnimeClient.DeleteAnime(anime.Id) + res, err := userAnimeClient.DeleteAnime(anime.Id) + if err != nil { + fmt.Println("Error While Deleting " + anime.Title + ":", err) + } if res != "200" { fmt.Println("Error: MyAnimeList Returned " + res + " while deleting " + anime.Title) } } func DeleteManga(manga m.Manga) { - res := userMangaClient.DeleteManga(manga.Id) + res, err := userMangaClient.DeleteManga(manga.Id) + if err != nil { + fmt.Println("Error While Deleting " + manga.Title + ":", err) + } if res != "200" { fmt.Println("Error: MyAnimeList Returned " + res + " while deleting " + manga.Title) } @@ -20,11 +20,11 @@ package mal import ( "github.com/MikunoNaka/macli/auth" - a "github.com/MikunoNaka/MAL2Go/anime" - m "github.com/MikunoNaka/MAL2Go/manga" - u "github.com/MikunoNaka/MAL2Go/user" - ua "github.com/MikunoNaka/MAL2Go/user/anime" - um "github.com/MikunoNaka/MAL2Go/user/manga" + a "github.com/MikunoNaka/MAL2Go/v2/anime" + m "github.com/MikunoNaka/MAL2Go/v2/manga" + u "github.com/MikunoNaka/MAL2Go/v2/user" + ua "github.com/MikunoNaka/MAL2Go/v2/user/anime" + um "github.com/MikunoNaka/MAL2Go/v2/user/manga" ) var animeClient a.Client diff --git a/mal/search.go b/mal/search.go index 703cdb4..8fee461 100644 --- a/mal/search.go +++ b/mal/search.go @@ -21,8 +21,8 @@ package mal import ( "fmt" "os" - a "github.com/MikunoNaka/MAL2Go/anime" - m "github.com/MikunoNaka/MAL2Go/manga" + a "github.com/MikunoNaka/MAL2Go/v2/anime" + m "github.com/MikunoNaka/MAL2Go/v2/manga" ) func SearchAnime(searchString string) []a.Anime { @@ -36,7 +36,7 @@ func SearchAnime(searchString string) []a.Anime { os.Exit(1) } - return res.Animes + return res } func SearchManga(searchString string) []m.Manga { @@ -50,5 +50,5 @@ func SearchManga(searchString string) []m.Manga { os.Exit(1) } - return res.Mangas + return res } diff --git a/mal/status.go b/mal/status.go index 1e11106..4a581df 100644 --- a/mal/status.go +++ b/mal/status.go @@ -29,10 +29,14 @@ func SetAnimeStatus(animeId int, status string) { fmt.Println("Error while parsing status:", err.Error()) os.Exit(1) } - if resp.Error != "" { - fmt.Println("MyAnimeList reported error on setting anime status", resp.Error, resp.Message) - os.Exit(1) - } + // TODO: do something with resp + fmt.Println(resp) + + // not needed with MAL2Go v2.... probably + // if resp.Error != "" { + // fmt.Println("MyAnimeList reported error on setting anime status", resp.Error, resp.Message) + // os.Exit(1) + // } } func SetMangaStatus(mangaId int, status string) { @@ -41,8 +45,12 @@ func SetMangaStatus(mangaId int, status string) { fmt.Println("Error while parsing status:", err.Error()) os.Exit(1) } - if resp.Error != "" { - fmt.Println("MyAnimeList reported error on setting manga status", resp.Error, resp.Message) - os.Exit(1) - } + // TODO: do something with resp + fmt.Println(resp) + + // not needed with MAL2Go v2.... probably + // if resp.Error != "" { + // fmt.Println("MyAnimeList reported error on setting manga status", resp.Error, resp.Message) + // os.Exit(1) + // } } diff --git a/mal/user.go b/mal/user.go index 4d7aa45..f6e9ce7 100644 --- a/mal/user.go +++ b/mal/user.go @@ -19,9 +19,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. package mal import ( - u "github.com/MikunoNaka/MAL2Go/user" + u "github.com/MikunoNaka/MAL2Go/v2/user" + "fmt" + "os" ) func GetUserInfo() u.UserInfo { - return userClient.GetSelfUserInfo() + userInfo, err := userClient.GetSelfUserInfo() + if err != nil { + fmt.Println("Error fetching User Information:", err) + os.Exit(1) + } + return userInfo } diff --git a/ui/actions.go b/ui/actions.go index 2d2b0f3..2600b21 100644 --- a/ui/actions.go +++ b/ui/actions.go @@ -23,8 +23,8 @@ import ( "fmt" "os" p "github.com/manifoldco/promptui" - a "github.com/MikunoNaka/MAL2Go/anime" - m "github.com/MikunoNaka/MAL2Go/manga" + a "github.com/MikunoNaka/MAL2Go/v2/anime" + m "github.com/MikunoNaka/MAL2Go/v2/manga" "github.com/MikunoNaka/macli/mal" ) diff --git a/ui/episodes.go b/ui/episodes.go index d4c3791..8b39119 100644 --- a/ui/episodes.go +++ b/ui/episodes.go @@ -24,8 +24,8 @@ import ( "os" "errors" "github.com/MikunoNaka/macli/mal" - a "github.com/MikunoNaka/MAL2Go/anime" - m "github.com/MikunoNaka/MAL2Go/manga" + a "github.com/MikunoNaka/MAL2Go/v2/anime" + m "github.com/MikunoNaka/MAL2Go/v2/manga" p "github.com/manifoldco/promptui" ) diff --git a/ui/search.go b/ui/search.go index 911add5..c62006a 100644 --- a/ui/search.go +++ b/ui/search.go @@ -24,8 +24,8 @@ import ( "os" p "github.com/manifoldco/promptui" mal "github.com/MikunoNaka/macli/mal" - a "github.com/MikunoNaka/MAL2Go/anime" - m "github.com/MikunoNaka/MAL2Go/manga" + a "github.com/MikunoNaka/MAL2Go/v2/anime" + m "github.com/MikunoNaka/MAL2Go/v2/manga" ) // only search animes probably only now diff --git a/ui/status.go b/ui/status.go index 11fe5d8..09fd3d0 100644 --- a/ui/status.go +++ b/ui/status.go @@ -23,8 +23,8 @@ import ( "fmt" "os" "github.com/MikunoNaka/macli/mal" - a "github.com/MikunoNaka/MAL2Go/anime" - m "github.com/MikunoNaka/MAL2Go/manga" + a "github.com/MikunoNaka/MAL2Go/v2/anime" + m "github.com/MikunoNaka/MAL2Go/v2/manga" p "github.com/manifoldco/promptui" ) |