Skip to content

Commit

Permalink
Added parsing case for c01-c04.
Browse files Browse the repository at this point in the history
  • Loading branch information
majora2007 committed Jan 25, 2024
1 parent 8a45bae commit fd2aa6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions API.Tests/Parser/MangaParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public void ParseSeriesTest(string filename, string expected)
[InlineData("Bleach 001-003", "1-3")]
[InlineData("Accel World Volume 2", "0")]
[InlineData("Historys Strongest Disciple Kenichi_v11_c90-98", "90-98")]
[InlineData("Historys Strongest Disciple Kenichi c01-c04", "1-4")]
public void ParseChaptersTest(string filename, string expected)
{
Assert.Equal(expected, API.Services.Tasks.Scanner.Parser.Parser.ParseChapter(filename));
Expand Down
7 changes: 6 additions & 1 deletion API/Services/Tasks/Scanner/Parser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ public static class Parser
{
// Historys Strongest Disciple Kenichi_v11_c90-98.zip, ...c90.5-100.5
new Regex(
@"(\b|_)(c|ch)(\.?\s?)(?<Chapter>(\d+(\.\d)?)(-\d+(\.\d)?)?)",
@"(\b|_)(c|ch)(\.?\s?)(?<Chapter>(\d+(\.\d)?)(-c?\d+(\.\d)?)?)",
MatchOptions, RegexTimeout),
// [Suihei Kiki]_Kasumi_Otoko_no_Ko_[Taruby]_v1.1.zip
new Regex(
Expand Down Expand Up @@ -761,6 +761,11 @@ private static string FormatValue(string value, bool hasPart)
var from = RemoveLeadingZeroes(tokens[0]);
if (tokens.Length != 2) return from;

// Occasionally users will use c01-c02 instead of c01-02, clean any leftover c
if (tokens[1].StartsWith("c", StringComparison.InvariantCultureIgnoreCase))
{
tokens[1] = tokens[1].Replace("c", string.Empty, StringComparison.InvariantCultureIgnoreCase);
}
var to = RemoveLeadingZeroes(hasPart ? AddChapterPart(tokens[1]) : tokens[1]);
return $"{from}-{to}";
}
Expand Down

0 comments on commit fd2aa6a

Please sign in to comment.