Skip to content

Commit

Permalink
fix: fix season number assignement and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Apr 10, 2024
1 parent 57bbbf4 commit 34e0e66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Shokofin/API/Info/ShowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public ShowInfo(SeasonInfo seasonInfo, string? collectionId = null)
{
var seasonNumberBaseDictionary = new Dictionary<string, int>();
var seasonOrderDictionary = new Dictionary<int, SeasonInfo>();
var seasonNumberOffset = 0;
var seasonNumberOffset = 1;
if (seasonInfo.EpisodeList.Count > 0 || seasonInfo.AlternateEpisodesList.Count > 0)
seasonNumberBaseDictionary.Add(seasonInfo.Id, seasonNumberOffset);
if (seasonInfo.EpisodeList.Count > 0)
Expand Down
5 changes: 4 additions & 1 deletion Shokofin/Utils/Ordering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,11 @@ public static (int?, int?, int?, bool) GetSpecialPlacement(ShowInfo showInfo, Se
/// <returns></returns>
public static int GetSeasonNumber(ShowInfo showInfo, SeasonInfo seasonInfo, EpisodeInfo episodeInfo)
{
if (!showInfo.TryGetBaseSeasonNumberForSeasonInfo(seasonInfo, out var seasonNumber))
if (!showInfo.TryGetBaseSeasonNumberForSeasonInfo(seasonInfo, out var seasonNumber)) {
if (showInfo.IsSpecial(episodeInfo))
return 0;
throw new System.IndexOutOfRangeException($"Series is not part of the provided group. (Group={showInfo.GroupId},Series={seasonInfo.Id})");
}

if (seasonInfo.AlternateEpisodesList.Any(ep => ep.Id == episodeInfo.Id))
return seasonNumber + 1;
Expand Down

0 comments on commit 34e0e66

Please sign in to comment.