Skip to content

Commit afdf84f

Browse files
committed
fix: Return ErrUserQuit for clean termination in download handling functions
1 parent 18368f8 commit afdf84f

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

internal/player/download.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ func HandleBatchDownloadRange(episodes []models.Episode, animeURL string, startN
700700
if util.IsDebug {
701701
util.Logger.Debug("HandleBatchDownloadRange completed", "animeURL", animeURL, "duration", time.Since(start))
702702
}
703-
return nil
703+
// For programmatic range downloads, exit without further prompts
704+
return ErrUserQuit
704705
}
705706

706707
// getEpisodeRange asks the user for the episode range for download.
@@ -826,7 +827,7 @@ func handleExistingEpisodes(episodes []models.Episode, animeURL string, startNum
826827

827828
if selectedEpisode == "exit" {
828829
fmt.Println("No episode selected.")
829-
return nil
830+
return ErrUserQuit
830831
}
831832

832833
// Find and play the selected episode
@@ -908,7 +909,7 @@ func askAndPlayDownloadedEpisode(episodes []models.Episode, animeURL string, sta
908909

909910
if selectedEpisode == "exit" {
910911
fmt.Println("No episode selected.")
911-
return nil
912+
return ErrUserQuit
912913
}
913914

914915
// Find and play the selected episode

internal/player/player.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func HandleDownloadAndPlay(
261261
case 2:
262262
// Download episodes in a range
263263
if err := HandleBatchDownload(episodes, animeURL); err != nil {
264-
util.Fatal("Failed to download episodes:", err)
264+
return err
265265
}
266266
default:
267267
// Play online - determine the best approach based on URL type
@@ -472,8 +472,10 @@ func downloadAndPlayEpisode(
472472
if err := playVideo(episodePath, episodes, selectedEpisodeNum, animeMalID, updater); err != nil {
473473
return err
474474
}
475+
return nil
475476
}
476-
return nil
477+
// User chose not to watch; terminate flow cleanly
478+
return ErrUserQuit
477479
}
478480

479481
// askForDownload presents a prompt for the user to choose a download option.

0 commit comments

Comments
 (0)