refactor: extract season show filter into helper
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user