mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
parent
4e8089dd42
commit
bc1a47ff5a
2 changed files with 51 additions and 2 deletions
|
@ -62,5 +62,24 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
{
|
{
|
||||||
Parser.Parser.ParseTitle(postTitle).SeriesTitle.Should().Be(title);
|
Parser.Parser.ParseTitle(postTitle).SeriesTitle.Should().Be(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("The.Man.from.U.N.C.L.E.2015.1080p.BluRay.x264-SPARKS", "The Man from U.N.C.L.E.")]
|
||||||
|
[TestCase("1941.1979.EXTENDED.720p.BluRay.X264-AMIABLE", "1941")]
|
||||||
|
[TestCase("MY MOVIE (2016) [R][Action, Horror][720p.WEB-DL.AVC.8Bit.6ch.AC3].mkv", "MY MOVIE")]
|
||||||
|
[TestCase("R.I.P.D.2013.720p.BluRay.x264-SPARKS", "R.I.P.D.")]
|
||||||
|
[TestCase("V.H.S.2.2013.LIMITED.720p.BluRay.x264-GECKOS", "V.H.S. 2")]
|
||||||
|
[TestCase("This Is A Movie (1999) [IMDB #] <Genre, Genre, Genre> {ACTORS} !DIRECTOR +MORE_SILLY_STUFF_NO_ONE_NEEDS ?", "This Is A Movie")]
|
||||||
|
[TestCase("R.I.P.D.2013.720p.BluRay.x264-SPARKS", "R.I.P.D.")]
|
||||||
|
[TestCase("(500).Days.Of.Summer.(2009).DTS.1080p.BluRay.x264.NLsubs", "(500) Days Of Summer")]
|
||||||
|
public void should_parse_movie_title(string postTitle, string title)
|
||||||
|
{
|
||||||
|
Parser.Parser.ParseMovieTitle(postTitle).MovieTitle.Should().Be(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("1941.1979.EXTENDED.720p.BluRay.X264-AMIABLE", 1979)]
|
||||||
|
public void should_parse_movie_year(string postTitle, int year)
|
||||||
|
{
|
||||||
|
Parser.Parser.ParseMovieTitle(postTitle).Year.Should().Be(year);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace NzbDrone.Core.Parser
|
||||||
//That did not work? Maybe some tool uses [] for years. Who would do that?
|
//That did not work? Maybe some tool uses [] for years. Who would do that?
|
||||||
new Regex(@"^(?<title>(?![(\[]).+?)?(?:(?:[-_\W](?<![)!]))*(?<year>(19|20)\d{2}(?!p|i|\d+|\W\d+)))+(\W+|_|$)(?!\\)",
|
new Regex(@"^(?<title>(?![(\[]).+?)?(?:(?:[-_\W](?<![)!]))*(?<year>(19|20)\d{2}(?!p|i|\d+|\W\d+)))+(\W+|_|$)(?!\\)",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||||
|
|
||||||
|
//As a last resort for movies that have ( or [ in their title.
|
||||||
|
new Regex(@"^(?<title>.+?)?(?:(?:[-_\W](?<![)\[!]))*(?<year>(19|20)\d{2}(?!p|i|\d+|\]|\W\d+)))+(\W+|_|$)(?!\\)",
|
||||||
|
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Regex[] ReportMovieTitleFolderRegex = new[]
|
private static readonly Regex[] ReportMovieTitleFolderRegex = new[]
|
||||||
|
@ -357,7 +362,7 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
if (!ValidateBeforeParsing(title)) return null;
|
if (!ValidateBeforeParsing(title)) return null;
|
||||||
|
|
||||||
title = title.Replace(" ", "."); //TODO: Determine if this breaks something. However, it shouldn't.
|
//title = title.Replace(" ", "."); //TODO: Determine if this breaks something. However, it shouldn't.
|
||||||
|
|
||||||
Logger.Debug("Parsing string '{0}'", title);
|
Logger.Debug("Parsing string '{0}'", title);
|
||||||
|
|
||||||
|
@ -704,9 +709,34 @@ namespace NzbDrone.Core.Parser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var seriesName = matchCollection[0].Groups["title"].Value.Replace('.', ' ').Replace('_', ' ');
|
var seriesName = matchCollection[0].Groups["title"].Value./*Replace('.', ' ').*/Replace('_', ' ');
|
||||||
seriesName = RequestInfoRegex.Replace(seriesName, "").Trim(' ');
|
seriesName = RequestInfoRegex.Replace(seriesName, "").Trim(' ');
|
||||||
|
|
||||||
|
var parts = seriesName.Split('.');
|
||||||
|
seriesName = "";
|
||||||
|
int n;
|
||||||
|
bool previousAcronym = false;
|
||||||
|
foreach (var part in parts)
|
||||||
|
{
|
||||||
|
if (part.Length == 1 && part.ToLower() != "a" && !int.TryParse(part, out n))
|
||||||
|
{
|
||||||
|
seriesName += part + ".";
|
||||||
|
previousAcronym = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (previousAcronym)
|
||||||
|
{
|
||||||
|
seriesName += " ";
|
||||||
|
previousAcronym = false;
|
||||||
|
}
|
||||||
|
seriesName += part + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
seriesName = seriesName.Trim(' ');
|
||||||
|
|
||||||
int airYear;
|
int airYear;
|
||||||
int.TryParse(matchCollection[0].Groups["year"].Value, out airYear);
|
int.TryParse(matchCollection[0].Groups["year"].Value, out airYear);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue