Some testing on Generic library
This commit is contained in:
parent
5423526484
commit
fad70432fb
6 changed files with 26 additions and 6 deletions
|
@ -193,6 +193,7 @@ public class CollectionTagRepository : ICollectionTagRepository
|
|||
.Where(t => t.Id == tag.Id)
|
||||
.SelectMany(uc => uc.Items.Select(s => s.Metadata))
|
||||
.Select(sm => sm.AgeRating)
|
||||
.DefaultIfEmpty()
|
||||
.MaxAsync();
|
||||
tag.AgeRating = maxAgeRating;
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
|
@ -40,8 +40,11 @@ public class Library : IEntityDate
|
|||
/// </summary>
|
||||
/// <remarks>Scrobbling requires a valid LicenseKey</remarks>
|
||||
public bool AllowScrobbling { get; set; } = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extra Regex that can be used for parsing
|
||||
/// </summary>
|
||||
/// <remarks>This is only used for Generic Library</remarks>
|
||||
//public string? ExtraParsingRegex { get; set; }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class ReadingItemService : IReadingItemService
|
|||
private readonly ImageParser _imageParser;
|
||||
private readonly BookParser _bookParser;
|
||||
private readonly PdfParser _pdfParser;
|
||||
private readonly GenericLibraryParser _genericParser;
|
||||
|
||||
public ReadingItemService(IArchiveService archiveService, IBookService bookService, IImageService imageService,
|
||||
IDirectoryService directoryService, ILogger<ReadingItemService> logger)
|
||||
|
@ -43,6 +44,7 @@ public class ReadingItemService : IReadingItemService
|
|||
_bookParser = new BookParser(directoryService, bookService, _basicParser);
|
||||
_comicVineParser = new ComicVineParser(directoryService);
|
||||
_pdfParser = new PdfParser(directoryService);
|
||||
_genericParser = new GenericLibraryParser(directoryService);
|
||||
|
||||
}
|
||||
|
||||
|
@ -177,6 +179,10 @@ public class ReadingItemService : IReadingItemService
|
|||
/// <returns></returns>
|
||||
private ParserInfo? Parse(string path, string rootPath, string libraryRoot, LibraryType type)
|
||||
{
|
||||
if (_genericParser.IsApplicable(path, type))
|
||||
{
|
||||
return _genericParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
|
||||
}
|
||||
if (_comicVineParser.IsApplicable(path, type))
|
||||
{
|
||||
return _comicVineParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
|
||||
|
|
|
@ -17,7 +17,13 @@ public class GenericLibraryParser(IDirectoryService directoryService) : DefaultP
|
|||
public override ParserInfo? Parse(string filePath, string rootPath, string libraryRoot, LibraryType type,
|
||||
ComicInfo? comicInfo = null, IEnumerable<string>? extraRegex = null)
|
||||
{
|
||||
if (extraRegex == null) return null;
|
||||
//if (extraRegex == null) return null;
|
||||
|
||||
// It can be very difficult for the user to supply all the regex needed to properly parse, we might need to let them override (but not sure how this will work)
|
||||
extraRegex = new List<string>()
|
||||
{
|
||||
@"(?<Series>.*)(\b|_)v(?<Volume>\d+-?\d+)( |_)"
|
||||
};
|
||||
|
||||
// The idea is this is passed in as a default param. Only Generic will use it
|
||||
var fileName = directoryService.FileSystem.Path.GetFileNameWithoutExtension(filePath);
|
||||
|
@ -36,7 +42,7 @@ public class GenericLibraryParser(IDirectoryService directoryService) : DefaultP
|
|||
|
||||
foreach (var regex in extraRegex)
|
||||
{
|
||||
var matches = new Regex(regex, RegexOptions.IgnoreCase).Matches(fileName);
|
||||
var matches = new Regex(regex, Parser.MatchOptions, Parser.RegexTimeout).Matches(fileName);
|
||||
foreach (var group in matches.Select(match => match.Groups))
|
||||
{
|
||||
foreach (var matchKey in group.Keys)
|
||||
|
@ -50,6 +56,9 @@ public class GenericLibraryParser(IDirectoryService directoryService) : DefaultP
|
|||
case "Chapter":
|
||||
info.Chapters = SetIfNotDefault(matchValue, info.Chapters);
|
||||
break;
|
||||
case "Volume":
|
||||
info.Volumes = SetIfNotDefault(matchValue, info.Volumes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public static class Parser
|
|||
public const string SupportedExtensions =
|
||||
ArchiveFileExtensions + "|" + ImageFileExtensions + "|" + BookFileExtensions;
|
||||
|
||||
private const RegexOptions MatchOptions =
|
||||
public const RegexOptions MatchOptions =
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant;
|
||||
|
||||
private static readonly ImmutableArray<string> FormatTagSpecialKeywords = ImmutableArray.Create(
|
||||
|
@ -1149,7 +1149,7 @@ public static class Parser
|
|||
|
||||
public static string? ExtractFilename(string fileUrl)
|
||||
{
|
||||
var matches = Parser.CssImageUrlRegex.Matches(fileUrl);
|
||||
var matches = CssImageUrlRegex.Matches(fileUrl);
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
if (!match.Success) continue;
|
||||
|
|
|
@ -16658,6 +16658,7 @@
|
|||
},
|
||||
"created": {
|
||||
"type": "string",
|
||||
"description": "Extra Regex that can be used for parsing",
|
||||
"format": "date-time"
|
||||
},
|
||||
"lastModified": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue