Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Implemented the ability to parse some volume and chapter keywords for chinese. (#1285)

Joseph Milazzoa9a1ec02cac0
diff --git a/API.Tests/Parser/MangaParserTests.cs b/API.Tests/Parser/MangaParserTests.cs
index a3d298e82..bf7766a4e 100644
--- a/API.Tests/Parser/MangaParserTests.cs
+++ b/API.Tests/Parser/MangaParserTests.cs
@@ -66,6 +66,9 @@ namespace API.Tests.Parser
[InlineData("Hentai Ouji to Warawanai Neko. - Vol. 06 Ch. 034.5", "6")]
[InlineData("The 100 Girlfriends Who Really, Really, Really, Really, Really Love You - Vol. 03 Ch. 023.5 - Volume 3 Extras.cbz", "3")]
[InlineData("The 100 Girlfriends Who Really, Really, Really, Really, Really Love You - Vol. 03.5 Ch. 023.5 - Volume 3 Extras.cbz", "3.5")]
+ [InlineData("幽游白书完全版 第03卷 天下", "3")]
+ [InlineData("阿衰online 第1册", "1")]
+ [InlineData("【TFO汉化&Petit汉化】迷你偶像漫画卷2第25话", "2")]
public void ParseVolumeTest(string filename, string expected)
{
Assert.Equal(expected, API.Parser.Parser.ParseVolume(filename));
@@ -246,6 +249,8 @@ namespace API.Tests.Parser
[InlineData("Harrison, Kim - The Good, The Bad, and the Undead - Hollows Vol 2.5.epub", "0")]
[InlineData("Kaiju No. 8 036 (2021) (Digital)", "36")]
[InlineData("Samurai Jack Vol. 01 - The threads of Time", "0")]
+ [InlineData("【TFO汉化&Petit汉化】迷你偶像漫画第25话", "25")]
+ [InlineData("【TFO汉化&Petit汉化】迷你偶像漫画卷2第25话", "25")]
public void ParseChaptersTest(string filename, string expected)
{
Assert.Equal(expected, API.Parser.Parser.ParseChapter(filename));
diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.cs
index 76b517adf..f0cc2d1c5 100644
--- a/API/Parser/Parser.cs
+++ b/API/Parser/Parser.cs
@@ -102,6 +102,14 @@ namespace API.Parser
new Regex(
@"(vol_)(?<Volume>\d+(\.\d)?)",
MatchOptions, RegexTimeout),
+ // Chinese Volume: 第n卷 -> Volume n, 第n册 -> Volume n, 幽游白书完全版 第03卷 天下 or 阿衰online 第1册
+ new Regex(
+ @"第(?<Volume>\d+)(卷|册)",
+ MatchOptions, RegexTimeout),
+ // Chinese Volume: 卷n -> Volume n, 册n -> Volume n
+ new Regex(
+ @"(卷|册)(?<Volume>\d+)",
+ MatchOptions, RegexTimeout),
};
private static readonly Regex[] MangaSeriesRegex = new[]
@@ -449,6 +457,10 @@ namespace API.Parser
new Regex(
@"(?<Volume>((vol|volume|v))?(\s|_)?\.?\d+)(\s|_)(Chp|Chapter)\.?(\s|_)?(?<Chapter>\d+)",
MatchOptions, RegexTimeout),
+ // Chinese Chapter: 第n话 -> Chapter n, 【TFO汉化&Petit汉化】迷你偶像漫画第25话
+ new Regex(
+ @"第(?<Chapter>\d+)话",
+ MatchOptions, RegexTimeout),
};
private static readonly Regex[] MangaEditionRegex = {