From c91ff9be3ee2f9af90eb2af84b3c542f17dc5749 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 14 Oct 2012 18:20:27 -0700 Subject: [PATCH 1/3] a.b.hdtv added New: Enabled searching of a.b.hdtv for NzbClub and NzbIndex --- NzbDrone.Core/Providers/Indexer/NzbClub.cs | 3 ++- NzbDrone.Core/Providers/Indexer/NzbIndex.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core/Providers/Indexer/NzbClub.cs b/NzbDrone.Core/Providers/Indexer/NzbClub.cs index 198129ab1..019753c95 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbClub.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbClub.cs @@ -23,7 +23,8 @@ namespace NzbDrone.Core.Providers.Indexer { return new[] { - string.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee%40EFNet") + String.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee%40EFNet"), + String.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=%23a.b.teevee%40EFNet") }; } } diff --git a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs index 69aacea8d..fca30d7b4 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs @@ -23,7 +23,8 @@ namespace NzbDrone.Core.Providers.Indexer { return new[] { - string.Format("http://www.nzbindex.nl/rss/alt.binaries.teevee/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet") + String.Format("http://www.nzbindex.nl/rss/alt.binaries.teevee/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet"), + String.Format("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet") }; } } From fae0cadbec1d11cca5fe19e94a6a6fba32153080 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 14 Oct 2012 19:21:12 -0700 Subject: [PATCH 2/3] Fixed header parsing --- NzbDrone.Core.Test/ParserTest.cs | 7 +++++++ NzbDrone.Core/Parser.cs | 19 ++++++++++++++----- NzbDrone.Core/Providers/Indexer/NzbClub.cs | 2 +- NzbDrone.Core/Providers/Indexer/NzbIndex.cs | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 40a78a785..ca9c7b008 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -453,5 +453,12 @@ namespace NzbDrone.Core.Test { Parser.ParseReleaseGroup(title).Should().Be(expected); } + + [TestCase("[112461]-[FULL]-[#a.b.teevee@EFNet]-[ 666.Park.Avenue.S01E03.720p.HDTV.X264-DIMENSION ]-[02/31] - \"the.devils.address.103.720p-dimension.par2\" yEnc", "666.Park.Avenue.S01E03.720p.HDTV.X264-DIMENSION")] + [TestCase("[112438]-[FULL]-[#a.b.teevee@EFNet]-[ Downton_Abbey.3x05.HDTV_x264-FoV ]-[01/26] - \"downton_abbey.3x05.hdtv_x264-fov.nfo\" yEnc", "Downton_Abbey.3x05.HDTV_x264-FoV")] + public void parse_header(string title, string expected) + { + Parser.ParseHeader(title).Should().Be(expected); + } } } diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index a151e0ef5..c3e7f5a72 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -74,8 +74,14 @@ namespace NzbDrone.Core private static readonly Regex ReportSizeRegex = new Regex(@"(?\d+\.\d{1,2}|\d+\,\d+\.\d{1,2})\W?(?GB|MB|GiB|MiB)", RegexOptions.IgnoreCase | RegexOptions.Compiled); - private static readonly Regex HeaderRegex = new Regex(@"(?:\[.+\]\-\[.+\]\-\[.+\]\-\[)(?.+)(?:\]\-.+)", - RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static readonly Regex[] HeaderRegex = new[] + { + new Regex(@"(?:\[.+\]\-\[.+\]\-\[.+\]\-\[)(?.+)(?:\]\-.+)", + RegexOptions.IgnoreCase | RegexOptions.Compiled), + + new Regex(@"(?:\[)(?.+)(?:\]\-.+)", + RegexOptions.IgnoreCase | RegexOptions.Compiled), + }; internal static EpisodeParseResult ParsePath(string path) { @@ -480,10 +486,13 @@ namespace NzbDrone.Core internal static string ParseHeader(string header) { - var match = HeaderRegex.Matches(header); + foreach(var regex in HeaderRegex) + { + var match = regex.Matches(header); - if (match.Count != 0) - return match[0].Groups["nzbTitle"].Value; + if (match.Count != 0) + return match[0].Groups["nzbTitle"].Value.Trim(); + } return header; } diff --git a/NzbDrone.Core/Providers/Indexer/NzbClub.cs b/NzbDrone.Core/Providers/Indexer/NzbClub.cs index 019753c95..ed21d4e14 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbClub.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbClub.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Providers.Indexer return new[] { String.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee%40EFNet"), - String.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=%23a.b.teevee%40EFNet") + String.Format("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=") }; } } diff --git a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs index fca30d7b4..4a7ebd847 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Core.Providers.Indexer return new[] { String.Format("http://www.nzbindex.nl/rss/alt.binaries.teevee/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet"), - String.Format("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet") + String.Format("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=") }; } } From 89c0a7a2f0630dffbd645dc602697e6f28b068d9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 14 Oct 2012 19:36:31 -0700 Subject: [PATCH 3/3] Fixed tests for multiple URLs --- NzbDrone.Core.Test/IndexerTests.cs | 62 +++++++++++------------------- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 153eea289..88097770b 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -341,7 +341,6 @@ namespace NzbDrone.Core.Test //Act var parseResults = Mocker.Resolve().FetchRss(); - parseResults.Should().HaveCount(1); parseResults[0].Size.Should().Be(1183105773); } @@ -351,13 +350,16 @@ namespace NzbDrone.Core.Test WithConfiguredIndexers(); Mocker.GetMock() - .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.teevee/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet", It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbindex.xml")); + + Mocker.GetMock() + .Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=", It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbindex.xml")); //Act var parseResults = Mocker.Resolve().FetchRss(); - parseResults.Should().HaveCount(1); parseResults[0].Size.Should().Be(587328389); } @@ -367,13 +369,17 @@ namespace NzbDrone.Core.Test WithConfiguredIndexers(); Mocker.GetMock() - .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee%40EFNet", It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbclub.xml")); + + Mocker.GetMock() + .Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=", It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbclub.xml")); //Act var parseResults = Mocker.Resolve().FetchRss(); - parseResults.Should().HaveCount(1); + parseResults.Should().HaveCount(2); parseResults[0].Size.Should().Be(2652142305); } @@ -462,38 +468,6 @@ namespace NzbDrone.Core.Test ExceptionVerification.MarkInconclusive("(500) Internal Server Error."); } - [Test] - public void title_preparse_nzbindex() - { - WithConfiguredIndexers(); - - Mocker.GetMock() - .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) - .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbindex.xml")); - - //Act - var parseResults = Mocker.Resolve().FetchRss(); - - parseResults.Should().HaveCount(1); - parseResults[0].CleanTitle.Should().Be("britainsgotmoretalent"); - } - - [Test] - public void title_preparse_nzbclub() - { - WithConfiguredIndexers(); - - Mocker.GetMock() - .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) - .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\nzbclub.xml")); - - //Act - var parseResults = Mocker.Resolve().FetchRss(); - - parseResults.Should().HaveCount(1); - parseResults[0].CleanTitle.Should().Be("britainsgottalent"); - } - [TestCase("wombles.xml", "de-de")] public void dateTime_should_parse_when_using_other_cultures(string fileName, string culture) { @@ -662,8 +636,12 @@ namespace NzbDrone.Core.Test const string expectedString = "release"; Mocker.GetMock() - .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) - .Returns(File.OpenRead(".\\Files\\Rss\\" + fileName)); + .Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.teevee/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=%23a.b.teevee%40EFNet", It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\nzbindex.xml")); + + Mocker.GetMock() + .Setup(h => h.DownloadStream("http://www.nzbindex.nl/rss/alt.binaries.hdtv/?sort=agedesc&minsize=100&complete=1&max=50&more=1&q=", It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\nzbindex.xml")); var parseResults = Mocker.Resolve().FetchRss(); @@ -682,7 +660,11 @@ namespace NzbDrone.Core.Test const string expectedString = "nzb_view"; Mocker.GetMock() - .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=102952&st=1&ns=1&q=%23a.b.teevee%40EFNet", It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\" + fileName)); + + Mocker.GetMock() + .Setup(h => h.DownloadStream("http://www.nzbclub.com/nzbfeed.aspx?ig=2&gid=5542&st=1&ns=1&q=", It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\" + fileName)); var parseResults = Mocker.Resolve().FetchRss();