Skip to content

Commit

Permalink
fix: re-create specials anchors if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed May 13, 2024
1 parent d78f3bb commit 2a34bde
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Shokofin/API/Info/SeasonInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,24 @@ public SeasonInfo(Series series, DateTime? earliestImportedAt, DateTime? lastImp

episodesList = altEpisodesList;
altEpisodesList = new();

// Re-create the special anchors because the episode list changed.
index = 0;
lastNormalEpisode = 0;
specialsAnchorDictionary.Clear();
foreach (var episode in episodes) {
if (episodesList.Contains(episode)) {
lastNormalEpisode = index;
}
else if (specialsList.Contains(episode)) {
var previousEpisode = episodes
.GetRange(lastNormalEpisode, index - lastNormalEpisode)
.FirstOrDefault(e => e.AniDB.Type == EpisodeType.Normal);
if (previousEpisode != null)
specialsAnchorDictionary[episode] = previousEpisode;
}
index++;
}
}

if (Plugin.Instance.Configuration.MovieSpecialsAsExtraFeaturettes && type == SeriesType.Movie) {
Expand Down

0 comments on commit 2a34bde

Please sign in to comment.