Update parser to recognize [] and year at the beginning. Fixes #155, fixes #137 and fixes #136.

pull/2/head
Leonardo Galli 8 years ago
parent d42165a93a
commit 8e8c4ff497

@ -265,7 +265,6 @@ namespace NzbDrone.Core.DecisionEngine
e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson());
_logger.Error(e, "Couldn't evaluate decision on " + remoteEpisode.Release.Title + ", with spec: " + spec.GetType().Name);
return new Rejection(string.Format("{0}: {1}", spec.GetType().Name, e.Message));//TODO UPDATE SPECS!
return null;
}
return null;

@ -189,7 +189,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
var lowerTitle = title.ToLower();
var parserResult = Parser.Parser.ParseMovieTitle(title);
var parserResult = Parser.Parser.ParseMovieTitle(title, true);
var yearTerm = "";

@ -36,6 +36,15 @@ namespace NzbDrone.Core.Parser
//PassThePopcorn Torrent names: Star.Wars[PassThePopcorn]
new Regex(@"^(?<title>.+?)?(?:(?:[-_\W](?<![()\[!]))*(?<year>(\[\w *\])))+(\W+|_|$)(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
//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+|_|$)(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
};
private static readonly Regex[] ReportMovieTitleFolderRegex = new[]
{
//When year comes first.
new Regex(@"^(?:(?:[-_\W](?<![)!]))*(?<year>(19|20)\d{2}(?!p|i|\d+|\W\d+)))+(\W+|_|$)(?<title>.+?)?$")
};
private static readonly Regex[] ReportTitleRegex = new[]
@ -327,7 +336,7 @@ namespace NzbDrone.Core.Parser
{
var fileInfo = new FileInfo(path);
var result = ParseMovieTitle(fileInfo.Name);
var result = ParseMovieTitle(fileInfo.Name, true);
if (result == null)
{
@ -345,7 +354,7 @@ namespace NzbDrone.Core.Parser
}
public static ParsedMovieInfo ParseMovieTitle(string title)
public static ParsedMovieInfo ParseMovieTitle(string title, bool isDir = false)
{
ParsedMovieInfo realResult = null;
@ -376,7 +385,14 @@ namespace NzbDrone.Core.Parser
simpleTitle = CleanTorrentSuffixRegex.Replace(simpleTitle, string.Empty);
foreach (var regex in ReportMovieTitleRegex)
var allRegexes = ReportMovieTitleRegex.ToList();
if (isDir)
{
allRegexes.AddRange(ReportMovieTitleFolderRegex);
}
foreach (var regex in allRegexes)
{
var match = regex.Matches(simpleTitle);

Loading…
Cancel
Save