refactor: extract season show filter into helper

This commit is contained in:
2026-07-06 18:36:36 +02:00
parent c4f276b72d
commit 15e08e1460

View File

@@ -89,10 +89,7 @@ func (c *AllAnimeProvider) SeasonalShows(ctx context.Context, season string, yea
raw, _ := edge.(map[string]any)
show := providerShowFrom(raw)
newestYear = max(newestYear, show.Year)
if show.Year != year {
continue
}
if show.MalID <= 0 || seen[show.MalID] || show.Type != "TV" || max(len(show.SubEpisodes), len(show.DubEpisodes)) == 0 {
if seen[show.MalID] || !isPlayableSeasonShow(show, year) {
continue
}
seen[show.MalID] = true
@@ -105,6 +102,10 @@ func (c *AllAnimeProvider) SeasonalShows(ctx context.Context, season string, yea
return out, nil
}
func isPlayableSeasonShow(show ProviderShow, year int) bool {
return show.Year == year && show.MalID > 0 && show.Type == "TV" && max(len(show.SubEpisodes), len(show.DubEpisodes)) > 0
}
func providerShowFrom(raw map[string]any) ProviderShow {
detail, _ := raw["availableEpisodesDetail"].(map[string]any)
season, _ := raw["season"].(map[string]any)