Commit 0c8b1d233f

0c8b1d233f2f698748d1081cbfe6c0c230bdbf19

parent: e1d6a35cf6

Unregistered key

Rushikesh Gaikwad <81632222+Wraient@users.noreply.github.com> · 2025-02-28 02:26 UTC
committer: <noreply@github.com>

Feat: Show next episode prompt from start of episode for CLI mode (#51)

* Feat: Show next episode prompt from start of episode for CLI mode

* chore: Remove unncessary output

Layout: unified · split

cmd/curd/main.go +15 −14
@@ -392,6 +392,19 @@ func main() {
392392 }
393393 }()
394394
395 // Thread to prompt for next episode in CLI Mode
396 go func() {
397 if !userCurdConfig.RofiSelection && userCurdConfig.NextEpisodePrompt {
398 internal.NextEpisodePrompt(&userCurdConfig)
399 anime.Ep.Number++
400 anime.Ep.Started = false
401 internal.Log("Completed episode, starting next.")
402 anime.Ep.IsCompleted = true
403 // Exit the skip loop
404 close(skipLoopDone)
405 }
406 }()
407
395408 wg.Add(1)
396409 // Thread to update playback time in database
397410 go func() {
@@ -453,7 +466,6 @@ func main() {
453466 if err != nil {
454467 internal.Log("Error sending skip times to MPV: " + err.Error())
455468 }
456 fmt.Println("Skip times sent!") // TODO: REMOVE
457469 }
458470
459471 // If resume is true, seek to the playback time
@@ -593,19 +605,8 @@ func main() {
593605 internal.ExitCurd(nil)
594606 }
595607
596 if userCurdConfig.NextEpisodePrompt {
597 internal.CurdOut(fmt.Sprintf("Start next episode (%d)?", anime.Ep.Number))
598
599 selectedOption, err := internal.DynamicSelect(map[string]string{"yes": "Yes"})
600 if err != nil {
601 internal.ExitCurd(err)
602 }
603
604 if selectedOption.Key != "yes" {
605 internal.ExitMPV(anime.Ep.Player.SocketPath)
606 internal.ExitCurd(nil)
607 }
608 // If yes or any other case, continue with the next episode
608 if userCurdConfig.RofiSelection && userCurdConfig.NextEpisodePrompt {
609 internal.NextEpisodePrompt(&userCurdConfig)
609610 }
610611
611612 internal.CurdOut(fmt.Sprint("Starting next episode: ", anime.Ep.Number))
internal/curd.go +22
@@ -1221,3 +1221,25 @@ func getEntriesByCategory(list AnimeList, category string) []Entry {
12211221 return []Entry{}
12221222 }
12231223}
1224
1225func NextEpisodePrompt(userCurdConfig *CurdConfig) {
1226 anime := GetGlobalAnime()
1227 // If in CLI mode (not Rofi), we need to show the next episode number
1228 episodeNum := anime.Ep.Number
1229 if !userCurdConfig.RofiSelection {
1230 episodeNum++
1231 }
1232
1233 CurdOut(fmt.Sprintf("Start next episode (%d)?", episodeNum))
1234
1235 selectedOption, err := DynamicSelect(map[string]string{"yes": "Yes"})
1236 if err != nil {
1237 ExitCurd(err)
1238 }
1239
1240 if selectedOption.Key != "yes" {
1241 ExitMPV(anime.Ep.Player.SocketPath)
1242 ExitCurd(nil)
1243 }
1244 // If yes or any other case, continue with the next episode
1245}