Loosen requirements for Publication status fixes #3794
- Don't use volume count for MaxCount if there are no volumes - Try using specials to reach external volume count - Try matching chapters loosly (>=) when matching external chapter count - Try using specials (prologue's, extra's) when matching external chapter count
This commit is contained in:
parent
f54e2f3c2a
commit
1b54b004db
1 changed files with 54 additions and 5 deletions
|
|
@ -1582,16 +1582,16 @@ public class ExternalMetadataService : IExternalMetadataService
|
||||||
var maxVolume = (int)(nonSpecialVolumes.Count != 0 ? nonSpecialVolumes.Max(v => v.MaxNumber) : 0);
|
var maxVolume = (int)(nonSpecialVolumes.Count != 0 ? nonSpecialVolumes.Max(v => v.MaxNumber) : 0);
|
||||||
var maxChapter = (int)chapters.Max(c => c.MaxNumber);
|
var maxChapter = (int)chapters.Max(c => c.MaxNumber);
|
||||||
|
|
||||||
if (series.Format == MangaFormat.Epub || series.Format == MangaFormat.Pdf && chapters.Count == 1)
|
if (series.Format is MangaFormat.Epub or MangaFormat.Pdf && chapters.Count == 1)
|
||||||
{
|
{
|
||||||
series.Metadata.MaxCount = 1;
|
series.Metadata.MaxCount = 1;
|
||||||
}
|
}
|
||||||
else if (series.Metadata.TotalCount <= 1 && chapters.Count == 1 && chapters[0].IsSpecial)
|
else if (series.Metadata.TotalCount <= 1 && chapters is [{ IsSpecial: true }])
|
||||||
{
|
{
|
||||||
series.Metadata.MaxCount = series.Metadata.TotalCount;
|
series.Metadata.MaxCount = series.Metadata.TotalCount;
|
||||||
}
|
}
|
||||||
else if ((maxChapter == Parser.DefaultChapterNumber || maxChapter > series.Metadata.TotalCount) &&
|
else if ((maxChapter == Parser.DefaultChapterNumber || maxChapter > series.Metadata.TotalCount) &&
|
||||||
maxVolume <= series.Metadata.TotalCount)
|
maxVolume <= series.Metadata.TotalCount && maxVolume != Parser.DefaultChapterNumber)
|
||||||
{
|
{
|
||||||
series.Metadata.MaxCount = maxVolume;
|
series.Metadata.MaxCount = maxVolume;
|
||||||
}
|
}
|
||||||
|
|
@ -1612,8 +1612,7 @@ public class ExternalMetadataService : IExternalMetadataService
|
||||||
{
|
{
|
||||||
status = PublicationStatus.Ended;
|
status = PublicationStatus.Ended;
|
||||||
|
|
||||||
// Check if all volumes/chapters match the total count
|
if (IsSeriesCompleted(series, chapters, externalMetadata, maxVolume, maxChapter))
|
||||||
if (series.Metadata.MaxCount == series.Metadata.TotalCount && series.Metadata.TotalCount > 0)
|
|
||||||
{
|
{
|
||||||
status = PublicationStatus.Completed;
|
status = PublicationStatus.Completed;
|
||||||
}
|
}
|
||||||
|
|
@ -1629,6 +1628,56 @@ public class ExternalMetadataService : IExternalMetadataService
|
||||||
return PublicationStatus.OnGoing;
|
return PublicationStatus.OnGoing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the series should be marked as completed, checks loosy with #chapters and #series; Also tries
|
||||||
|
/// to use specials to reach the required amount
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="series"></param>
|
||||||
|
/// <param name="chapters"></param>
|
||||||
|
/// <param name="externalMetadata"></param>
|
||||||
|
/// <param name="maxVolumes"></param>
|
||||||
|
/// <param name="maxChapters"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks>Updates MaxCount and TotalCount if a loosy check is used to set as completed</remarks>
|
||||||
|
private static bool IsSeriesCompleted(Series series, List<Chapter> chapters, ExternalSeriesDetailDto externalMetadata, int maxVolumes, int maxChapters)
|
||||||
|
{
|
||||||
|
// A series is completed if exactly the amount is found
|
||||||
|
if (series.Metadata.MaxCount == series.Metadata.TotalCount && series.Metadata.TotalCount > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If volumes are collected, check if we reach the required volumes by including specials
|
||||||
|
//
|
||||||
|
// TODO BUG: If the series has specials, that are not included in the external count. But you do own them
|
||||||
|
// This may mark the series as completed pre-maturely
|
||||||
|
if (maxVolumes != Parser.DefaultChapterNumber && series.Volumes.Count == externalMetadata.Volumes)
|
||||||
|
{
|
||||||
|
series.Metadata.MaxCount = series.Volumes.Count;
|
||||||
|
series.Metadata.TotalCount = series.Volumes.Count;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no volumes are collected, the series is completed if we reach or exceed the external chapters
|
||||||
|
if (maxVolumes == Parser.DefaultChapterNumber && series.Metadata.MaxCount >= externalMetadata.Chapters)
|
||||||
|
{
|
||||||
|
series.Metadata.TotalCount = series.Metadata.MaxCount;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no volumes are collected, the series is complete if we reach or exceed the external chapters while including
|
||||||
|
// prologues, and extra chapters
|
||||||
|
if (maxVolumes == Parser.DefaultChapterNumber && chapters.Count >= externalMetadata.Chapters)
|
||||||
|
{
|
||||||
|
series.Metadata.TotalCount = chapters.Count;
|
||||||
|
series.Metadata.MaxCount = chapters.Count;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static Dictionary<MetadataFieldType, List<string>> ApplyFieldMappings(IEnumerable<string> values, MetadataFieldType sourceType, List<MetadataFieldMappingDto> mappings)
|
private static Dictionary<MetadataFieldType, List<string>> ApplyFieldMappings(IEnumerable<string> values, MetadataFieldType sourceType, List<MetadataFieldMappingDto> mappings)
|
||||||
{
|
{
|
||||||
var result = new Dictionary<MetadataFieldType, List<string>>();
|
var result = new Dictionary<MetadataFieldType, List<string>>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue