From 6097a2acf01763235bc5c43a938ddccde9c6bef9 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Sun, 24 Jan 2021 10:37:02 -0600 Subject: [PATCH] Some crazy regex for parsing chapters for poorly named files. --- API.Tests/ParserTest.cs | 9 +++++++++ API/Parser/Parser.cs | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/API.Tests/ParserTest.cs b/API.Tests/ParserTest.cs index c246d1118..60a05cbef 100644 --- a/API.Tests/ParserTest.cs +++ b/API.Tests/ParserTest.cs @@ -91,6 +91,7 @@ namespace API.Tests [InlineData("Tenjou_Tenge_v17_c100[MT].zip", "100")] [InlineData("Shimoneta - Manmaru Hen - c001-006 (v01) [Various].zip", "1-6")] [InlineData("Mujaki no Rakuen Vol12 ch76", "76")] + [InlineData("Beelzebub_01_[Noodles].zip", "1")] public void ParseChaptersTest(string filename, string expected) { Assert.Equal(expected, ParseChapter(filename)); @@ -167,6 +168,14 @@ namespace API.Tests FullFilePath = filepath }); + filepath = @"E:\Manga\Beelzebub\Beelzebub_01_[Noodles].zip"; + expected.Add(filepath, new ParserInfo + { + Series = "Beelzebub", Volumes = "0", + Chapters = "1", Filename = "Beelzebub_01_[Noodles].zip", Format = MangaFormat.Archive, + FullFilePath = filepath + }); + diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.cs index 0d8c62cf5..04bc3d542 100644 --- a/API/Parser/Parser.cs +++ b/API/Parser/Parser.cs @@ -115,6 +115,10 @@ namespace API.Parser new Regex( @"(?.*) S(?\d+) (?\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled), + // Beelzebub_01_[Noodles].zip + new Regex( + @"^((?!v|vo|vol|Volume).)*( |_)(?\.?\d+)( |_)", + RegexOptions.IgnoreCase | RegexOptions.Compiled), }; private static readonly Regex[] MangaEditionRegex = new[]