diff --git a/API.Tests/Parser/ComicParserTests.cs b/API.Tests/Parser/ComicParserTests.cs index e0551aac1..1088fa673 100644 --- a/API.Tests/Parser/ComicParserTests.cs +++ b/API.Tests/Parser/ComicParserTests.cs @@ -48,10 +48,12 @@ namespace API.Tests.Parser [InlineData("Chew v1 - Taster“s Choise (2012) (Digital) (1920) (Kingpin-Empire)", "Chew")] [InlineData("Chew Script Book (2011) (digital-Empire) SP04", "Chew Script Book")] [InlineData("Batman - Detective Comics - Rebirth Deluxe Edition Book 02 (2018) (digital) (Son of Ultron-Empire)", "Batman - Detective Comics - Rebirth Deluxe Edition Book")] - [InlineData("Cyberpunk 2077 - Your Voice 01", "Cyberpunk 2077")] + [InlineData("Cyberpunk 2077 - Your Voice 01", "Cyberpunk 2077 - Your Voice")] [InlineData("Cyberpunk 2077 #01", "Cyberpunk 2077")] + [InlineData("Cyberpunk 2077 - Trauma Team 04.cbz", "Cyberpunk 2077 - Trauma Team")] [InlineData("Batgirl Vol.2000 #57 (December, 2004)", "Batgirl")] [InlineData("Batgirl V2000 #57", "Batgirl")] + [InlineData("Fables 021 (2004) (Digital) (Nahga-Empire).cbr", "Fables")] public void ParseComicSeriesTest(string filename, string expected) { Assert.Equal(expected, API.Parser.Parser.ParseComicSeries(filename)); @@ -84,6 +86,8 @@ namespace API.Tests.Parser [InlineData("Chew Script Book (2011) (digital-Empire) SP04", "0")] [InlineData("Batgirl Vol.2000 #57 (December, 2004)", "2000")] [InlineData("Batgirl V2000 #57", "2000")] + [InlineData("Fables 021 (2004) (Digital) (Nahga-Empire).cbr", "0")] + [InlineData("Cyberpunk 2077 - Trauma Team 04.cbz", "0")] public void ParseComicVolumeTest(string filename, string expected) { Assert.Equal(expected, API.Parser.Parser.ParseComicVolume(filename)); @@ -120,6 +124,8 @@ namespace API.Tests.Parser [InlineData("Chew Script Book (2011) (digital-Empire) SP04", "0")] [InlineData("Batgirl Vol.2000 #57 (December, 2004)", "57")] [InlineData("Batgirl V2000 #57", "57")] + [InlineData("Fables 021 (2004) (Digital) (Nahga-Empire).cbr", "21")] + [InlineData("Cyberpunk 2077 - Trauma Team 04.cbz", "4")] public void ParseComicChapterTest(string filename, string expected) { Assert.Equal(expected, API.Parser.Parser.ParseComicChapter(filename)); diff --git a/API.Tests/Parser/ParserTest.cs b/API.Tests/Parser/ParserTest.cs index 3a8b7ba6a..039beaf91 100644 --- a/API.Tests/Parser/ParserTest.cs +++ b/API.Tests/Parser/ParserTest.cs @@ -36,15 +36,15 @@ namespace API.Tests.Parser } [Theory] - [InlineData("Hello_I_am_here", "Hello I am here")] - [InlineData("Hello_I_am_here ", "Hello I am here")] - [InlineData("[ReleaseGroup] The Title", "The Title")] - [InlineData("[ReleaseGroup]_The_Title", "The Title")] - [InlineData("[Suihei Kiki]_Kasumi_Otoko_no_Ko_[Taruby]_v1.1", "Kasumi Otoko no Ko v1.1")] - [InlineData("Batman - Detective Comics - Rebirth Deluxe Edition Book 04 (2019) (digital) (Son of Ultron-Empire)", "Batman - Detective Comics - Rebirth Deluxe Edition")] - public void CleanTitleTest(string input, string expected) + [InlineData("Hello_I_am_here", false, "Hello I am here")] + [InlineData("Hello_I_am_here ", false, "Hello I am here")] + [InlineData("[ReleaseGroup] The Title", false, "The Title")] + [InlineData("[ReleaseGroup]_The_Title", false, "The Title")] + [InlineData("[Suihei Kiki]_Kasumi_Otoko_no_Ko_[Taruby]_v1.1", false, "Kasumi Otoko no Ko v1.1")] + [InlineData("Batman - Detective Comics - Rebirth Deluxe Edition Book 04 (2019) (digital) (Son of Ultron-Empire)", true, "Batman - Detective Comics - Rebirth Deluxe Edition")] + public void CleanTitleTest(string input, bool isComic, string expected) { - Assert.Equal(expected, CleanTitle(input)); + Assert.Equal(expected, CleanTitle(input, isComic)); } diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.cs index 9c79e84ad..7386cf125 100644 --- a/API/Parser/Parser.cs +++ b/API/Parser/Parser.cs @@ -317,11 +317,13 @@ namespace API.Parser @"^(?.+?)Vol\.?\s?#?(?:\d+)", MatchOptions, RegexTimeout), + // Batman & Catwoman - Trail of the Gun 01, Batman & Grendel (1996) 01 - Devil's Bones, Teen Titans v1 001 (1966-02) (digital) (OkC.O.M.P.U.T.O.-Novus) new Regex( @"^(?.+?)(?: \d+)", MatchOptions, RegexTimeout), + // Batman & Robin the Teen Wonder #0 new Regex( @"^(?.*)(?: |_)#\d+", @@ -618,7 +620,7 @@ namespace API.Parser var edition = ParseEdition(fileName); if (!string.IsNullOrEmpty(edition)) { - ret.Series = CleanTitle(ret.Series.Replace(edition, ""), type == LibraryType.Comic); + ret.Series = CleanTitle(ret.Series.Replace(edition, ""), type is LibraryType.Comic); ret.Edition = edition; } @@ -643,7 +645,7 @@ namespace API.Parser if (string.IsNullOrEmpty(ret.Series)) { - ret.Series = CleanTitle(fileName, type == LibraryType.Comic); + ret.Series = CleanTitle(fileName, type is LibraryType.Comic); } // Pdfs may have .pdf in the series name, remove that @@ -691,7 +693,7 @@ namespace API.Parser if ((string.IsNullOrEmpty(series) && i == fallbackFolders.Count - 1)) { - ret.Series = CleanTitle(folder, type == LibraryType.Comic); + ret.Series = CleanTitle(folder, type is LibraryType.Comic); break; }