Added NzbInfoUrl to indexers.

pull/2/head
Mark McDowall 13 years ago
parent ce0a6f8b86
commit b314ff5e82

@ -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 @@ namespace NzbDrone.Core.Test
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<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\" + fileName));
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
Mocker.GetMock<IndexerProvider>()
.Setup(c => c.GetSettings(It.IsAny<Type>()))
.Returns(fakeSettings);
var mockIndexer = Mocker.Resolve<MockIndexer>();
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);
}
}
}

@ -141,11 +141,15 @@ namespace NzbDrone.Core.Test.ProviderTests
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 @@ namespace NzbDrone.Core.Test.ProviderTests
{
return "http://google.com";
}
protected override string NzbInfoUrl(SyndicationItem item)
{
return "http://google.com";
}
}
public class CustomParserIndexer : IndexerBase
@ -243,6 +252,11 @@ namespace NzbDrone.Core.Test.ProviderTests
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 @@ namespace NzbDrone.Core.Test.ProviderTests
{
throw new NotImplementedException();
}
protected override string NzbInfoUrl(SyndicationItem item)
{
throw new NotImplementedException();
}
}
public class DefaultEnabledIndexer : IndexerBase
@ -346,11 +365,16 @@ namespace NzbDrone.Core.Test.ProviderTests
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; }

@ -224,6 +224,7 @@
<Compile Include="Datastore\MigrationLogger.cs" />
<Compile Include="Datastore\MigrationsHelper.cs" />
<Compile Include="Datastore\CustomeMapper.cs" />
<Compile Include="Datastore\Migrations\Migration20120430.cs" />
<Compile Include="Datastore\Migrations\Migration20120420.cs" />
<Compile Include="Datastore\Migrations\Migration20120228.cs" />
<Compile Include="Datastore\Migrations\Migration20120227.cs" />

@ -68,6 +68,11 @@ namespace NzbDrone.Core.Providers.Indexer
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)

@ -97,6 +97,13 @@ namespace NzbDrone.Core.Providers.Indexer
/// <returns>Download link URL</returns>
protected abstract string NzbDownloadUrl(SyndicationItem item);
/// <summary>
/// Generates link to the NZB info at the indexer
/// </summary>
/// <param name = "item">RSS Feed item to generate the link for</param>
/// <returns>Nzb Info URL</returns>
protected abstract string NzbInfoUrl(SyndicationItem item);
/// <summary>
/// Fetches RSS feed and process each news item.
/// </summary>
@ -191,6 +198,7 @@ namespace NzbDrone.Core.Providers.Indexer
if (parsedEpisode != null)
{
parsedEpisode.NzbUrl = NzbDownloadUrl(item);
parsedEpisode.NzbInfoUrl = NzbInfoUrl(item);
parsedEpisode.Indexer = Name;
result.Add(parsedEpisode);
}

@ -101,6 +101,11 @@ namespace NzbDrone.Core.Providers.Indexer
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)

@ -74,6 +74,11 @@ namespace NzbDrone.Core.Providers.Indexer
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)

@ -46,6 +46,11 @@ namespace NzbDrone.Core.Providers.Indexer
return item.Links[0].Uri.ToString();
}
protected override string NzbInfoUrl(SyndicationItem item)
{
return item.Links[0].Uri.ToString();
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
var searchUrls = new List<String>();

@ -46,6 +46,11 @@ namespace NzbDrone.Core.Providers.Indexer
return item.Links[1].Uri.ToString();
}
protected override string NzbInfoUrl(SyndicationItem item)
{
return item.Links[0].Uri.ToString();
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
var searchUrls = new List<String>();

@ -101,6 +101,11 @@ namespace NzbDrone.Core.Providers.Indexer
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)

@ -98,6 +98,11 @@ namespace NzbDrone.Core.Providers.Indexer
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)

@ -49,6 +49,10 @@ namespace NzbDrone.Core.Providers.Indexer
return item.Links[0].Uri.ToString();
}
protected override string NzbInfoUrl(SyndicationItem item)
{
return item.Links[0].Uri.ToString();
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{

@ -45,6 +45,10 @@ namespace NzbDrone.Core.Providers.Indexer
return item.Links[0].Uri.ToString();
}
protected override string NzbInfoUrl(SyndicationItem item)
{
return item.Links[0].Uri.ToString();
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{

Loading…
Cancel
Save