Commit 8a0174b661

8a0174b6615df64f55986074b37425196c7c1a91

parent: 7b8800f0b5

Unsigned

Wraient <wraient.911@gmail.com> · 2026-01-07 20:46 UTC

Feat: Open browser for multiple sequels

Layout: unified · split

internal/anilist.go +18 −4
@@ -921,10 +921,12 @@ type SequelInfo struct {
921921 CoverImage string
922922 Episodes int
923923 Status string // "FINISHED", "RELEASING", "NOT_YET_RELEASED"
924 SiteURL string
924925}
925926
926927// GetAnimeSequel fetches sequel information for a given anime from AniList
927func GetAnimeSequel(animeID int, token string) (*SequelInfo, error) {
928// GetAnimeSequel fetches sequel information for a given anime from AniList
929func GetAnimeSequel(animeID int, token string) ([]SequelInfo, error) {
928930 url := "https://graphql.anilist.co"
929931 query := `
930932 query ($id: Int) {
@@ -943,6 +945,7 @@ func GetAnimeSequel(animeID int, token string) (*SequelInfo, error) {
943945 }
944946 episodes
945947 status
948 siteUrl
946949 }
947950 }
948951 }
@@ -983,6 +986,8 @@ func GetAnimeSequel(animeID int, token string) (*SequelInfo, error) {
983986 return nil, nil // No edges found
984987 }
985988
989 var sequels []SequelInfo
990
986991 // Look for a SEQUEL relation
987992 for _, edge := range edges {
988993 edgeData, ok := edge.(map[string]interface{})
@@ -1000,7 +1005,7 @@ func GetAnimeSequel(animeID int, token string) (*SequelInfo, error) {
10001005 continue
10011006 }
10021007
1003 sequel := &SequelInfo{}
1008 var sequel SequelInfo
10041009
10051010 // Parse ID
10061011 if id, ok := node["id"].(float64); ok {
@@ -1034,10 +1039,19 @@ func GetAnimeSequel(animeID int, token string) (*SequelInfo, error) {
10341039 sequel.Status = status
10351040 }
10361041
1037 return sequel, nil
1042 // Parse siteUrl
1043 if siteUrl, ok := node["siteUrl"].(string); ok {
1044 sequel.SiteURL = siteUrl
1045 }
1046
1047 sequels = append(sequels, sequel)
1048 }
1049
1050 if len(sequels) == 0 {
1051 return nil, nil // No sequel found
10381052 }
10391053
1040 return nil, nil // No sequel found
1054 return sequels, nil
10411055}
10421056
10431057// AddAnimeToList adds an anime to a specified list (CURRENT, PLANNING, PAUSED, DROPPED)
internal/curd.go +29 −2
@@ -17,6 +17,7 @@ import (
1717 "time"
1818
1919 "github.com/gen2brain/beeep"
20 "github.com/pkg/browser"
2021)
2122
2223func EditConfig(configFilePath string) {
@@ -1695,17 +1696,43 @@ func handleSequelCheck(userCurdConfig *CurdConfig, anime *Anime, userToken strin
16951696 }()
16961697
16971698 // Fetch sequel information
1698 sequel, err := GetAnimeSequel(anime.AnilistId, userToken)
1699 sequels, err := GetAnimeSequel(anime.AnilistId, userToken)
16991700 if err != nil {
17001701 Log(fmt.Sprintf("Error fetching sequel information: %v", err))
17011702 return
17021703 }
17031704
1704 if sequel == nil {
1705 if len(sequels) == 0 {
17051706 Log("No sequel found for this anime")
17061707 return
17071708 }
17081709
1710 if len(sequels) > 1 {
1711 CurdOut("Multiple sequels found for this anime.")
1712 options := []SelectionOption{
1713 {Key: "yes", Label: "Open AniList page to view sequels"},
1714 {Key: "no", Label: "Ignore"},
1715 }
1716
1717 selectedOption, err := DynamicSelect(options)
1718 if err != nil {
1719 Log(fmt.Sprintf("Error in multiple sequel prompt: %v", err))
1720 return
1721 }
1722
1723 if selectedOption.Key == "yes" {
1724 url := fmt.Sprintf("https://anilist.co/anime/%d", anime.AnilistId)
1725 CurdOut(fmt.Sprintf("Opening %s", url))
1726 if err := browser.OpenURL(url); err != nil {
1727 Log(fmt.Sprintf("Error opening browser: %v", err))
1728 CurdOut("Failed to open browser.")
1729 }
1730 }
1731 return
1732 }
1733
1734 sequel := &sequels[0]
1735
17091736 // Get sequel title based on user's language preference
17101737 sequelTitle := sequel.Title.Romaji
17111738 if sequel.Title.English != "" && userCurdConfig.AnimeNameLanguage == "english" {