Implemented the ability to read format tag and force special status. (#1284)

This commit is contained in:
Joseph Milazzo 2022-05-25 12:05:16 -05:00 committed by GitHub
parent a0e1ba8d67
commit 1a128a3af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 1 deletions

View File

@ -62,6 +62,11 @@ namespace API.Data.Metadata
/// Represents the sort order for the title /// Represents the sort order for the title
/// </summary> /// </summary>
public string TitleSort { get; set; } = string.Empty; public string TitleSort { get; set; } = string.Empty;
/// <summary>
/// This comes from ComicInfo and is free form text. We use this to validate against a set of tags and mark a file as
/// special.
/// </summary>
public string Format { get; set; } = string.Empty;
/// <summary> /// <summary>
/// The translator, can be comma separated. This is part of ComicInfo.xml draft v2.1 /// The translator, can be comma separated. This is part of ComicInfo.xml draft v2.1

View File

@ -85,7 +85,7 @@ public class DefaultParser
if (ret.Chapters == Parser.DefaultChapter && ret.Volumes == Parser.DefaultVolume && !string.IsNullOrEmpty(isSpecial)) if (ret.Chapters == Parser.DefaultChapter && ret.Volumes == Parser.DefaultVolume && !string.IsNullOrEmpty(isSpecial))
{ {
ret.IsSpecial = true; ret.IsSpecial = true;
ParseFromFallbackFolders(filePath, rootPath, type, ref ret); ParseFromFallbackFolders(filePath, rootPath, type, ref ret); // NOTE: This can cause some complications, we should try to be a bit less aggressive to fallback to folder
} }
// If we are a special with marker, we need to ensure we use the correct series name. we can do this by falling back to Folder name // If we are a special with marker, we need to ensure we use the correct series name. we can do this by falling back to Folder name

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Immutable;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -512,6 +513,11 @@ namespace API.Parser
MatchOptions, RegexTimeout MatchOptions, RegexTimeout
); );
private static readonly ImmutableArray<string> FormatTagSpecialKeyowrds = ImmutableArray.Create(
"Special", "Reference", "Director's Cut", "Box Set", "Box-Set", "Annual", "Anthology", "Epilogue",
"One Shot", "One-Shot", "Prologue", "TPB", "Trade Paper Back", "Omnibus", "Compendium", "Absolute", "Graphic Novel",
"GN", "FCBD");
public static MangaFormat ParseFormat(string filePath) public static MangaFormat ParseFormat(string filePath)
{ {
if (IsArchive(filePath)) return MangaFormat.Archive; if (IsArchive(filePath)) return MangaFormat.Archive;
@ -1034,5 +1040,15 @@ namespace API.Parser
{ {
return path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); return path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
} }
/// <summary>
/// Checks against a set of strings to validate if a ComicInfo.Format should receive special treatment
/// </summary>
/// <param name="comicInfoFormat"></param>
/// <returns></returns>
public static bool HasComicInfoSpecial(string comicInfoFormat)
{
return FormatTagSpecialKeyowrds.Contains(comicInfoFormat);
}
} }
} }

View File

@ -122,6 +122,13 @@ namespace API.Services.Tasks.Scanner
info.SeriesSort = info.ComicInfo.TitleSort.Trim(); info.SeriesSort = info.ComicInfo.TitleSort.Trim();
} }
if (!string.IsNullOrEmpty(info.ComicInfo.Format) && Parser.Parser.HasComicInfoSpecial(info.ComicInfo.Format))
{
info.IsSpecial = true;
info.Chapters = Parser.Parser.DefaultChapter;
info.Volumes = Parser.Parser.DefaultVolume;
}
if (!string.IsNullOrEmpty(info.ComicInfo.SeriesSort)) if (!string.IsNullOrEmpty(info.ComicInfo.SeriesSort))
{ {
info.SeriesSort = info.ComicInfo.SeriesSort.Trim(); info.SeriesSort = info.ComicInfo.SeriesSort.Trim();