It aint pretty, but it works.

This commit is contained in:
Joseph Milazzo 2025-06-24 17:12:27 -05:00
parent a984859770
commit b5e1e7eddd

View file

@ -1629,15 +1629,15 @@ public class ExternalMetadataService : IExternalMetadataService
} }
/// <summary> /// <summary>
/// Returns true if the series should be marked as completed, checks loosy with #chapters and #series; Also tries /// Returns true if the series should be marked as completed, checks loosey with chapter and series numbers.
/// to use specials to reach the required amount /// Respects Specials to reach the required amount.
/// </summary> /// </summary>
/// <param name="series"></param> /// <param name="series"></param>
/// <param name="chapters"></param> /// <param name="chapters"></param>
/// <param name="externalMetadata"></param> /// <param name="externalMetadata"></param>
/// <param name="maxVolumes"></param> /// <param name="maxVolumes"></param>
/// <returns></returns> /// <returns></returns>
/// <remarks>Updates MaxCount and TotalCount if a loosy check is used to set as completed</remarks> /// <remarks>Updates MaxCount and TotalCount if a loosey check is used to set as completed</remarks>
public static bool IsSeriesCompleted(Series series, List<Chapter> chapters, ExternalSeriesDetailDto externalMetadata, int maxVolumes) public static bool IsSeriesCompleted(Series series, List<Chapter> chapters, ExternalSeriesDetailDto externalMetadata, int maxVolumes)
{ {
// A series is completed if exactly the amount is found // A series is completed if exactly the amount is found
@ -1653,7 +1653,12 @@ public class ExternalMetadataService : IExternalMetadataService
// Note: I've currently opted to keep this an equals to prevent the above bug from happening // Note: I've currently opted to keep this an equals to prevent the above bug from happening
// We *could* change this to >= in the future in case this is reported by users // We *could* change this to >= in the future in case this is reported by users
// If we do; test IsSeriesCompleted_Volumes_TooManySpecials needs to be updated // If we do; test IsSeriesCompleted_Volumes_TooManySpecials needs to be updated
if (maxVolumes != Parser.DefaultChapterNumber && series.Volumes.Count == externalMetadata.Volumes)
// Note: If Kavita has specials, we should be lenient and ignore for the volume check
var volumeModifier = series.Volumes.Any(v => v.Name == Parser.SpecialVolume) ? 1 : 0;
var modifiedMinVolumeCount = series.Volumes.Count - volumeModifier;
if (maxVolumes != Parser.DefaultChapterNumber &&
(externalMetadata.Volumes == series.Volumes.Count || externalMetadata.Volumes == modifiedMinVolumeCount))
{ {
series.Metadata.MaxCount = series.Volumes.Count; series.Metadata.MaxCount = series.Volumes.Count;
series.Metadata.TotalCount = series.Volumes.Count; series.Metadata.TotalCount = series.Volumes.Count;