mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Implemented the ability to read format tag and force special status. (#1284)
This commit is contained in:
parent
a0e1ba8d67
commit
1a128a3af4
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user