mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-01-25 11:13:39 +02:00
Initial support for episode search in indexerbase and Nzbs.org
This commit is contained in:
parent
4cc240a7e0
commit
9417748056
@ -42,7 +42,7 @@ namespace NzbDrone.Core.Test
|
|||||||
.Returns(fakeSettings);
|
.Returns(fakeSettings);
|
||||||
|
|
||||||
var mockIndexer = mocker.Resolve<MockIndexer>();
|
var mockIndexer = mocker.Resolve<MockIndexer>();
|
||||||
var parseResults = mockIndexer.Fetch();
|
var parseResults = mockIndexer.FetchRss();
|
||||||
|
|
||||||
foreach (var episodeParseResult in parseResults)
|
foreach (var episodeParseResult in parseResults)
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test
|
|||||||
.Returns(fakeSettings);
|
.Returns(fakeSettings);
|
||||||
|
|
||||||
var newzbinProvider = mocker.Resolve<Newzbin>();
|
var newzbinProvider = mocker.Resolve<Newzbin>();
|
||||||
var parseResults = newzbinProvider.Fetch();
|
var parseResults = newzbinProvider.FetchRss();
|
||||||
|
|
||||||
foreach (var episodeParseResult in parseResults)
|
foreach (var episodeParseResult in parseResults)
|
||||||
{
|
{
|
||||||
@ -163,7 +163,7 @@ namespace NzbDrone.Core.Test
|
|||||||
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
.Setup(c => c.GetSettings(It.IsAny<Type>()))
|
||||||
.Returns(fakeSettings);
|
.Returns(fakeSettings);
|
||||||
|
|
||||||
mocker.Resolve<TestUrlIndexer>().Fetch();
|
mocker.Resolve<TestUrlIndexer>().FetchRss();
|
||||||
|
|
||||||
ExceptionVerification.IgnoreWarns();
|
ExceptionVerification.IgnoreWarns();
|
||||||
}
|
}
|
||||||
@ -195,12 +195,39 @@ namespace NzbDrone.Core.Test
|
|||||||
var indexer = mocker.Resolve<MockIndexer>();
|
var indexer = mocker.Resolve<MockIndexer>();
|
||||||
//indexer.ProcessItem(new SyndicationItem { Title = new TextSyndicationContent("Adventure.Inc.S01E18.DVDRip.XviD-OSiTV") });
|
//indexer.ProcessItem(new SyndicationItem { Title = new TextSyndicationContent("Adventure.Inc.S01E18.DVDRip.XviD-OSiTV") });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void nzbsorg_search_returns_valid_results()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
mocker.GetMock<ConfigProvider>()
|
||||||
|
.SetupGet(c => c.NzbsOrgUId)
|
||||||
|
.Returns("43516");
|
||||||
|
|
||||||
|
mocker.GetMock<ConfigProvider>()
|
||||||
|
.SetupGet(c => c.NzbsOrgHash)
|
||||||
|
.Returns("bc8edb4cc49d4ae440775adec5ac001f");
|
||||||
|
|
||||||
|
|
||||||
|
mocker.Resolve<HttpProvider>();
|
||||||
|
|
||||||
|
var result = mocker.Resolve<NzbsOrg>().FetchEpisode("Simpsons", 21, 23);
|
||||||
|
|
||||||
|
Assert.IsNotEmpty(result);
|
||||||
|
Assert.ForAll(result, r => r.CleanTitle == "simpsons");
|
||||||
|
Assert.ForAll(result, r => r.SeasonNumber == 21);
|
||||||
|
Assert.ForAll(result, r => r.EpisodeNumbers.Contains(23));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MockIndexer : IndexerBase
|
public class MockIndexer : IndexerBase
|
||||||
{
|
{
|
||||||
public MockIndexer(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider)
|
public MockIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
|
||||||
: base(httpProvider, configProvider, indexerProvider)
|
: base(httpProvider, configProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +236,11 @@ namespace NzbDrone.Core.Test
|
|||||||
get { return new[] { "www.google.com" }; }
|
get { return new[] { "www.google.com" }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
protected override NetworkCredential Credentials
|
protected override NetworkCredential Credentials
|
||||||
{
|
{
|
||||||
get { return null; }
|
get { return null; }
|
||||||
@ -228,8 +260,8 @@ namespace NzbDrone.Core.Test
|
|||||||
|
|
||||||
public class TestUrlIndexer : IndexerBase
|
public class TestUrlIndexer : IndexerBase
|
||||||
{
|
{
|
||||||
public TestUrlIndexer(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider)
|
public TestUrlIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
|
||||||
: base(httpProvider, configProvider, indexerProvider)
|
: base(httpProvider, configProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +275,11 @@ namespace NzbDrone.Core.Test
|
|||||||
get { return new[] { "http://rss.nzbmatrix.com/rss.php?cat=TV" }; }
|
get { return new[] { "http://rss.nzbmatrix.com/rss.php?cat=TV" }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
protected override string NzbDownloadUrl(SyndicationItem item)
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
||||||
{
|
{
|
||||||
return "http://google.com";
|
return "http://google.com";
|
||||||
@ -251,8 +288,8 @@ namespace NzbDrone.Core.Test
|
|||||||
|
|
||||||
public class CustomParserIndexer : IndexerBase
|
public class CustomParserIndexer : IndexerBase
|
||||||
{
|
{
|
||||||
public CustomParserIndexer(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider)
|
public CustomParserIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
|
||||||
: base(httpProvider, configProvider, indexerProvider)
|
: base(httpProvider, configProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +305,11 @@ namespace NzbDrone.Core.Test
|
|||||||
get { return new[] { "http://www.google.com" }; }
|
get { return new[] { "http://www.google.com" }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
protected override string NzbDownloadUrl(SyndicationItem item)
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
||||||
{
|
{
|
||||||
return "http://www.google.com";
|
return "http://www.google.com";
|
||||||
|
@ -171,7 +171,7 @@
|
|||||||
<Compile Include="Providers\DownloadProvider.cs" />
|
<Compile Include="Providers\DownloadProvider.cs" />
|
||||||
<Compile Include="Providers\ExternalNotification\ExternalNotificationProviderBase.cs" />
|
<Compile Include="Providers\ExternalNotification\ExternalNotificationProviderBase.cs" />
|
||||||
<Compile Include="Providers\ExternalNotification\XbmcNotificationProvider.cs" />
|
<Compile Include="Providers\ExternalNotification\XbmcNotificationProvider.cs" />
|
||||||
<Compile Include="Providers\Indexer\InventoryProvider.cs" />
|
<Compile Include="Providers\InventoryProvider.cs" />
|
||||||
<Compile Include="Providers\Indexer\SyndicationFeedXmlReader.cs" />
|
<Compile Include="Providers\Indexer\SyndicationFeedXmlReader.cs" />
|
||||||
<Compile Include="Providers\AutoConfigureProvider.cs" />
|
<Compile Include="Providers\AutoConfigureProvider.cs" />
|
||||||
<Compile Include="Providers\Indexer\NzbMatrix.cs" />
|
<Compile Include="Providers\Indexer\NzbMatrix.cs" />
|
||||||
|
@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.ServiceModel.Syndication;
|
using System.ServiceModel.Syndication;
|
||||||
|
using System.Web;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
@ -14,13 +15,11 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
protected readonly Logger _logger;
|
protected readonly Logger _logger;
|
||||||
private readonly HttpProvider _httpProvider;
|
private readonly HttpProvider _httpProvider;
|
||||||
protected readonly ConfigProvider _configProvider;
|
protected readonly ConfigProvider _configProvider;
|
||||||
private readonly IndexerProvider _indexerProvider;
|
|
||||||
|
|
||||||
protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider)
|
protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider)
|
||||||
{
|
{
|
||||||
_httpProvider = httpProvider;
|
_httpProvider = httpProvider;
|
||||||
_configProvider = configProvider;
|
_configProvider = configProvider;
|
||||||
_indexerProvider = indexerProvider;
|
|
||||||
|
|
||||||
_logger = LogManager.GetLogger(GetType().ToString());
|
_logger = LogManager.GetLogger(GetType().ToString());
|
||||||
}
|
}
|
||||||
@ -35,6 +34,16 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract string[] Urls { get; }
|
protected abstract string[] Urls { get; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the rss url for specific episode search
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seriesTitle">The series title.</param>
|
||||||
|
/// <param name="seasonNumber">The season number.</param>
|
||||||
|
/// <param name="episodeNumber">The episode number.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected abstract IList<String> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the credential.
|
/// Gets the credential.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -43,59 +52,80 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
get { return null; }
|
get { return null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexerSetting Settings
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _indexerProvider.GetSettings(GetType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches RSS feed and process each news item.
|
/// Fetches RSS feed and process each news item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<EpisodeParseResult> Fetch()
|
public IList<EpisodeParseResult> FetchRss()
|
||||||
{
|
{
|
||||||
_logger.Debug("Fetching feeds from " + Settings.Name);
|
_logger.Debug("Fetching feeds from " + Name);
|
||||||
|
|
||||||
var result = new List<EpisodeParseResult>();
|
var result = new List<EpisodeParseResult>();
|
||||||
|
|
||||||
foreach (var url in Urls)
|
foreach (var url in Urls)
|
||||||
{
|
{
|
||||||
try
|
result.AddRange(Fetch(url));
|
||||||
{
|
}
|
||||||
_logger.Trace("Downloading RSS " + url);
|
|
||||||
|
_logger.Info("Finished processing feeds from " + Name);
|
||||||
var reader = new SyndicationFeedXmlReader(_httpProvider.DownloadStream(url, Credentials));
|
return result;
|
||||||
var feed = SyndicationFeed.Load(reader).Items;
|
}
|
||||||
|
|
||||||
foreach (var item in feed)
|
|
||||||
{
|
public IList<EpisodeParseResult> FetchEpisode(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
try
|
{
|
||||||
{
|
_logger.Debug("Searching {0} for {1}-S{2}E{3:00}", Name, seriesTitle, seasonNumber, episodeNumber);
|
||||||
var parsedEpisode = ParseFeed(item);
|
|
||||||
if (parsedEpisode != null)
|
var result = new List<EpisodeParseResult>();
|
||||||
{
|
|
||||||
parsedEpisode.NzbUrl = NzbDownloadUrl(item);
|
var searchUrls = GetSearchUrls(HttpUtility.UrlDecode(seriesTitle), seasonNumber, episodeNumber);
|
||||||
parsedEpisode.Indexer = Name;
|
|
||||||
parsedEpisode.NzbTitle = item.Title.Text;
|
foreach (var url in searchUrls)
|
||||||
result.Add(parsedEpisode);
|
{
|
||||||
}
|
result.AddRange(Fetch(url));
|
||||||
}
|
}
|
||||||
catch (Exception itemEx)
|
|
||||||
{
|
_logger.Info("Finished searching {0} for {1}-S{2}E{3:00}, Found {4}", Name, seriesTitle, seasonNumber, episodeNumber, result.Count);
|
||||||
_logger.ErrorException("An error occurred while processing feed item", itemEx);
|
return result;
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
private IList<EpisodeParseResult> Fetch(string url)
|
||||||
catch (Exception feedEx)
|
{
|
||||||
{
|
var result = new List<EpisodeParseResult>();
|
||||||
_logger.ErrorException("An error occurred while processing feed", feedEx);
|
|
||||||
}
|
try
|
||||||
|
{
|
||||||
|
_logger.Trace("Downloading RSS " + url);
|
||||||
|
|
||||||
|
var reader = new SyndicationFeedXmlReader(_httpProvider.DownloadStream(url, Credentials));
|
||||||
|
var feed = SyndicationFeed.Load(reader).Items;
|
||||||
|
|
||||||
|
foreach (var item in feed)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var parsedEpisode = ParseFeed(item);
|
||||||
|
if (parsedEpisode != null)
|
||||||
|
{
|
||||||
|
parsedEpisode.NzbUrl = NzbDownloadUrl(item);
|
||||||
|
parsedEpisode.Indexer = Name;
|
||||||
|
parsedEpisode.NzbTitle = item.Title.Text;
|
||||||
|
result.Add(parsedEpisode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception itemEx)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("An error occurred while processing feed item", itemEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception feedEx)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("An error occurred while processing feed", feedEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Info("Finished processing feeds from " + Settings.Name);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.ServiceModel.Syndication;
|
using System.ServiceModel.Syndication;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
@ -9,8 +10,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
{
|
{
|
||||||
public class Newzbin : IndexerBase
|
public class Newzbin : IndexerBase
|
||||||
{
|
{
|
||||||
public Newzbin(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider)
|
public Newzbin(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
|
||||||
: base(httpProvider, configProvider, indexerProvider)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,19 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected override NetworkCredential Credentials
|
protected override NetworkCredential Credentials
|
||||||
{
|
{
|
||||||
get { return new NetworkCredential(_configProvider.NewzbinUsername, _configProvider.NewzbinPassword); }
|
get { return new NetworkCredential(_configProvider.NewzbinUsername, _configProvider.NewzbinPassword); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
|
{
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
public override string Name
|
public override string Name
|
||||||
{
|
{
|
||||||
get { return "Newzbin"; }
|
get { return "Newzbin"; }
|
||||||
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
{
|
{
|
||||||
public class NzbMatrix : IndexerBase
|
public class NzbMatrix : IndexerBase
|
||||||
{
|
{
|
||||||
public NzbMatrix(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider) : base(httpProvider, configProvider, indexerProvider)
|
public NzbMatrix(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,5 +40,10 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
return item.Links[0].Uri.ToString();
|
return item.Links[0].Uri.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
|
{
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.ServiceModel.Syndication;
|
using System.ServiceModel.Syndication;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
@ -10,7 +11,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
{
|
{
|
||||||
public class NzbsOrg : IndexerBase
|
public class NzbsOrg : IndexerBase
|
||||||
{
|
{
|
||||||
public NzbsOrg(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider) : base(httpProvider, configProvider, indexerProvider)
|
public NzbsOrg(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,5 +37,17 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
return item.Id;
|
return item.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
|
{
|
||||||
|
var searchUrls = new List<String>();
|
||||||
|
|
||||||
|
foreach (var url in Urls)
|
||||||
|
{
|
||||||
|
searchUrls.Add(String.Format("{0}&action=search&q={1}+s{2}e{3:00}", url, seriesTitle, seasonNumber, episodeNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
return searchUrls;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
{
|
{
|
||||||
public class NzbsRUs : IndexerBase
|
public class NzbsRUs : IndexerBase
|
||||||
{
|
{
|
||||||
public NzbsRUs(HttpProvider httpProvider, ConfigProvider configProvider, IndexerProvider indexerProvider) : base(httpProvider, configProvider, indexerProvider)
|
public NzbsRUs(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,16 +27,20 @@ namespace NzbDrone.Core.Providers.Indexer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Name
|
public override string Name
|
||||||
{
|
{
|
||||||
get { return "NzbsRUs"; }
|
get { return "NzbsRUs"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string NzbDownloadUrl(SyndicationItem item)
|
protected override string NzbDownloadUrl(SyndicationItem item)
|
||||||
{
|
{
|
||||||
return item.Links[0].Uri.ToString();
|
return item.Links[0].Uri.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IList<string> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||||
|
{
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Providers.Core;
|
|
||||||
using NzbDrone.Core.Providers.Indexer;
|
using NzbDrone.Core.Providers.Indexer;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using SubSonic.Repository;
|
using SubSonic.Repository;
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Indexer
|
namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
public class InventoryProvider
|
public class InventoryProvider
|
||||||
{
|
{
|
@ -13,15 +13,17 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||||||
private readonly IEnumerable<IndexerBase> _indexers;
|
private readonly IEnumerable<IndexerBase> _indexers;
|
||||||
private readonly InventoryProvider _inventoryProvider;
|
private readonly InventoryProvider _inventoryProvider;
|
||||||
private readonly DownloadProvider _downloadProvider;
|
private readonly DownloadProvider _downloadProvider;
|
||||||
|
private readonly IndexerProvider _indexerProvider;
|
||||||
|
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public RssSyncJob(IEnumerable<IndexerBase> indexers, InventoryProvider inventoryProvider, DownloadProvider downloadProvider)
|
public RssSyncJob(IEnumerable<IndexerBase> indexers, InventoryProvider inventoryProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider)
|
||||||
{
|
{
|
||||||
_indexers = indexers;
|
_indexers = indexers;
|
||||||
_inventoryProvider = inventoryProvider;
|
_inventoryProvider = inventoryProvider;
|
||||||
_downloadProvider = downloadProvider;
|
_downloadProvider = downloadProvider;
|
||||||
|
_indexerProvider = indexerProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
@ -38,12 +40,12 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||||||
{
|
{
|
||||||
var reports = new List<EpisodeParseResult>();
|
var reports = new List<EpisodeParseResult>();
|
||||||
|
|
||||||
foreach (var indexer in _indexers.Where(i => i.Settings.Enable))
|
foreach (var indexer in _indexers.Where(i => _indexerProvider.GetSettings(i.GetType()).Enable))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
notification.CurrentMessage = "Fetching RSS from " + indexer.Name;
|
notification.CurrentMessage = "Fetching RSS from " + indexer.Name;
|
||||||
reports.AddRange(indexer.Fetch());
|
reports.AddRange(indexer.FetchRss());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user