Skip to content

Commit

Permalink
hotfix: fix episode and special counts for anidb
Browse files Browse the repository at this point in the history
this hotfix fixes the display of normal and special episode counts
in shoko desktop.

[no ci] [skip ci]
  • Loading branch information
revam committed Apr 2, 2023
1 parent 0760ec4 commit 58b17bd
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Shoko.Server/Providers/AniDB/HTTP/AnimeCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ private void CreateEpisodes(List<ResponseEpisode> rawEpisodeList, SVR_AniDB_Anim
{
// Load the titles for the episode now, since we might need to check
// them even if we don't update the episode itself.
var skipCounting = false;
if (!currentAniDBEpisodeTitles.TryGetValue(rawEpisode.EpisodeID, out var currentTitles))
currentTitles = new();

Expand All @@ -194,11 +193,11 @@ private void CreateEpisodes(List<ResponseEpisode> rawEpisodeList, SVR_AniDB_Anim
// If the episode does not belong to the anime being
// processed, or if none of the titles changed since last
// time, then also skip updating the episode titles.
if (episode.AnimeID != rawEpisode.AnimeID ||
currentTitles.Count == rawEpisode.Titles.Count &&
currentTitles.All(t1 => rawEpisode.Titles.Any(t2 => string.Equals(t1.Title, t2.Title))))
if (episode.AnimeID != rawEpisode.AnimeID)
continue;
skipCounting = true;
if (currentTitles.Count == rawEpisode.Titles.Count &&
currentTitles.All(t1 => rawEpisode.Titles.Any(t2 => string.Equals(t1.Title, t2.Title))))
goto count;
}
// Update the existing record.
else
Expand Down Expand Up @@ -252,21 +251,16 @@ private void CreateEpisodes(List<ResponseEpisode> rawEpisodeList, SVR_AniDB_Anim
if (currentTitles.Count > 0)
titlesToRemove.AddRange(currentTitles.Where(a => !newTitles.Any(b => b.Equals(a))));

// Skip counting the episode if we only needed to update the titles
// for it.
if (skipCounting)
continue;

// Since the HTTP API doesn't return a count of the number of normal
// episodes and/or specials, then we will calculate it now.
switch (episode.GetEpisodeTypeEnum())
count: switch (episode.GetEpisodeTypeEnum())
{
case Shoko.Models.Enums.EpisodeType.Episode:
episodeCountNormal++;
break;

case Shoko.Models.Enums.EpisodeType.Special:
episodeCountNormal++;
episodeCountSpecial++;
break;
}
}
Expand Down

0 comments on commit 58b17bd

Please sign in to comment.