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.
C# annotationscbzcomicinfocomicscomics-readercross-platformcsharpepubepub-readerfreelinuxmangamedia-servermetadataopdsopds-feedpdfself-hostedubooquitywindows
More regex! Bonus is now a keyword for specials (#220)
Joseph Milazzo2f793af34ca5
diff --git a/API.Tests/Parser/MangaParserTests.cs b/API.Tests/Parser/MangaParserTests.csindex e1b143272..31e1b89d5 100644--- a/API.Tests/Parser/MangaParserTests.cs+++ b/API.Tests/Parser/MangaParserTests.cs@@ -53,7 +53,7 @@ namespace API.Tests.Parser[InlineData("Kedouin Makoto - Corpse Party Musume, Chapter 12 [Dametrans][v2]", "0")][InlineData("Vagabond_v03", "3")][InlineData("Mujaki No Rakune Volume 10.cbz", "10")]- [InlineData("Umineko no Naku Koro ni - Episode 3 - Banquet of the Golden Witch #02.cbz", "3")]+ [InlineData("Umineko no Naku Koro ni - Episode 3 - Banquet of the Golden Witch #02.cbz", "0")][InlineData("Volume 12 - Janken Boy is Coming!.cbz", "12")][InlineData("[dmntsf.net] One Piece - Digital Colored Comics Vol. 20 Ch. 177 - 30 Million vs 81 Million.cbz", "20")][InlineData("Gantz.V26.cbz", "26")]@@ -61,6 +61,9 @@ namespace API.Tests.Parser[InlineData("[Hidoi]_Amaenaideyo_MS_vol01_chp02.rar", "1")][InlineData("NEEDLESS_Vol.4_-_Simeon_6_v2_[SugoiSugoi].rar", "4")][InlineData("Okusama wa Shougakusei c003 (v01) [bokuwaNEET]", "1")]+ [InlineData("Sword Art Online Vol 10 - Alicization Running [Yen Press] [LuCaZ] {r2}.epub", "10")]+ [InlineData("Noblesse - Episode 406 (52 Pages).7z", "0")]+ [InlineData("X-Men v1 #201 (September 2007).cbz", "1")]public void ParseVolumeTest(string filename, string expected){Assert.Equal(expected, API.Parser.Parser.ParseVolume(filename));@@ -136,7 +139,11 @@ namespace API.Tests.Parser[InlineData("Okusama wa Shougakusei c003 (v01) [bokuwaNEET]", "Okusama wa Shougakusei")][InlineData("VanDread-v01-c001[MD].zip", "VanDread")][InlineData("Momo The Blood Taker - Chapter 027 Violent Emotion.cbz", "Momo The Blood Taker")]+ [InlineData("Kiss x Sis - Ch.15 - The Angst of a 15 Year Old Boy.cbz", "Kiss x Sis")][InlineData("Green Worldz - Chapter 112 Final Chapter (End).cbz", "Green Worldz")]+ [InlineData("Noblesse - Episode 406 (52 Pages).7z", "Noblesse")]+ [InlineData("X-Men v1 #201 (September 2007).cbz", "X-Men")]+ [InlineData("Kodoja #001 (March 2016)", "Kodoja")]public void ParseSeriesTest(string filename, string expected){Assert.Equal(expected, API.Parser.Parser.ParseSeries(filename));@@ -197,7 +204,12 @@ namespace API.Tests.Parser[InlineData("Kiss x Sis - Ch.00 - Let's Start from 0.cbz", "0")][InlineData("[Hidoi]_Amaenaideyo_MS_vol01_chp02.rar", "2")][InlineData("Okusama wa Shougakusei c003 (v01) [bokuwaNEET]", "3")]+ [InlineData("Kiss x Sis - Ch.15 - The Angst of a 15 Year Old Boy.cbz", "15")][InlineData("Tomogui Kyoushitsu - Chapter 006 Game 005 - Fingernails On Right Hand (Part 002).cbz", "6")]+ [InlineData("Noblesse - Episode 406 (52 Pages).7z", "406")]+ [InlineData("X-Men v1 #201 (September 2007).cbz", "201")]+ [InlineData("Kodoja #001 (March 2016)", "1")]+ [InlineData("Noblesse - Episode 429 (74 Pages).7z", "429")]public void ParseChaptersTest(string filename, string expected){Assert.Equal(expected, API.Parser.Parser.ParseChapter(filename));@@ -226,6 +238,7 @@ namespace API.Tests.Parser[InlineData("Corpse Party -The Anthology- Sachikos game of love Hysteric Birthday 2U Extra Chapter", true)][InlineData("Ani-Hina Art Collection.cbz", true)][InlineData("Gifting The Wonderful World With Blessings! - 3 Side Stories [yuNS][Unknown]", true)]+ [InlineData("A Town Where You Live - Bonus Chapter.zip", true)][InlineData("Yuki Merry - 4-Komga Anthology", true)]public void ParseMangaSpecialTest(string input, bool expected){diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.csindex 3cffb87e6..23f9b70c5 100644--- a/API/Parser/Parser.cs+++ b/API/Parser/Parser.cs@@ -52,10 +52,10 @@ namespace API.Parsernew Regex(@"(?<Series>.*)(\b|_|)(S(?<Volume>\d+))",RegexOptions.IgnoreCase | RegexOptions.Compiled),- // Umineko no Naku Koro ni - Episode 3 - Banquet of the Golden Witch #02.cbz- new Regex(- @"(?<Series>.*)( |_|-)(?:Episode)(?: |_)(?<Volume>\d+(-\d+)?)",- RegexOptions.IgnoreCase | RegexOptions.Compiled),+ // Umineko no Naku Koro ni - Episode 3 - Banquet of the Golden Witch #02.cbz (this case is too limited, most other cases shouldn't parse out)+ // new Regex(+ // @"(?<Series>.*)( |_|-)(?:Episode)(?: |_)(?<Volume>\d+(-\d+)?)",+ // RegexOptions.IgnoreCase | RegexOptions.Compiled),};@@ -115,6 +115,10 @@ namespace API.Parsernew Regex(@"(?<Series>.*) (?<Chapter>\d+(?:.\d+|-\d+)?) \(\d{4}\)",RegexOptions.IgnoreCase | RegexOptions.Compiled),+ // Noblesse - Episode 429 (74 Pages).7z+ new Regex(+ @"(?<Series>.*)(\s|_)(?:Episode|Ep\.?)(\s|_)(?<Chapter>\d+(?:.\d+|-\d+)?)",+ RegexOptions.IgnoreCase | RegexOptions.Compiled),// Akame ga KILL! ZERO (2016-2019) (Digital) (LuCaZ)new Regex(@"(?<Series>.*)\(\d",@@ -148,10 +152,7 @@ namespace API.Parsernew Regex(@"^(?!Vol\.?)(?<Series>.*)( |_|-)(?<!-)(episode ?)\d+-?\d*",RegexOptions.IgnoreCase | RegexOptions.Compiled),- // Baketeriya ch01-05.zip, Akiiro Bousou Biyori - 01.jpg, Beelzebub_172_RHS.zip, Cynthia the Mission 29.rar- new Regex(- @"^(?!Vol\.?)(?<Series>.*)( |_|-)(?<!-)(ch)?\d+-?\d*",- RegexOptions.IgnoreCase | RegexOptions.Compiled),+// Baketeriya ch01-05.zipnew Regex(@"^(?!Vol)(?<Series>.*)ch\d+-?\d?",@@ -164,6 +165,14 @@ namespace API.Parsernew Regex(@"^(?!Vol)(?<Series>.*)(-)\d+-?\d*", // This catches a lot of stuff ^(?!Vol)(?<Series>.*)( |_)(\d+)RegexOptions.IgnoreCase | RegexOptions.Compiled),+ // Kodoja #001 (March 2016)+ new Regex(+ @"(?<Series>.*)(\s|_|-)#",+ RegexOptions.IgnoreCase | RegexOptions.Compiled),+ // Baketeriya ch01-05.zip, Akiiro Bousou Biyori - 01.jpg, Beelzebub_172_RHS.zip, Cynthia the Mission 29.rar+ new Regex(+ @"^(?!Vol\.?)(?<Series>.*)( |_|-)(?<!-)(ch)?\d+-?\d*",+ RegexOptions.IgnoreCase | RegexOptions.Compiled),// [BAA]_Darker_than_Black_c1 (This is very greedy, make sure it's close to last)new Regex(@"^(?!Vol)(?<Series>.*)( |_|-)(ch?)\d+",@@ -292,7 +301,7 @@ namespace API.Parser{// Historys Strongest Disciple Kenichi_v11_c90-98.zip, ...c90.5-100.5new Regex(- @"(c|ch)(\.? ?)(?<Chapter>(\d+(\.\d)?)-?(\d+(\.\d)?)?)",+ @"(\b|_)(c|ch)(\.?\s?)(?<Chapter>(\d+(\.\d)?)-?(\d+(\.\d)?)?)",RegexOptions.IgnoreCase | RegexOptions.Compiled),// [Suihei Kiki]_Kasumi_Otoko_no_Ko_[Taruby]_v1.1.zipnew Regex(@@ -367,7 +376,7 @@ namespace API.Parser{// All Keywords, does not account for checking if contains volume/chapter identification. Parser.Parse() will handle.new Regex(- @"(?<Special>Specials?|OneShot|One\-Shot|Omake|Extra( Chapter)?|Art Collection|Side( |_)Stories|(?<!The\s)Anthology)",+ @"(?<Special>Specials?|OneShot|One\-Shot|Omake|Extra( Chapter)?|Art Collection|Side( |_)Stories|(?<!The\s)Anthology|Bonus)",RegexOptions.IgnoreCase | RegexOptions.Compiled),};