diff --git a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs index 9d34e2283..7d55563e1 100644 --- a/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/CrapParserFixture.cs @@ -39,6 +39,13 @@ namespace NzbDrone.Core.Test.ParserTests ExceptionVerification.IgnoreWarns(); } + [TestCase("علم نف) أ.دعادل الأبيض ٢٠٢٤ ٣ ٣")] + [TestCase("ror-240618_1007-1022-")] + public void should_parse_unknown_formats_without_error(string title) + { + Parser.Parser.ParseTitle(title).Should().NotBeNull(); + } + [Test] public void should_not_parse_md5() { diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 5558fa698..89c3d8270 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -745,7 +745,7 @@ namespace NzbDrone.Core.Parser Logger.Trace(regex); try { - var result = ParseMatchCollection(match, releaseTitle); + var result = ParseMatchCollection(match, simpleTitle); if (result != null) { @@ -1209,6 +1209,7 @@ namespace NzbDrone.Core.Parser } } + // TODO: This needs to check the modified title if (lastSeasonEpisodeStringIndex != releaseTitle.Length) { result.ReleaseTokens = releaseTitle.Substring(lastSeasonEpisodeStringIndex); @@ -1289,7 +1290,7 @@ namespace NzbDrone.Core.Parser private static int ParseNumber(string value) { - var normalized = value.Normalize(NormalizationForm.FormKC); + var normalized = ConvertToNumerals(value.Normalize(NormalizationForm.FormKC)); if (int.TryParse(normalized, out var number)) { @@ -1308,7 +1309,7 @@ namespace NzbDrone.Core.Parser private static decimal ParseDecimal(string value) { - var normalized = value.Normalize(NormalizationForm.FormKC); + var normalized = ConvertToNumerals(value.Normalize(NormalizationForm.FormKC)); if (decimal.TryParse(normalized, NumberStyles.Float, CultureInfo.InvariantCulture, out var number)) { @@ -1317,5 +1318,24 @@ namespace NzbDrone.Core.Parser throw new FormatException(string.Format("{0} isn't a number", value)); } + + private static string ConvertToNumerals(string input) + { + var result = new StringBuilder(input.Length); + + foreach (var c in input.ToCharArray()) + { + if (char.IsNumber(c)) + { + result.Append(char.GetNumericValue(c)); + } + else + { + result.Append(c); + } + } + + return result.ToString(); + } } }