Fixed: Incorrect matching of date in title

Closes #1401
This commit is contained in:
Mark McDowall 2016-07-26 22:31:03 -07:00
parent 87d00abdf1
commit 2ab9bb4fce
2 changed files with 10 additions and 4 deletions

View File

@ -122,6 +122,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Judge Judy 2016 02 25 S20E143", "Judge Judy", 20, 143)] [TestCase("Judge Judy 2016 02 25 S20E143", "Judge Judy", 20, 143)]
[TestCase("Red Dwarf - S02 - E06 - Parallel Universe", "Red Dwarf", 2, 6)] [TestCase("Red Dwarf - S02 - E06 - Parallel Universe", "Red Dwarf", 2, 6)]
[TestCase("O.J.Simpson.Made.in.America.Part.Two.720p.HDTV.x264-2HD", "O J Simpson Made in America", 1, 2)] [TestCase("O.J.Simpson.Made.in.America.Part.Two.720p.HDTV.x264-2HD", "O J Simpson Made in America", 1, 2)]
[TestCase("The.100000.Dollar.Pyramid.2016.S01E05.720p.HDTV.x264-W4F", "The 100000 Dollar Pyramid 2016", 1, 5)]
//[TestCase("", "", 0, 0)] //[TestCase("", "", 0, 0)]
public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber) public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber)
{ {

View File

@ -319,11 +319,16 @@ namespace NzbDrone.Core.Parser
var sixDigitAirDateMatch = SixDigitAirDateRegex.Match(simpleTitle); var sixDigitAirDateMatch = SixDigitAirDateRegex.Match(simpleTitle);
if (sixDigitAirDateMatch.Success) if (sixDigitAirDateMatch.Success)
{ {
var fixedDate = string.Format("20{0}.{1}.{2}", sixDigitAirDateMatch.Groups["airyear"].Value, var airYear = sixDigitAirDateMatch.Groups["airyear"].Value;
sixDigitAirDateMatch.Groups["airmonth"].Value, var airMonth = sixDigitAirDateMatch.Groups["airmonth"].Value;
sixDigitAirDateMatch.Groups["airday"].Value); var airDay = sixDigitAirDateMatch.Groups["airday"].Value;
simpleTitle = simpleTitle.Replace(sixDigitAirDateMatch.Groups["airdate"].Value, fixedDate); if (airMonth != "00" || airDay != "00")
{
var fixedDate = string.Format("20{0}.{1}.{2}", airYear, airMonth, airDay);
simpleTitle = simpleTitle.Replace(sixDigitAirDateMatch.Groups["airdate"].Value, fixedDate);
}
} }
foreach (var regex in ReportTitleRegex) foreach (var regex in ReportTitleRegex)