mirror of
https://github.com/Radarr/Radarr
synced 2025-02-24 23:23:21 +00:00
Fixed: Parsing alternative titles containing "A.K.A."
This commit is contained in:
parent
41b1ea553e
commit
25685314bc
2 changed files with 17 additions and 0 deletions
|
@ -201,6 +201,20 @@ public void should_parse_german_movie(string postTitle, string title, string edi
|
||||||
"Енола Голмс",
|
"Енола Голмс",
|
||||||
"Enola Holmes"
|
"Enola Holmes"
|
||||||
})]
|
})]
|
||||||
|
[TestCase("Mon cousin a.k.a. My Cousin 2020 1080p Blu-ray DD 5.1 x264.mkv",
|
||||||
|
new string[]
|
||||||
|
{
|
||||||
|
"Mon cousin AKA My Cousin",
|
||||||
|
"Mon cousin",
|
||||||
|
"My Cousin"
|
||||||
|
})]
|
||||||
|
[TestCase("Sydney A.K.A. Hard Eight 1996 1080p AMZN WEB-DL DD+ 2.0 H.264.mkv",
|
||||||
|
new string[]
|
||||||
|
{
|
||||||
|
"Sydney AKA Hard Eight",
|
||||||
|
"Sydney",
|
||||||
|
"Hard Eight"
|
||||||
|
})]
|
||||||
public void should_parse_movie_alternative_titles(string postTitle, string[] parsedTitles)
|
public void should_parse_movie_alternative_titles(string postTitle, string[] parsedTitles)
|
||||||
{
|
{
|
||||||
var movieInfo = Parser.Parser.ParseMovieTitle(postTitle, true);
|
var movieInfo = Parser.Parser.ParseMovieTitle(postTitle, true);
|
||||||
|
|
|
@ -105,6 +105,8 @@ public static class Parser
|
||||||
// Regex to unbracket alternative titles.
|
// Regex to unbracket alternative titles.
|
||||||
private static readonly Regex BracketedAlternativeTitleRegex = new Regex(@"(.*) \([ ]*AKA[ ]+(.*)\)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
private static readonly Regex BracketedAlternativeTitleRegex = new Regex(@"(.*) \([ ]*AKA[ ]+(.*)\)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
|
private static readonly Regex NormalizeAlternativeTitleRegex = new Regex(@"[ ]+(?:A\.K\.A\.)[ ]+", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
private static readonly Regex NormalizeRegex = new Regex(@"((?:\b|_)(?<!^|[^a-zA-Z0-9_']\w[^a-zA-Z0-9_'])(a(?!$|[^a-zA-Z0-9_']\w[^a-zA-Z0-9_'])|an|the|and|or|of)(?!$)(?:\b|_))|\W|_",
|
private static readonly Regex NormalizeRegex = new Regex(@"((?:\b|_)(?<!^|[^a-zA-Z0-9_']\w[^a-zA-Z0-9_'])(a(?!$|[^a-zA-Z0-9_']\w[^a-zA-Z0-9_'])|an|the|and|or|of)(?!$)(?:\b|_))|\W|_",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
|
@ -590,6 +592,7 @@ private static ParsedMovieInfo ParseMovieMatchCollection(MatchCollection matchCo
|
||||||
}
|
}
|
||||||
|
|
||||||
var movieName = matchCollection[0].Groups["title"].Value.Replace('_', ' ');
|
var movieName = matchCollection[0].Groups["title"].Value.Replace('_', ' ');
|
||||||
|
movieName = NormalizeAlternativeTitleRegex.Replace(movieName, " AKA ");
|
||||||
movieName = RequestInfoRegex.Replace(movieName, "").Trim(' ');
|
movieName = RequestInfoRegex.Replace(movieName, "").Trim(' ');
|
||||||
|
|
||||||
var parts = movieName.Split('.');
|
var parts = movieName.Split('.');
|
||||||
|
|
Loading…
Reference in a new issue