Commit 0612f42bde
Unsigned
Layout: unified · split
internal/curd.go +27 −1
| @@ -4,6 +4,7 @@ import ( | ||
| 4 | 4 | "encoding/json" |
| 5 | 5 | "fmt" |
| 6 | 6 | "os" |
| 7 | "path/filepath" | |
| 7 | 8 | "runtime" |
| 8 | 9 | "strconv" |
| 9 | 10 | "strings" |
| @@ -99,7 +100,32 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 99 | 100 | ExitCurd() |
| 100 | 101 | } |
| 101 | 102 | if anilistSelectedOption.Label == "add_new" { // Todo: Add new anime |
| 102 | ExitCurd() | |
| 103 | fmt.Println("Enter the anime name:") | |
| 104 | var query string | |
| 105 | fmt.Scanln(&query) | |
| 106 | animeMap, err := SearchAnimeAnilist(query, user.Token) | |
| 107 | if err != nil { | |
| 108 | fmt.Println("Failed to search anime") | |
| 109 | ExitCurd() | |
| 110 | } | |
| 111 | anilistSelectedOption, err = DynamicSelect(animeMap) | |
| 112 | if err != nil { | |
| 113 | fmt.Println("No anime available") | |
| 114 | ExitCurd() | |
| 115 | } | |
| 116 | animeID, err := strconv.Atoi(anilistSelectedOption.Key) | |
| 117 | if err != nil { | |
| 118 | fmt.Println("Failed to convert anime ID to integer") | |
| 119 | ExitCurd() | |
| 120 | } | |
| 121 | err = AddAnimeToWatchingList(animeID, user.Token) | |
| 122 | if err != nil { | |
| 123 | fmt.Println("Failed to add anime to watching list") | |
| 124 | ExitCurd() | |
| 125 | } | |
| 126 | anilistUserData, err := GetUserData(user.Token, user.Id) | |
| 127 | user.AnimeList = ParseAnimeList(anilistUserData) | |
| 128 | // animeListMap := GetAnimeMap(user.AnimeList) | |
| 103 | 129 | } |
| 104 | 130 | userQuery := anilistSelectedOption.Label |
| 105 | 131 | anime.AnilistId, err = strconv.Atoi(anilistSelectedOption.Key) |