From b314ff5e822e92467be4c7ee06f7b190543b966f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 2 May 2012 12:02:39 -0700 Subject: [PATCH] Added NzbInfoUrl to indexers. --- NzbDrone.Core.Test/IndexerTests.cs | 35 ++++++++++++++++++- .../ProviderTests/IndexerProviderTest.cs | 30 ++++++++++++++-- NzbDrone.Core/NzbDrone.Core.csproj | 1 + .../Providers/Indexer/FileSharingTalk.cs | 5 +++ .../Providers/Indexer/IndexerBase.cs | 8 +++++ NzbDrone.Core/Providers/Indexer/Newzbin.cs | 5 +++ NzbDrone.Core/Providers/Indexer/Newznab.cs | 5 +++ NzbDrone.Core/Providers/Indexer/NzbClub.cs | 5 +++ NzbDrone.Core/Providers/Indexer/NzbIndex.cs | 5 +++ NzbDrone.Core/Providers/Indexer/NzbMatrix.cs | 5 +++ NzbDrone.Core/Providers/Indexer/NzbsOrg.cs | 5 +++ NzbDrone.Core/Providers/Indexer/NzbsRUs.cs | 4 +++ NzbDrone.Core/Providers/Indexer/Wombles.cs | 4 +++ 13 files changed, 113 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 417eaa5a8..4559f8deb 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -26,7 +26,6 @@ namespace NzbDrone.Core.Test // ReSharper disable InconsistentNaming public class IndexerTests : CoreTest { - [TestCase("nzbsorg.xml")] [TestCase("nzbsrus.xml")] [TestCase("newzbin.xml")] @@ -563,5 +562,39 @@ public void dateTime_should_parse_when_using_other_cultures(string fileName, str Thread.CurrentThread.CurrentCulture = currentCulture; } + + [TestCase("nzbsorg.xml", "info")] + [TestCase("nzbsrus.xml", "info")] + [TestCase("newzbin.xml", "info")] + [TestCase("nzbmatrix.xml", "info")] + [TestCase("newznab.xml", "info")] + [TestCase("wombles.xml", "info")] + [TestCase("filesharingtalk.xml", "info")] + [TestCase("nzbindex.xml", "info")] + [TestCase("nzbclub.xml", "info")] + public void NzbInfoUrl_should_contain_information_string(string fileName, string expectedContent) + { + Mocker.GetMock() + .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) + .Returns(File.OpenRead(".\\Files\\Rss\\" + fileName)); + + var fakeSettings = Builder.CreateNew().Build(); + Mocker.GetMock() + .Setup(c => c.GetSettings(It.IsAny())) + .Returns(fakeSettings); + + var mockIndexer = Mocker.Resolve(); + var parseResults = mockIndexer.FetchRss(); + + foreach (var episodeParseResult in parseResults) + { + episodeParseResult.NzbInfoUrl.Should().Contain(expectedContent); + } + + parseResults.Should().NotBeEmpty(); + parseResults.Should().OnlyContain(s => s.Indexer == mockIndexer.Name); + parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString)); + parseResults.Should().OnlyContain(s => s.Age >= 0); + } } } diff --git a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs index f8aed279b..7fc319096 100644 --- a/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/IndexerProviderTest.cs @@ -141,11 +141,15 @@ public override string Name get { return "Mocked Indexer"; } } - protected override string NzbDownloadUrl(SyndicationItem item) { return item.Links[0].Uri.ToString(); } + + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[1].Uri.ToString(); + } } public class TestUrlIndexer : IndexerBase @@ -194,6 +198,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) { return "http://google.com"; } + + protected override string NzbInfoUrl(SyndicationItem item) + { + return "http://google.com"; + } } public class CustomParserIndexer : IndexerBase @@ -243,6 +252,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return "http://www.google.com"; } + protected override string NzbInfoUrl(SyndicationItem item) + { + return "http://www.google.com"; + } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) { if (currentResult == null) currentResult = new EpisodeParseResult(); @@ -297,6 +311,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) { throw new NotImplementedException(); } + + protected override string NzbInfoUrl(SyndicationItem item) + { + throw new NotImplementedException(); + } } public class DefaultEnabledIndexer : IndexerBase @@ -345,12 +364,17 @@ public override string Name { get { return "Mocked Indexer"; } } - - + protected override string NzbDownloadUrl(SyndicationItem item) { return item.Links[0].Uri.ToString(); } + + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[1].Uri.ToString(); + } + public override bool EnabledByDefault { get { return true; } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 6e960e097..8a4e71889 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -224,6 +224,7 @@ + diff --git a/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs b/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs index 645b89dda..ff0daadb1 100644 --- a/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs +++ b/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs @@ -68,6 +68,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Links[0].Uri.ToString(); } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) { if (currentResult != null) diff --git a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs index af9bf25aa..3b8af79f5 100644 --- a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs +++ b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs @@ -97,6 +97,13 @@ protected virtual string TitlePreParser(SyndicationItem item) /// Download link URL protected abstract string NzbDownloadUrl(SyndicationItem item); + /// + /// Generates link to the NZB info at the indexer + /// + /// RSS Feed item to generate the link for + /// Nzb Info URL + protected abstract string NzbInfoUrl(SyndicationItem item); + /// /// Fetches RSS feed and process each news item. /// @@ -191,6 +198,7 @@ private List Fetch(IEnumerable urls) if (parsedEpisode != null) { parsedEpisode.NzbUrl = NzbDownloadUrl(item); + parsedEpisode.NzbInfoUrl = NzbInfoUrl(item); parsedEpisode.Indexer = Name; result.Add(parsedEpisode); } diff --git a/NzbDrone.Core/Providers/Indexer/Newzbin.cs b/NzbDrone.Core/Providers/Indexer/Newzbin.cs index 74101a75b..733f70ce3 100644 --- a/NzbDrone.Core/Providers/Indexer/Newzbin.cs +++ b/NzbDrone.Core/Providers/Indexer/Newzbin.cs @@ -101,6 +101,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Id + "nzb"; } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) { if (currentResult != null) diff --git a/NzbDrone.Core/Providers/Indexer/Newznab.cs b/NzbDrone.Core/Providers/Indexer/Newznab.cs index 41e988dde..e6a9aa41c 100644 --- a/NzbDrone.Core/Providers/Indexer/Newznab.cs +++ b/NzbDrone.Core/Providers/Indexer/Newznab.cs @@ -74,6 +74,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Links[0].Uri.ToString(); } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) { if (currentResult != null) diff --git a/NzbDrone.Core/Providers/Indexer/NzbClub.cs b/NzbDrone.Core/Providers/Indexer/NzbClub.cs index f16fa0133..beed3893a 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbClub.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbClub.cs @@ -46,6 +46,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Links[0].Uri.ToString(); } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { var searchUrls = new List(); diff --git a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs index 675644891..69aacea8d 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs @@ -46,6 +46,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Links[1].Uri.ToString(); } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { var searchUrls = new List(); diff --git a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs index 1efadfc3f..922e33cf6 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbMatrix.cs @@ -101,6 +101,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Links[0].Uri.ToString(); } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) { if (currentResult != null) diff --git a/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs b/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs index 3363f2e21..320d7a000 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsOrg.cs @@ -98,6 +98,11 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Id; } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult) { if (currentResult != null) diff --git a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs index d88c51abf..bc9024fce 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs @@ -49,6 +49,10 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Links[0].Uri.ToString(); } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) { diff --git a/NzbDrone.Core/Providers/Indexer/Wombles.cs b/NzbDrone.Core/Providers/Indexer/Wombles.cs index efbb35e4f..3110afed5 100644 --- a/NzbDrone.Core/Providers/Indexer/Wombles.cs +++ b/NzbDrone.Core/Providers/Indexer/Wombles.cs @@ -45,6 +45,10 @@ protected override string NzbDownloadUrl(SyndicationItem item) return item.Links[0].Uri.ToString(); } + protected override string NzbInfoUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } protected override IList GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber) {