Commit 0c8b1d233f
Unregistered key
Layout: unified · split
cmd/curd/main.go +15 −14
| @@ -392,6 +392,19 @@ func main() { | |||
| 392 | } | 392 | } |
| 393 | }() | 393 | }() |
| 394 | 394 | ||
| 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 | |||
| 395 | wg.Add(1) | 408 | wg.Add(1) |
| 396 | // Thread to update playback time in database | 409 | // Thread to update playback time in database |
| 397 | go func() { | 410 | go func() { |
| @@ -453,7 +466,6 @@ func main() { | |||
| 453 | if err != nil { | 466 | if err != nil { |
| 454 | internal.Log("Error sending skip times to MPV: " + err.Error()) | 467 | internal.Log("Error sending skip times to MPV: " + err.Error()) |
| 455 | } | 468 | } |
| 456 | fmt.Println("Skip times sent!") // TODO: REMOVE | ||
| 457 | } | 469 | } |
| 458 | 470 | ||
| 459 | // If resume is true, seek to the playback time | 471 | // If resume is true, seek to the playback time |
| @@ -593,19 +605,8 @@ func main() { | |||
| 593 | internal.ExitCurd(nil) | 605 | internal.ExitCurd(nil) |
| 594 | } | 606 | } |
| 595 | 607 | ||
| 596 | if userCurdConfig.NextEpisodePrompt { | 608 | if userCurdConfig.RofiSelection && userCurdConfig.NextEpisodePrompt { |
| 597 | internal.CurdOut(fmt.Sprintf("Start next episode (%d)?", anime.Ep.Number)) | 609 | internal.NextEpisodePrompt(&userCurdConfig) |
| 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 | ||
| 609 | } | 610 | } |
| 610 | 611 | ||
| 611 | internal.CurdOut(fmt.Sprint("Starting next episode: ", anime.Ep.Number)) | 612 | 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 { | |||
| 1221 | return []Entry{} | 1221 | return []Entry{} |
| 1222 | } | 1222 | } |
| 1223 | } | 1223 | } |
| 1224 | |||
| 1225 | func 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 | } | ||