More regex tweaking and use cases for real library.
This commit is contained in:
parent
7cd0b80ac2
commit
fe88467d8b
3 changed files with 44 additions and 36 deletions
|
@ -151,6 +151,10 @@ namespace API.Parser
|
|||
new Regex(
|
||||
@"(?<Cleanup>(\{Complete\}|\[Complete\]|\(Complete\)))",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
// Anything in parenthesis
|
||||
new Regex(
|
||||
@"\(.*\)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
};
|
||||
|
||||
|
||||
|
@ -159,11 +163,13 @@ namespace API.Parser
|
|||
/// from filename.
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="rootPath">Root folder</param>
|
||||
/// <returns><see cref="ParserInfo"/> or null if Series was empty</returns>
|
||||
public static ParserInfo Parse(string filePath)
|
||||
public static ParserInfo? Parse(string filePath, string rootPath)
|
||||
{
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
var directoryName = (new FileInfo(filePath)).Directory?.Name;
|
||||
var rootName = (new DirectoryInfo(rootPath)).Name;
|
||||
|
||||
var ret = new ParserInfo()
|
||||
{
|
||||
|
@ -175,17 +181,14 @@ namespace API.Parser
|
|||
FullFilePath = filePath
|
||||
};
|
||||
|
||||
if (ret.Series == string.Empty)
|
||||
if (ret.Series == string.Empty && directoryName != null && directoryName != rootName)
|
||||
{
|
||||
ret.Series = ParseSeries(directoryName);
|
||||
if (ret.Series == string.Empty) ret.Series = CleanTitle(directoryName);
|
||||
} else if (directoryName != null && directoryName.Contains(ret.Series))
|
||||
{
|
||||
ret.Series = directoryName; // TODO: Validate if this works better overall for grouping.
|
||||
}
|
||||
|
||||
|
||||
var edition = ParseEdition(fileName);
|
||||
if (edition != string.Empty)
|
||||
if (!string.IsNullOrEmpty(edition))
|
||||
{
|
||||
ret.Series = CleanTitle(ret.Series.Replace(edition, ""));
|
||||
ret.Edition = edition;
|
||||
|
|
|
@ -9,12 +9,12 @@ namespace API.Parser
|
|||
public class ParserInfo
|
||||
{
|
||||
// This can be multiple
|
||||
public string Chapters { get; set; }
|
||||
public string Series { get; set; }
|
||||
public string Chapters { get; set; } = "";
|
||||
public string Series { get; set; } = "";
|
||||
// This can be multiple
|
||||
public string Volumes { get; set; }
|
||||
public string Filename { get; init; }
|
||||
public string FullFilePath { get; set; }
|
||||
public string Volumes { get; set; } = "";
|
||||
public string Filename { get; init; } = "";
|
||||
public string FullFilePath { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="MangaFormat"/> that represents the type of the file (so caching service knows how to cache for reading)
|
||||
|
@ -25,9 +25,5 @@ namespace API.Parser
|
|||
/// This can potentially story things like "Omnibus, Color, Full Contact Edition, Extra, Final, etc"
|
||||
/// </summary>
|
||||
public string Edition { get; set; } = "";
|
||||
/// <summary>
|
||||
/// If this file is some sort of side story that links back to some master series.
|
||||
/// </summary>
|
||||
public bool IsSpecial { get; set; } = false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue