From c813d551246dc117306b7596cb7db51bfa6945b9 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Wed, 20 Oct 2021 06:29:05 -0700 Subject: [PATCH] Fallback to Folder Parsing Issue (#694) * Fixed a bug in the scanner where we fall back to parsing from folders for poorly named files. The code was exiting early if a chapter or volume could be parsed out. * Fixed a unit test by tweaking a regex for fallback --- API.Tests/Parser/MangaParserTests.cs | 17 +++++++++++++++++ API/Parser/Parser.cs | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/API.Tests/Parser/MangaParserTests.cs b/API.Tests/Parser/MangaParserTests.cs index 9cb9d560a..1576cbb07 100644 --- a/API.Tests/Parser/MangaParserTests.cs +++ b/API.Tests/Parser/MangaParserTests.cs @@ -297,6 +297,7 @@ namespace API.Tests.Parser [Theory] [InlineData("/manga/Btooom!/Vol.1/Chapter 1/1.cbz", "Btooom!~1~1")] [InlineData("/manga/Btooom!/Vol.1 Chapter 2/1.cbz", "Btooom!~1~2")] + [InlineData("/manga/Monster #8/Ch. 001-016 [MangaPlus] [Digital] [amit34521]/Monster #8 Ch. 001 [MangaPlus] [Digital] [amit34521]/13.jpg", "Monster #8~0~1")] public void ParseFromFallbackFoldersTest(string inputFile, string expectedParseInfo) { const string rootDirectory = "/manga/"; @@ -438,6 +439,22 @@ namespace API.Tests.Parser filepath = @"E:\Manga\Seraph of the End\cover.png"; expected.Add(filepath, null); + filepath = @"E:\Manga\The Beginning After the End\Chapter 001.cbz"; + expected.Add(filepath, new ParserInfo + { + Series = "The Beginning After the End", Volumes = "0", Edition = "", + Chapters = "1", Filename = "Chapter 001.cbz", Format = MangaFormat.Archive, + FullFilePath = filepath, IsSpecial = false + }); + + filepath = @"E:\Manga\Monster #8\Ch. 001-016 [MangaPlus] [Digital] [amit34521]\Monster #8 Ch. 001 [MangaPlus] [Digital] [amit34521]\13.jpg"; + expected.Add(filepath, new ParserInfo + { + Series = "Monster #8", Volumes = "0", Edition = "", + Chapters = "1", Filename = "13.jpg", Format = MangaFormat.Archive, + FullFilePath = filepath, IsSpecial = false + }); + foreach (var file in expected.Keys) { diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.cs index 51a07a835..2f8b704de 100644 --- a/API/Parser/Parser.cs +++ b/API/Parser/Parser.cs @@ -226,7 +226,7 @@ namespace API.Parser MatchOptions, RegexTimeout), // Baketeriya ch01-05.zip, Akiiro Bousou Biyori - 01.jpg, Beelzebub_172_RHS.zip, Cynthia the Mission 29.rar, A Compendium of Ghosts - 031 - The Third Story_ Part 12 (Digital) (Cobalt001) new Regex( - @"^(?!Vol\.?)(?.+?)( |_|-)(?.+?)(\s|_|-)(?