Fixed: Parser no longer chokes on titles with a file extension and invalid path characters such as :.

pull/2/head
Taloth Saldono 10 years ago
parent 8a86b8acdc
commit 10b45f769e

@ -52,6 +52,12 @@ namespace NzbDrone.Core.Test.ParserTests
title.CleanSeriesTitle().Should().Be("carnivale");
}
[TestCase("Discovery TV - Gold Rush : 02 Road From Hell [S04].mp4")]
public void should_clean_up_invalid_path_characters(String postTitle)
{
Parser.Parser.ParseTitle(postTitle);
}
[TestCase("[scnzbefnet][509103] 2.Broke.Girls.S03E18.720p.HDTV.X264-DIMENSION", "2 Broke Girls")]
public void should_remove_request_info_from_title(String postTitle, String title)
{

@ -138,6 +138,9 @@ namespace NzbDrone.Core.Parser
private static readonly Regex NormalizeRegex = new Regex(@"((?:\b|_)(?<!^)(a|an|the|and|or|of)(?:\b|_))|\W|_",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex FileExtensionRegex = new Regex(@"\.[a-z0-9]{2,4}$",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex SimpleTitleRegex = new Regex(@"480[i|p]|720[i|p]|1080[i|p]|[xh][\W_]?264|DD\W?5\W1|\<|\>|\?|\*|\:|\||848x480|1280x720|1920x1080|8bit|10bit",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
@ -371,14 +374,18 @@ namespace NzbDrone.Core.Parser
public static string RemoveFileExtension(string title)
{
if (!title.ContainsInvalidPathChars())
{
var extension = Path.GetExtension(title).ToLower();
if (MediaFiles.MediaFileExtensions.Extensions.Contains(extension) || new [] { ".par2", ".nzb" }.Contains(extension))
title = FileExtensionRegex.Replace(title, m =>
{
title = Path.Combine(Path.GetDirectoryName(title), Path.GetFileNameWithoutExtension(title));
}
}
var extension = m.Value.ToLower();
if (MediaFiles.MediaFileExtensions.Extensions.Contains(extension) || new[] { ".par2", ".nzb" }.Contains(extension))
{
return String.Empty;
}
else
{
return m.Value;
}
});
return title;
}

Loading…
Cancel
Save