Commit 3957bf0a41
Unsigned
Layout: unified · split
cmd/curd/main.go +33 −7
| @@ -212,16 +212,42 @@ func main() { | |||
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | // Start curd | 214 | // Start curd |
| 215 | if !((anime.Ep.IsFiller && userCurdConfig.SkipFiller) || (anime.Ep.IsRecap && userCurdConfig.SkipRecap)) { | 215 | for { |
| 216 | // fmt.Println("Not a filler episode, Starting: ", anime.Ep.Number) | 216 | // Check if current episode is filler/recap |
| 217 | anime.Ep.Player.SocketPath = internal.StartCurd(&userCurdConfig, &anime, logFile) | 217 | err = internal.GetEpisodeData(anime.MalId, anime.Ep.Number, &anime) |
| 218 | if err != nil { | ||
| 219 | internal.Log("Error getting episode data, assuming non-filler: "+err.Error(), logFile) | ||
| 220 | break // Break the loop and continue with playback | ||
| 221 | } | ||
| 218 | 222 | ||
| 219 | internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile) | 223 | // If not filler/recap (or skip is disabled), break and continue with playback |
| 220 | internal.Log(anime.Ep.Player.SocketPath, logFile) | 224 | if !((anime.Ep.IsFiller && userCurdConfig.SkipFiller) || (anime.Ep.IsRecap && userCurdConfig.SkipRecap)) { |
| 221 | } else { | 225 | break |
| 222 | internal.CurdOut(fmt.Sprint("Filler episode, skipping: ", anime.Ep.Number)) | 226 | } |
| 227 | |||
| 228 | // If it is filler/recap, log it and move to next episode | ||
| 229 | if anime.Ep.IsFiller { | ||
| 230 | internal.CurdOut(fmt.Sprint("Filler episode, skipping: ", anime.Ep.Number)) | ||
| 231 | } else { | ||
| 232 | internal.CurdOut(fmt.Sprint("Recap episode, skipping: ", anime.Ep.Number)) | ||
| 233 | } | ||
| 234 | |||
| 235 | anime.Ep.Number++ | ||
| 236 | anime.Ep.Started = false | ||
| 237 | internal.LocalUpdateAnime(databaseFile, anime.AnilistId, anime.AllanimeId, anime.Ep.Number, 0, 0, internal.GetAnimeName(anime)) | ||
| 238 | |||
| 239 | // Check if we've reached the end of the series | ||
| 240 | if anime.Ep.Number > anime.TotalEpisodes { | ||
| 241 | internal.CurdOut("Reached end of series") | ||
| 242 | internal.ExitCurd(nil) | ||
| 243 | } | ||
| 223 | } | 244 | } |
| 224 | 245 | ||
| 246 | // Now start playback for the non-filler episode | ||
| 247 | anime.Ep.Player.SocketPath = internal.StartCurd(&userCurdConfig, &anime, logFile) | ||
| 248 | internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile) | ||
| 249 | internal.Log(anime.Ep.Player.SocketPath, logFile) | ||
| 250 | |||
| 225 | wg.Add(1) | 251 | wg.Add(1) |
| 226 | // Get episode data | 252 | // Get episode data |
| 227 | go func() { | 253 | go func() { |
internal/jikan.go +10 −2
| @@ -14,7 +14,11 @@ func GetEpisodeData(animeID int, episodeNo int, anime *Anime) error { | |||
| 14 | // Use the helper function for making the GET request | 14 | // Use the helper function for making the GET request |
| 15 | response, err := makeGetRequest(url, nil) | 15 | response, err := makeGetRequest(url, nil) |
| 16 | if err != nil { | 16 | if err != nil { |
| 17 | return fmt.Errorf("error fetching data from Jikan (MyAnimeList) API: %w", err) | 17 | Log(fmt.Sprintf("Warning: Jikan API error: %v - continuing without filler data", err), logFile) |
| 18 | // Set default values when API fails | ||
| 19 | anime.Ep.IsFiller = false | ||
| 20 | anime.Ep.IsRecap = false | ||
| 21 | return nil // Return nil to allow the application to continue | ||
| 18 | } | 22 | } |
| 19 | 23 | ||
| 20 | Log(response, logFile) | 24 | Log(response, logFile) |
| @@ -22,7 +26,11 @@ func GetEpisodeData(animeID int, episodeNo int, anime *Anime) error { | |||
| 22 | // Check if the 'data' field exists and is valid | 26 | // Check if the 'data' field exists and is valid |
| 23 | data, ok := response["data"].(map[string]interface{}) | 27 | data, ok := response["data"].(map[string]interface{}) |
| 24 | if !ok { | 28 | if !ok { |
| 25 | return fmt.Errorf("invalid response structure: missing or invalid 'data' field") | 29 | Log("Warning: Invalid Jikan API response - continuing without filler data", logFile) |
| 30 | // Set default values when response is invalid | ||
| 31 | anime.Ep.IsFiller = false | ||
| 32 | anime.Ep.IsRecap = false | ||
| 33 | return nil // Return nil to allow the application to continue | ||
| 26 | } | 34 | } |
| 27 | // Helper function to safely get string value | 35 | // Helper function to safely get string value |
| 28 | getStringValue := func(field string) string { | 36 | getStringValue := func(field string) string { |