Commit 3957bf0a41

3957bf0a4174d04bba56332d63de7f4cf17922a3

parent: c71c910434

Unsigned

Wraient <wraient.911@gmail.com> · 2024-12-18 17:03 UTC

fix: Filler skip works are a block of filler episodes

Layout: unified · split

cmd/curd/main.go +33 −7
@@ -212,16 +212,42 @@ func main() {
212212 }
213213
214214 // Start curd
215 if !((anime.Ep.IsFiller && userCurdConfig.SkipFiller) || (anime.Ep.IsRecap && userCurdConfig.SkipRecap)) {
216 // fmt.Println("Not a filler episode, Starting: ", anime.Ep.Number)
217 anime.Ep.Player.SocketPath = internal.StartCurd(&userCurdConfig, &anime, logFile)
215 for {
216 // Check if current episode is filler/recap
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 }
218222
219 internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile)
220 internal.Log(anime.Ep.Player.SocketPath, logFile)
221 } else {
222 internal.CurdOut(fmt.Sprint("Filler episode, skipping: ", anime.Ep.Number))
223 // If not filler/recap (or skip is disabled), break and continue with playback
224 if !((anime.Ep.IsFiller && userCurdConfig.SkipFiller) || (anime.Ep.IsRecap && userCurdConfig.SkipRecap)) {
225 break
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 }
223244 }
224245
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
225251 wg.Add(1)
226252 // Get episode data
227253 go func() {
internal/jikan.go +10 −2
@@ -14,7 +14,11 @@ func GetEpisodeData(animeID int, episodeNo int, anime *Anime) error {
1414 // Use the helper function for making the GET request
1515 response, err := makeGetRequest(url, nil)
1616 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
1822 }
1923
2024 Log(response, logFile)
@@ -22,7 +26,11 @@ func GetEpisodeData(animeID int, episodeNo int, anime *Anime) error {
2226 // Check if the 'data' field exists and is valid
2327 data, ok := response["data"].(map[string]interface{})
2428 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
2634 }
2735 // Helper function to safely get string value
2836 getStringValue := func(field string) string {