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)
|
.Where(t => t.Id == tag.Id)
|
||||||
.SelectMany(uc => uc.Items.Select(s => s.Metadata))
|
.SelectMany(uc => uc.Items.Select(s => s.Metadata))
|
||||||
.Select(sm => sm.AgeRating)
|
.Select(sm => sm.AgeRating)
|
||||||
|
.DefaultIfEmpty()
|
||||||
.MaxAsync();
|
.MaxAsync();
|
||||||
tag.AgeRating = maxAgeRating;
|
tag.AgeRating = maxAgeRating;
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
|
@ -40,8 +40,11 @@ public class Library : IEntityDate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Scrobbling requires a valid LicenseKey</remarks>
|
/// <remarks>Scrobbling requires a valid LicenseKey</remarks>
|
||||||
public bool AllowScrobbling { get; set; } = true;
|
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 ImageParser _imageParser;
|
||||||
private readonly BookParser _bookParser;
|
private readonly BookParser _bookParser;
|
||||||
private readonly PdfParser _pdfParser;
|
private readonly PdfParser _pdfParser;
|
||||||
|
private readonly GenericLibraryParser _genericParser;
|
||||||
|
|
||||||
public ReadingItemService(IArchiveService archiveService, IBookService bookService, IImageService imageService,
|
public ReadingItemService(IArchiveService archiveService, IBookService bookService, IImageService imageService,
|
||||||
IDirectoryService directoryService, ILogger<ReadingItemService> logger)
|
IDirectoryService directoryService, ILogger<ReadingItemService> logger)
|
||||||
|
@ -43,6 +44,7 @@ public class ReadingItemService : IReadingItemService
|
||||||
_bookParser = new BookParser(directoryService, bookService, _basicParser);
|
_bookParser = new BookParser(directoryService, bookService, _basicParser);
|
||||||
_comicVineParser = new ComicVineParser(directoryService);
|
_comicVineParser = new ComicVineParser(directoryService);
|
||||||
_pdfParser = new PdfParser(directoryService);
|
_pdfParser = new PdfParser(directoryService);
|
||||||
|
_genericParser = new GenericLibraryParser(directoryService);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +179,10 @@ public class ReadingItemService : IReadingItemService
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private ParserInfo? Parse(string path, string rootPath, string libraryRoot, LibraryType type)
|
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))
|
if (_comicVineParser.IsApplicable(path, type))
|
||||||
{
|
{
|
||||||
return _comicVineParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
|
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,
|
public override ParserInfo? Parse(string filePath, string rootPath, string libraryRoot, LibraryType type,
|
||||||
ComicInfo? comicInfo = null, IEnumerable<string>? extraRegex = null)
|
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
|
// The idea is this is passed in as a default param. Only Generic will use it
|
||||||
var fileName = directoryService.FileSystem.Path.GetFileNameWithoutExtension(filePath);
|
var fileName = directoryService.FileSystem.Path.GetFileNameWithoutExtension(filePath);
|
||||||
|
@ -36,7 +42,7 @@ public class GenericLibraryParser(IDirectoryService directoryService) : DefaultP
|
||||||
|
|
||||||
foreach (var regex in extraRegex)
|
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 group in matches.Select(match => match.Groups))
|
||||||
{
|
{
|
||||||
foreach (var matchKey in group.Keys)
|
foreach (var matchKey in group.Keys)
|
||||||
|
@ -50,6 +56,9 @@ public class GenericLibraryParser(IDirectoryService directoryService) : DefaultP
|
||||||
case "Chapter":
|
case "Chapter":
|
||||||
info.Chapters = SetIfNotDefault(matchValue, info.Chapters);
|
info.Chapters = SetIfNotDefault(matchValue, info.Chapters);
|
||||||
break;
|
break;
|
||||||
|
case "Volume":
|
||||||
|
info.Volumes = SetIfNotDefault(matchValue, info.Volumes);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public static class Parser
|
||||||
public const string SupportedExtensions =
|
public const string SupportedExtensions =
|
||||||
ArchiveFileExtensions + "|" + ImageFileExtensions + "|" + BookFileExtensions;
|
ArchiveFileExtensions + "|" + ImageFileExtensions + "|" + BookFileExtensions;
|
||||||
|
|
||||||
private const RegexOptions MatchOptions =
|
public const RegexOptions MatchOptions =
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant;
|
RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant;
|
||||||
|
|
||||||
private static readonly ImmutableArray<string> FormatTagSpecialKeywords = ImmutableArray.Create(
|
private static readonly ImmutableArray<string> FormatTagSpecialKeywords = ImmutableArray.Create(
|
||||||
|
@ -1149,7 +1149,7 @@ public static class Parser
|
||||||
|
|
||||||
public static string? ExtractFilename(string fileUrl)
|
public static string? ExtractFilename(string fileUrl)
|
||||||
{
|
{
|
||||||
var matches = Parser.CssImageUrlRegex.Matches(fileUrl);
|
var matches = CssImageUrlRegex.Matches(fileUrl);
|
||||||
foreach (Match match in matches)
|
foreach (Match match in matches)
|
||||||
{
|
{
|
||||||
if (!match.Success) continue;
|
if (!match.Success) continue;
|
||||||
|
|
|
@ -16658,6 +16658,7 @@
|
||||||
},
|
},
|
||||||
"created": {
|
"created": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
"description": "Extra Regex that can be used for parsing",
|
||||||
"format": "date-time"
|
"format": "date-time"
|
||||||
},
|
},
|
||||||
"lastModified": {
|
"lastModified": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue