diff --git a/Parsers/RawParser.cs b/Parsers/RawParser.cs index 9acec10..7cdebac 100644 --- a/Parsers/RawParser.cs +++ b/Parsers/RawParser.cs @@ -51,13 +51,25 @@ public class RawParser : ItemParser return (rawTitle, null); } + + private void SimplifyMatches(List matches) + { + matches.RemoveAll(match => string.IsNullOrEmpty(match.Trim())); + matches.RemoveAll(match => Regex.Match(match.Trim(), @"\d+[Pp]$").Success); + } + + private List GetParts(string name) + { + var matches = Regex.Matches(name, @"[^\[\]_【】]+").Select(match => match.Value).ToList(); + SimplifyMatches(matches); + return matches; + } private bool TryParseRawTitle(Item item, out string rawTitle) { rawTitle = null; var name = item.Name(); - var matches = Regex.Matches(name, @"[^\[\]_]+").Select(match => match.Value).ToList(); - matches.RemoveAll(match => string.IsNullOrEmpty(match.Trim())); + var matches = GetParts(name); if (matches.Count == 0) return false; @@ -78,10 +90,11 @@ public class RawParser : ItemParser { season = null; var name = item.Name(); - var matches = Regex.Matches(name, @"[^\[\]_]+").Select(match => match.Value).ToArray(); - if (matches.Length == 0) return false; + var matches = GetParts(name); + + if (matches.Count == 0) return false; - if (matches.Length == 1) + if (matches.Count == 1) { (_, season) = SplitTitleAndSeason(matches[0]); if (!string.IsNullOrEmpty(season)) return true; @@ -99,8 +112,9 @@ public class RawParser : ItemParser { group = null; var name = item.Name(); - var matches = Regex.Matches(name, @"[^\[\]_《》【】]+").Select(match => match.Value).ToArray(); - if (matches.Length <= 1) return false; + var matches = GetParts(name); + + if (matches.Count <= 1) return false; group = matches[0]; return true; }