Commit 5b3c5fd80a

5b3c5fd80a94187575124cce797a8eb6123a7319

parent: b1f77c3661

Unsigned

Wraient <wraient.911@gmail.com> · 2026-05-23 00:32 UTC

Offer actions for unreleased anime

Layout: unified · split

internal/curd.go +51 −3
@@ -897,9 +897,7 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni
897897 }
898898
899899 if selectedAnilistAnime.Media.Status == "NOT_YET_RELEASED" {
900 CurdOut("This anime is not yet released. Cannot play.")
901 time.Sleep(2 * time.Second)
902 anime.Ep.ContinueLast = false
900 handleUnreleasedAnime(userCurdConfig, user, anime, *selectedAnilistAnime)
903901 ClearScreen()
904902 continue
905903 }
@@ -1475,6 +1473,56 @@ func WriteTokenToFile(token string, filePath string) error {
14751473 return nil
14761474}
14771475
1476func handleUnreleasedAnime(userCurdConfig *CurdConfig, user *User, anime *Anime, entry Entry) {
1477 title := entry.Media.Title.Romaji
1478 if userCurdConfig != nil && userCurdConfig.AnimeNameLanguage == "english" && entry.Media.Title.English != "" {
1479 title = entry.Media.Title.English
1480 }
1481 if title == "" {
1482 title = strconv.Itoa(entry.Media.ID)
1483 }
1484
1485 CurdOut(fmt.Sprintf("%s is not released yet.", title))
1486 options := []SelectionOption{}
1487 if UsesRemoteTracking(userCurdConfig) {
1488 options = append(options, SelectionOption{Key: "planning", Label: "Add to Plan to Watch"})
1489 }
1490 options = append(options,
1491 SelectionOption{Key: "details", Label: "Open AniList details"},
1492 SelectionOption{Key: "back", Label: "Back to list"},
1493 )
1494
1495 selected, err := DynamicSelect(options)
1496 if err != nil {
1497 Log(fmt.Sprintf("Error in unreleased anime prompt: %v", err))
1498 anime.Ep.ContinueLast = false
1499 return
1500 }
1501
1502 switch selected.Key {
1503 case "planning":
1504 if err := AddAnimeToList(entry.Media.ID, "PLANNING", user.Token); err != nil {
1505 Log(fmt.Sprintf("Error adding unreleased anime to planning: %v", err))
1506 CurdOut("Failed to add to Plan to Watch.")
1507 } else {
1508 CurdOut("Added to Plan to Watch.")
1509 if err := RefreshUserAnimeList(userCurdConfig, user); err != nil {
1510 Log("Error refreshing anime list: " + err.Error())
1511 }
1512 }
1513 case "details":
1514 url := fmt.Sprintf("https://anilist.co/anime/%d", entry.Media.ID)
1515 CurdOut(fmt.Sprintf("Opening %s", url))
1516 if err := browser.OpenURL(url); err != nil {
1517 Log(fmt.Sprintf("Error opening browser: %v", err))
1518 CurdOut("Failed to open browser.")
1519 }
1520 case "-1":
1521 ExitCurd(nil)
1522 }
1523 anime.Ep.ContinueLast = false
1524}
1525
14781526func confirmProviderMatch(option SelectionOption, reason string) bool {
14791527 label := option.Label
14801528 if label == "" {