Last Read Filter + A lot of bug fixes (#3312)

This commit is contained in:
Joe Milazzo 2024-10-27 09:39:10 -05:00 committed by GitHub
parent 953d80de1a
commit 6b13db129e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 620 additions and 198 deletions

View file

@ -14,6 +14,7 @@ using API.Data.Metadata;
using API.Data.Repositories;
using API.Entities;
using API.Entities.Enums;
using API.Extensions;
using API.Helpers;
using API.Helpers.Builders;
using API.Services;
@ -157,6 +158,34 @@ public class ScannerServiceTests : AbstractDbTest
Assert.Equal(3, postLib.Series.First().Volumes.Count);
}
[Fact]
public async Task ScanLibrary_LocalizedSeries2()
{
const string testcase = "Series with Localized 2 - Manga.json";
// Get the first file and generate a ComicInfo
var infos = new Dictionary<string, ComicInfo>();
infos.Add("Immoral Guild v01.cbz", new ComicInfo()
{
Series = "Immoral Guild",
LocalizedSeries = "Futoku no Guild" // Filename has a capital N and localizedSeries has lowercase
});
var library = await GenerateScannerData(testcase, infos);
var scanner = CreateServices();
await scanner.ScanLibrary(library.Id);
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
Assert.NotNull(postLib);
Assert.Single(postLib.Series);
var s = postLib.Series.First();
Assert.Equal("Immoral Guild", s.Name);
Assert.Equal("Futoku no Guild", s.LocalizedName);
Assert.Equal(3, s.Volumes.Count);
}
/// <summary>
/// Files under a folder with a SP marker should group into one issue
@ -179,6 +208,109 @@ public class ScannerServiceTests : AbstractDbTest
Assert.Equal(3, postLib.Series.First().Volumes.Count);
}
/// <summary>
/// This test is currently disabled because the Image parser is unable to support multiple files mapping into one single Special.
/// https://github.com/Kareadita/Kavita/issues/3299
/// </summary>
public async Task ScanLibrary_ImageSeries_SpecialGrouping_NonEnglish()
{
const string testcase = "Image Series with SP Folder (Non English) - Image.json";
var library = await GenerateScannerData(testcase);
var scanner = CreateServices();
await scanner.ScanLibrary(library.Id);
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
Assert.NotNull(postLib);
Assert.Single(postLib.Series);
var series = postLib.Series.First();
Assert.Equal(3, series.Volumes.Count);
var specialVolume = series.Volumes.FirstOrDefault(v => v.Name == Parser.SpecialVolume);
Assert.NotNull(specialVolume);
Assert.Single(specialVolume.Chapters);
Assert.True(specialVolume.Chapters.First().IsSpecial);
//Assert.Equal("葬送のフリーレン 公式ファンブック SP01", specialVolume.Chapters.First().Title);
}
[Fact]
public async Task ScanLibrary_PublishersInheritFromChapters()
{
const string testcase = "Flat Special - Manga.json";
var infos = new Dictionary<string, ComicInfo>();
infos.Add("Uzaki-chan Wants to Hang Out! v01 (2019) (Digital) (danke-Empire).cbz", new ComicInfo()
{
Publisher = "Correct Publisher"
});
infos.Add("Uzaki-chan Wants to Hang Out! - 2022 New Years Special SP01.cbz", new ComicInfo()
{
Publisher = "Special Publisher"
});
infos.Add("Uzaki-chan Wants to Hang Out! - Ch. 103 - Kouhai and Control.cbz", new ComicInfo()
{
Publisher = "Chapter Publisher"
});
var library = await GenerateScannerData(testcase, infos);
var scanner = CreateServices();
await scanner.ScanLibrary(library.Id);
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
Assert.NotNull(postLib);
Assert.Single(postLib.Series);
var publishers = postLib.Series.First().Metadata.People
.Where(p => p.Role == PersonRole.Publisher);
Assert.Equal(3, publishers.Count());
}
/// <summary>
/// Tests that pdf parser handles the loose chapters correctly
/// https://github.com/Kareadita/Kavita/issues/3148
/// </summary>
[Fact]
public async Task ScanLibrary_LooseChapters_Pdf()
{
const string testcase = "PDF Comic Chapters - Comic.json";
var library = await GenerateScannerData(testcase);
var scanner = CreateServices();
await scanner.ScanLibrary(library.Id);
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
Assert.NotNull(postLib);
Assert.Single(postLib.Series);
var series = postLib.Series.First();
Assert.Single(series.Volumes);
Assert.Equal(4, series.Volumes.First().Chapters.Count);
}
[Fact]
public async Task ScanLibrary_LooseChapters_Pdf_LN()
{
const string testcase = "PDF Comic Chapters - LightNovel.json";
var library = await GenerateScannerData(testcase);
var scanner = CreateServices();
await scanner.ScanLibrary(library.Id);
var postLib = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
Assert.NotNull(postLib);
Assert.Single(postLib.Series);
var series = postLib.Series.First();
Assert.Single(series.Volumes);
Assert.Equal(4, series.Volumes.First().Chapters.Count);
}
#region Setup
private async Task<Library> GenerateScannerData(string testcase, Dictionary<string, ComicInfo> comicInfos = null)

View file

@ -0,0 +1,5 @@
[
"葬送のフィリーレン/葬送のフィリーレン vol 1/0001.png",
"葬送のフィリーレン/葬送のフィリーレン vol 2/0002.png",
"葬送のフィリーレン/Specials/葬送のフリーレン 公式ファンブック SP01/0001.png"
]

View file

@ -0,0 +1,6 @@
[
"Dreadwolf/Dreadwolf Chapter 1-12.pdf",
"Dreadwolf/Dreadwolf Chapter 13-24.pdf",
"Dreadwolf/Dreadwolf Chapter 25.pdf",
"Dreadwolf/Dreadwolf Chapter 26.pdf"
]

View file

@ -0,0 +1,6 @@
[
"Dreadwolf/Dreadwolf Chapter 1-12.pdf",
"Dreadwolf/Dreadwolf Chapter 13-24.pdf",
"Dreadwolf/Dreadwolf Chapter 25.pdf",
"Dreadwolf/Dreadwolf Chapter 26.pdf"
]

View file

@ -0,0 +1,5 @@
[
"Immoral Guild/Immoral Guild v01.cbz",
"Immoral Guild/Immoral Guild v02.cbz",
"Immoral Guild/Futoku No Guild - Vol. 12 Ch. 67 - Take Responsibility.cbz"
]