Skip to content

Commit 58b17bd

Browse files
committed
hotfix: fix episode and special counts for anidb
this hotfix fixes the display of normal and special episode counts in shoko desktop. [no ci] [skip ci]
1 parent 0760ec4 commit 58b17bd

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Shoko.Server/Providers/AniDB/HTTP/AnimeCreator.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ private void CreateEpisodes(List<ResponseEpisode> rawEpisodeList, SVR_AniDB_Anim
180180
{
181181
// Load the titles for the episode now, since we might need to check
182182
// them even if we don't update the episode itself.
183-
var skipCounting = false;
184183
if (!currentAniDBEpisodeTitles.TryGetValue(rawEpisode.EpisodeID, out var currentTitles))
185184
currentTitles = new();
186185

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

255-
// Skip counting the episode if we only needed to update the titles
256-
// for it.
257-
if (skipCounting)
258-
continue;
259-
260254
// Since the HTTP API doesn't return a count of the number of normal
261255
// episodes and/or specials, then we will calculate it now.
262-
switch (episode.GetEpisodeTypeEnum())
256+
count: switch (episode.GetEpisodeTypeEnum())
263257
{
264258
case Shoko.Models.Enums.EpisodeType.Episode:
265259
episodeCountNormal++;
266260
break;
267261

268262
case Shoko.Models.Enums.EpisodeType.Special:
269-
episodeCountNormal++;
263+
episodeCountSpecial++;
270264
break;
271265
}
272266
}

0 commit comments

Comments
 (0)