New Scanner + People Pages (#3286)
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
parent
1ed0eae22d
commit
ba20ad4ecc
142 changed files with 17529 additions and 3038 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using API.Data.Metadata;
|
||||
using API.Entities.Enums;
|
||||
|
||||
|
@ -79,7 +80,25 @@ public class BasicParser(IDirectoryService directoryService, IDefaultParser imag
|
|||
// NOTE: This uses rootPath. LibraryRoot works better for manga, but it's not always that way.
|
||||
// It might be worth writing some logic if the file is a special, to take the folder above the Specials/
|
||||
// if present
|
||||
ParseFromFallbackFolders(filePath, rootPath, type, ref ret);
|
||||
var tempRootPath = rootPath;
|
||||
if (rootPath.EndsWith("Specials") || rootPath.EndsWith("Specials/"))
|
||||
{
|
||||
tempRootPath = rootPath.Replace("Specials", string.Empty).TrimEnd('/');
|
||||
}
|
||||
|
||||
// Check if the folder the file exists in is Specials/ and if so, take the parent directory as series (cleaned)
|
||||
var fileDirectory = Path.GetDirectoryName(filePath);
|
||||
if (!string.IsNullOrEmpty(fileDirectory) &&
|
||||
(fileDirectory.EndsWith("Specials", StringComparison.OrdinalIgnoreCase) ||
|
||||
fileDirectory.EndsWith("Specials/", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
ret.Series = Parser.CleanTitle(Directory.GetParent(fileDirectory)?.Name ?? string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
ParseFromFallbackFolders(filePath, tempRootPath, type, ref ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(ret.Series))
|
||||
|
|
|
@ -714,8 +714,9 @@ public static class Parser
|
|||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasSpecialMarker(string filePath)
|
||||
public static bool HasSpecialMarker(string? filePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) return false;
|
||||
return SpecialMarkerRegex.IsMatch(filePath);
|
||||
}
|
||||
|
||||
|
@ -728,30 +729,19 @@ public static class Parser
|
|||
|
||||
public static bool IsSpecial(string? filePath, LibraryType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
LibraryType.Manga => IsMangaSpecial(filePath),
|
||||
LibraryType.Comic => IsComicSpecial(filePath),
|
||||
LibraryType.Book => IsMangaSpecial(filePath),
|
||||
LibraryType.Image => IsMangaSpecial(filePath),
|
||||
LibraryType.LightNovel => IsMangaSpecial(filePath),
|
||||
LibraryType.ComicVine => IsComicSpecial(filePath),
|
||||
_ => false
|
||||
};
|
||||
return HasSpecialMarker(filePath);
|
||||
}
|
||||
|
||||
private static bool IsMangaSpecial(string? filePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) return false;
|
||||
filePath = ReplaceUnderscores(filePath);
|
||||
return MangaSpecialRegex.IsMatch(filePath);
|
||||
return HasSpecialMarker(filePath);
|
||||
}
|
||||
|
||||
private static bool IsComicSpecial(string? filePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) return false;
|
||||
filePath = ReplaceUnderscores(filePath);
|
||||
return ComicSpecialRegex.IsMatch(filePath);
|
||||
return HasSpecialMarker(filePath);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,13 @@ public class PdfParser(IDirectoryService directoryService) : DefaultParser(direc
|
|||
ret.Chapters = Parser.DefaultChapter;
|
||||
ret.Volumes = Parser.SpecialVolume;
|
||||
|
||||
ParseFromFallbackFolders(filePath, rootPath, type, ref ret);
|
||||
var tempRootPath = rootPath;
|
||||
if (rootPath.EndsWith("Specials") || rootPath.EndsWith("Specials/"))
|
||||
{
|
||||
tempRootPath = rootPath.Replace("Specials", string.Empty).TrimEnd('/');
|
||||
}
|
||||
|
||||
ParseFromFallbackFolders(filePath, tempRootPath, type, ref ret);
|
||||
}
|
||||
|
||||
if (ret.Chapters == Parser.DefaultChapter && ret.Volumes == Parser.LooseLeafVolume && type == LibraryType.Book)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue