Parser now ignores daily episodes from the future.

pull/4/head
kay.one 13 years ago
parent d0d9c44124
commit 03aa27c45c

@ -148,16 +148,6 @@
<categoryid>6</categoryid>
<enclosure url="http://nzbmatrix.com/nzb-details.php?id=914427&amp;hit=1" length="418717368" type="application/x-nzb" />
</item>
<item>
<title>Fussball Bundesliga 2010 2011 30 Spieltag FC Bayern Muenchen vs Bayer 04 Leverkusen German WS dTV XviD WoGS</title>
<guid>http://nzbmatrix.com/nzb-details.php?id=914423&amp;hit=1</guid>
<link>http://nzbmatrix.com/nzb-details.php?id=914423&amp;hit=1</link>
<description><![CDATA[<b>Name:</b> Fussball Bundesliga 2010 2011 30 Spieltag FC Bayern Muenchen vs Bayer 04 Leverkusen German WS dTV XviD WoGS<br /><b>Category:</b> TV: Divx/Xvid<br /><b>Size:</b> 1.28 GB<br /><b>Added:</b> 2011-04-25 11:41:35<br /><b>Group:</b> alt.binaries.multimedia <BR /><b>NFO:</b> <a href="http://nzbmatrix.com/viewnfo.php?id=914423">View NFO</a> ]]></description>
<category>TV: Divx/Xvid</category>
<cattext>tv.divx/xvid</cattext>
<categoryid>6</categoryid>
<enclosure url="http://nzbmatrix.com/nzb-details.php?id=914423&amp;hit=1" length="1377828864" type="application/x-nzb" />
</item>
<item>
<title>How I Met Your Mother S06E20 The Exploding Meatball Sub German Custom Subbed WS HDTV XviD iNTERNAL BaCKToRG</title>
<guid>http://nzbmatrix.com/nzb-details.php?id=914420&amp;hit=1</guid>

@ -172,7 +172,7 @@ namespace NzbDrone.Core.Test
[TestCase("2011.01.10 - Denis Leary - HD TV.mkv", "", 2011, 1, 10)]
[TestCase("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)]
[TestCase("The Tonight Show with Jay Leno - 2011-06-16 - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo", "The Tonight Show with Jay Leno", 2011, 6, 16)]
public void episode_daily_parse(string postTitle, string title, int year, int month, int day)
public void parse_daily_episodes(string postTitle, string title, int year, int month, int day)
{
var result = Parser.ParseTitle(postTitle);
var airDate = new DateTime(year, month, day);
@ -181,6 +181,16 @@ namespace NzbDrone.Core.Test
Assert.IsNull(result.EpisodeNumbers);
}
[Test]
public void parse_daily_should_fail_if_episode_is_far_in_future()
{
var title = string.Format("{0}.{1}.{2} - Denis Leary - HD TV.mkv", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(2).Day);
Parser.ParseTitle(title).Should().BeNull();
ExceptionVerification.ExcpectedWarns(1);
}
[TestCase("30.Rock.Season.04.HDTV.XviD-DIMENSION", "30.Rock", 4)]
[TestCase("Parks.and.Recreation.S02.720p.x264-DIMENSION", "Parks.and.Recreation", 2)]
@ -364,5 +374,13 @@ namespace NzbDrone.Core.Test
ExceptionVerification.ExcpectedWarns(1);
}
[TestCase("Fussball Bundesliga 2010 2011 30 Spieltag FC Bayern Muenchen vs Bayer 04 Leverkusen German WS dTV XviD WoGS")]
public void unparsable_should_log_error_but_not_throw(string title)
{
Parser.ParseTitle(title);
ExceptionVerification.IgnoreWarns();
ExceptionVerification.ExcpectedErrors(1);
}
}
}

@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.ProviderTests
//Assert
VerifySkipImport(result, mocker);
ExceptionVerification.ExcpectedWarns(1);
ExceptionVerification.ExcpectedWarns(2);
}
[Test]

@ -155,7 +155,7 @@ namespace NzbDrone.Core.Test.ProviderTests.LogProviderTests
//Assert
var result = Db.Fetch<Log>();
result.Should().HaveCount(21);
result.Should().HaveCount(20);
result.Should().OnlyContain(s => s.Time > DateTime.Now.AddDays(-30));
}

@ -80,26 +80,36 @@ namespace NzbDrone.Core
internal static EpisodeParseResult ParseTitle(string title)
{
Logger.Trace("Parsing string '{0}'", title);
var simpleTitle = SimpleTitleRegex.Replace(title, String.Empty);
foreach (var regex in ReportTitleRegex)
try
{
var match = regex.Matches(simpleTitle);
Logger.Trace("Parsing string '{0}'", title);
var simpleTitle = SimpleTitleRegex.Replace(title, String.Empty);
if (match.Count != 0)
foreach (var regex in ReportTitleRegex)
{
var result = ParseMatchCollection(match);
if (result != null)
var match = regex.Matches(simpleTitle);
if (match.Count != 0)
{
result.Language = ParseLanguage(title);
result.Quality = ParseQuality(title);
return result;
var result = ParseMatchCollection(match);
if (result != null)
{
//Check if episode is in the future (most likley a parse error)
if (result.AirDate > DateTime.Now.AddDays(1).Date)
break;
result.Language = ParseLanguage(title);
result.Quality = ParseQuality(title);
return result;
}
}
}
Logger.Warn("Unable to parse episode info. {0}", title);
}
catch (Exception e)
{
Logger.Error("An error has occurred while trying to parse '{0}'", title);
}
Logger.Warn("Unable to parse episode info. {0}", title);
return null;
}
@ -164,7 +174,7 @@ namespace NzbDrone.Core
parsedEpisode = new EpisodeParseResult
{
AirDate = new DateTime(airyear, airmonth, airday),
AirDate = new DateTime(airyear, airmonth, airday).Date,
};
}

Loading…
Cancel
Save