From a9a1ec02cac0162b6d4dad5cb9c0b964cd11fded Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Wed, 25 May 2022 14:25:53 -0500 Subject: [PATCH] Implemented the ability to parse some volume and chapter keywords for chinese. (#1285) --- API.Tests/Parser/MangaParserTests.cs | 5 +++++ API/Parser/Parser.cs | 12 ++++++++++++ 2 files changed, 17 insertions(+) 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_)(?\d+(\.\d)?)", MatchOptions, RegexTimeout), + // Chinese Volume: 第n卷 -> Volume n, 第n册 -> Volume n, 幽游白书完全版 第03卷 天下 or 阿衰online 第1册 + new Regex( + @"第(?\d+)(卷|册)", + MatchOptions, RegexTimeout), + // Chinese Volume: 卷n -> Volume n, 册n -> Volume n + new Regex( + @"(卷|册)(?\d+)", + MatchOptions, RegexTimeout), }; private static readonly Regex[] MangaSeriesRegex = new[] @@ -449,6 +457,10 @@ namespace API.Parser new Regex( @"(?((vol|volume|v))?(\s|_)?\.?\d+)(\s|_)(Chp|Chapter)\.?(\s|_)?(?\d+)", MatchOptions, RegexTimeout), + // Chinese Chapter: 第n话 -> Chapter n, 【TFO汉化&Petit汉化】迷你偶像漫画第25话 + new Regex( + @"第(?\d+)话", + MatchOptions, RegexTimeout), }; private static readonly Regex[] MangaEditionRegex = {