更新
This commit is contained in:
parent
9cf948ec9c
commit
3d58c7d497
@ -52,12 +52,24 @@ public class RawParser : ItemParser
|
|||||||
return (rawTitle, null);
|
return (rawTitle, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SimplifyMatches(List<string> matches)
|
||||||
|
{
|
||||||
|
matches.RemoveAll(match => string.IsNullOrEmpty(match.Trim()));
|
||||||
|
matches.RemoveAll(match => Regex.Match(match.Trim(), @"\d+[Pp]$").Success);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string> 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)
|
private bool TryParseRawTitle(Item item, out string rawTitle)
|
||||||
{
|
{
|
||||||
rawTitle = null;
|
rawTitle = null;
|
||||||
var name = item.Name();
|
var name = item.Name();
|
||||||
var matches = Regex.Matches(name, @"[^\[\]_]+").Select(match => match.Value).ToList();
|
var matches = GetParts(name);
|
||||||
matches.RemoveAll(match => string.IsNullOrEmpty(match.Trim()));
|
|
||||||
|
|
||||||
if (matches.Count == 0) return false;
|
if (matches.Count == 0) return false;
|
||||||
|
|
||||||
@ -78,10 +90,11 @@ public class RawParser : ItemParser
|
|||||||
{
|
{
|
||||||
season = null;
|
season = null;
|
||||||
var name = item.Name();
|
var name = item.Name();
|
||||||
var matches = Regex.Matches(name, @"[^\[\]_]+").Select(match => match.Value).ToArray();
|
var matches = GetParts(name);
|
||||||
if (matches.Length == 0) return false;
|
|
||||||
|
|
||||||
if (matches.Length == 1)
|
if (matches.Count == 0) return false;
|
||||||
|
|
||||||
|
if (matches.Count == 1)
|
||||||
{
|
{
|
||||||
(_, season) = SplitTitleAndSeason(matches[0]);
|
(_, season) = SplitTitleAndSeason(matches[0]);
|
||||||
if (!string.IsNullOrEmpty(season)) return true;
|
if (!string.IsNullOrEmpty(season)) return true;
|
||||||
@ -99,8 +112,9 @@ public class RawParser : ItemParser
|
|||||||
{
|
{
|
||||||
group = null;
|
group = null;
|
||||||
var name = item.Name();
|
var name = item.Name();
|
||||||
var matches = Regex.Matches(name, @"[^\[\]_《》【】]+").Select(match => match.Value).ToArray();
|
var matches = GetParts(name);
|
||||||
if (matches.Length <= 1) return false;
|
|
||||||
|
if (matches.Count <= 1) return false;
|
||||||
group = matches[0];
|
group = matches[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user