indexers implementation is now separated from settings/definition

so we can have multiple newznab definitions.
pull/3113/head
Keivan Beigi 12 years ago
parent 50fd2f77b1
commit 96990eabb3

@ -20,7 +20,7 @@ namespace NzbDrone.App.Test
[Test]
public void should_be_able_to_resolve_indexers()
{
MainAppContainerBuilder.BuildContainer().Resolve<IEnumerable<IIndexerBase>>().Should().NotBeEmpty();
MainAppContainerBuilder.BuildContainer().Resolve<IEnumerable<IIndexer>>().Should().NotBeEmpty();
}
[Test]

@ -0,0 +1,73 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Indexers.NzbClub;
using NzbDrone.Core.Indexers.NzbIndex;
using NzbDrone.Core.Indexers.NzbsRUs;
using NzbDrone.Core.Indexers.Omgwtfnzbs;
using NzbDrone.Core.Indexers.Wombles;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.IndexerTests
{
public class IndexerServiceFixture : DbTest<IndexerService, IndexerDefinition>
{
private List<IIndexer> _indexers;
[SetUp]
public void Setup()
{
_indexers = new List<IIndexer>();
_indexers.Add(new Newznab());
_indexers.Add(new Nzbsrus());
_indexers.Add(new NzbClub());
_indexers.Add(new NzbIndex());
_indexers.Add(new Omgwtfnzbs());
_indexers.Add(new Wombles());
Mocker.SetConstant<IEnumerable<IIndexer>>(_indexers);
}
[Test]
public void should_create_default_indexer_on_startup()
{
IList<IndexerDefinition> storedIndexers = null;
Mocker.GetMock<IIndexerRepository>()
.Setup(c => c.InsertMany(It.IsAny<IList<IndexerDefinition>>()))
.Callback<IList<IndexerDefinition>>(indexers => storedIndexers = indexers);
Subject.Handle(new ApplicationStartedEvent());
storedIndexers.Should().NotBeEmpty();
storedIndexers.Select(c => c.Name).Should().OnlyHaveUniqueItems();
storedIndexers.Select(c => c.Enable).Should().NotBeEmpty();
storedIndexers.Select(c => c.Implementation).Should().NotContainNulls();
}
[Test]
public void getting_list_of_indexers()
{
Mocker.SetConstant<IIndexerRepository>(Mocker.Resolve<IndexerRepository>());
Subject.Handle(new ApplicationStartedEvent());
var indexers = Subject.All().ToList();
indexers.Should().NotBeEmpty();
indexers.Should().NotContain(c => c.Settings == null);
indexers.Should().NotContain(c => c.Instance == null);
indexers.Should().NotContain(c => c.Name == null);
indexers.Select(c => c.Name).Should().OnlyHaveUniqueItems();
indexers.Select(c => c.Instance).Should().OnlyHaveUniqueItems();
}
}
}

@ -132,6 +132,7 @@
<Compile Include="Framework\NBuilderExtensions.cs" />
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
<Compile Include="IndexerTests\BasicRssParserFixture.cs" />
<Compile Include="IndexerTests\IndexerServiceFixture.cs" />
<Compile Include="IndexerTests\IntegrationTests\NzbxIntegerationTests.cs" />
<Compile Include="IndexerTests\ParserTests\NzbxParserFixture.cs" />
<Compile Include="JobTests\JobRepositoryFixture.cs" />

@ -102,14 +102,9 @@ namespace NzbDrone.Core.Datastore.Migration
Create.TableForModel("IndexerDefinitions")
.WithColumn("Enable").AsBoolean()
.WithColumn("Name").AsString().Unique()
.WithColumn("Implementation").AsString()
.WithColumn("Settings").AsString().Nullable();
Create.TableForModel("NewznabDefinitions")
.WithColumn("Enable").AsBoolean()
.WithColumn("Name").AsString().Unique()
.WithColumn("Url").AsString()
.WithColumn("ApiKey").AsString().Nullable();
Create.TableForModel("QualityProfiles")
.WithColumn("Name").AsString().Unique()
.WithColumn("Cutoff").AsInt32()

@ -9,7 +9,6 @@ using NzbDrone.Core.DataAugmentation.Scene;
using NzbDrone.Core.Datastore.Converters;
using NzbDrone.Core.ExternalNotification;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.MediaFiles;
@ -34,7 +33,6 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity<RootFolder>().RegisterModel("RootFolders").Ignore(r => r.FreeSpace);
Mapper.Entity<IndexerDefinition>().RegisterModel("IndexerDefinitions");
Mapper.Entity<NewznabDefinition>().RegisterModel("NewznabDefinitions");
Mapper.Entity<JobDefinition>().RegisterModel("JobDefinitions");
Mapper.Entity<ExternalNotificationDefinition>().RegisterModel("ExternalNotificationDefinitions");

@ -109,9 +109,9 @@ namespace NzbDrone.Core.IndexerSearch
return spec;
}
private List<DownloadDecision> Dispatch(Func<IIndexerBase, IEnumerable<ReportInfo>> searchAction, SearchDefinitionBase definitionBase)
private List<DownloadDecision> Dispatch(Func<IIndexer, IEnumerable<ReportInfo>> searchAction, SearchDefinitionBase definitionBase)
{
var indexers = _indexerService.GetAvailableIndexers();
var indexers = _indexerService.GetAvailableIndexers().ToList();
var reports = new List<ReportInfo>();
Parallel.ForEach(indexers, indexer =>

@ -28,7 +28,7 @@ namespace NzbDrone.Core.Indexers
{
var result = new List<ReportInfo>();
var indexers = _indexerService.GetAvailableIndexers();
var indexers = _indexerService.GetAvailableIndexers().ToList();
if (!indexers.Any())
{

@ -3,17 +3,18 @@ using System.Collections.Generic;
namespace NzbDrone.Core.Indexers
{
public interface IIndexerBase
public interface IIndexer
{
string Name { get; }
bool EnabledByDefault { get; }
IEnumerable<IndexerDefinition> DefaultDefinitions { get; }
IndexerDefinition InstanceDefinition { get; set; }
IEnumerable<string> RecentFeed { get; }
IParseFeed Parser { get; }
bool IsConfigured { get; }
IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);
IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date);
IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber);

@ -8,6 +8,13 @@
public class NullSetting : IIndexerSetting
{
public static NullSetting Instance = new NullSetting();
private NullSetting()
{
}
public bool IsValid
{
get

@ -3,18 +3,23 @@ using System.Collections.Generic;
namespace NzbDrone.Core.Indexers
{
public abstract class Indexer : IIndexerBase
public abstract class IndexerBase : IIndexer
{
public abstract string Name { get; }
public IndexerDefinition InstanceDefinition { get; set; }
public virtual bool EnabledByDefault
public virtual IEnumerable<IndexerDefinition> DefaultDefinitions
{
get
{
return true;
yield return new IndexerDefinition
{
Name = Name,
Enable = true,
Implementation = GetType().Name,
Settings = string.Empty
};
}
}
@ -26,13 +31,6 @@ namespace NzbDrone.Core.Indexers
}
}
public virtual bool IsConfigured
{
get { return true; }
}
public abstract IEnumerable<string> RecentFeed { get; }
public abstract IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);

@ -8,5 +8,6 @@ namespace NzbDrone.Core.Indexers
public Boolean Enable { get; set; }
public String Name { get; set; }
public String Settings { get; set; }
public String Implementation { get; set; }
}
}

@ -12,12 +12,12 @@ namespace NzbDrone.Core.Indexers
{
public interface IFetchFeedFromIndexers
{
IList<ReportInfo> FetchRss(IIndexerBase indexer);
IList<ReportInfo> FetchRss(IIndexer indexer);
IList<ReportInfo> Fetch(IIndexerBase indexer, SeasonSearchDefinition searchDefinition);
IList<ReportInfo> Fetch(IIndexerBase indexer, SingleEpisodeSearchDefinition searchDefinition);
IList<ReportInfo> Fetch(IIndexerBase indexer, PartialSeasonSearchDefinition searchDefinition);
IList<ReportInfo> Fetch(IIndexerBase indexer, DailyEpisodeSearchDefinition searchDefinition);
IList<ReportInfo> Fetch(IIndexer indexer, SeasonSearchDefinition searchDefinition);
IList<ReportInfo> Fetch(IIndexer indexer, SingleEpisodeSearchDefinition searchDefinition);
IList<ReportInfo> Fetch(IIndexer indexer, PartialSeasonSearchDefinition searchDefinition);
IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchDefinition searchDefinition);
}
public class FetchFeedService : IFetchFeedFromIndexers
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Indexers
}
public virtual IList<ReportInfo> FetchRss(IIndexerBase indexer)
public virtual IList<ReportInfo> FetchRss(IIndexer indexer)
{
_logger.Debug("Fetching feeds from " + indexer.Name);
@ -44,7 +44,7 @@ namespace NzbDrone.Core.Indexers
return result;
}
public IList<ReportInfo> Fetch(IIndexerBase indexer, SeasonSearchDefinition searchDefinition)
public IList<ReportInfo> Fetch(IIndexer indexer, SeasonSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Indexers
return result;
}
public IList<ReportInfo> Fetch(IIndexerBase indexer, SingleEpisodeSearchDefinition searchDefinition)
public IList<ReportInfo> Fetch(IIndexer indexer, SingleEpisodeSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -69,7 +69,7 @@ namespace NzbDrone.Core.Indexers
}
public IList<ReportInfo> Fetch(IIndexerBase indexer, PartialSeasonSearchDefinition searchDefinition)
public IList<ReportInfo> Fetch(IIndexer indexer, PartialSeasonSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -81,7 +81,7 @@ namespace NzbDrone.Core.Indexers
return result;
}
public IList<ReportInfo> Fetch(IIndexerBase indexer, DailyEpisodeSearchDefinition searchDefinition)
public IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchDefinition searchDefinition)
{
_logger.Debug("Searching for {0}", searchDefinition);
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Indexers
return result;
}
private List<ReportInfo> Fetch(IIndexerBase indexer, IEnumerable<string> urls)
private List<ReportInfo> Fetch(IIndexer indexer, IEnumerable<string> urls)
{
var result = new List<ReportInfo>();

@ -8,12 +8,21 @@ using NzbDrone.Core.Lifecycle;
namespace NzbDrone.Core.Indexers
{
public class Indexer
{
public int DefinitionId { get; set; }
public string Name { get; set; }
public bool Enable { get; set; }
public IIndexerSetting Settings { get; set; }
public IIndexer Instance { get; set; }
}
public interface IIndexerService
{
List<IndexerDefinition> All();
List<IIndexerBase> GetAvailableIndexers();
void Save(IndexerDefinition indexer);
IndexerDefinition Get(string name);
List<Indexer> All();
List<IIndexer> GetAvailableIndexers();
Indexer Get(string name);
}
public class IndexerService : IIndexerService, IHandle<ApplicationStartedEvent>
@ -21,9 +30,9 @@ namespace NzbDrone.Core.Indexers
private readonly IIndexerRepository _indexerRepository;
private readonly Logger _logger;
private readonly IList<IIndexerBase> _indexers;
private readonly IList<IIndexer> _indexers;
public IndexerService(IIndexerRepository indexerRepository, IEnumerable<IIndexerBase> indexers, Logger logger)
public IndexerService(IIndexerRepository indexerRepository, IEnumerable<IIndexer> indexers, Logger logger)
{
_indexerRepository = indexerRepository;
_logger = logger;
@ -31,48 +40,65 @@ namespace NzbDrone.Core.Indexers
}
public List<IndexerDefinition> All()
public List<Indexer> All()
{
return _indexerRepository.All().ToList();
return _indexerRepository.All().Select(ToIndexer).ToList();
}
public List<IIndexerBase> GetAvailableIndexers()
public List<IIndexer> GetAvailableIndexers()
{
var enabled = All().Where(c => c.Enable).Select(c => c.Name);
var configureIndexers = _indexers.Where(c => c.IsConfigured);
return All().Where(c => c.Enable && c.Settings.IsValid).Select(c=>c.Instance).ToList();
}
return configureIndexers.Where(c => enabled.Contains(c.Name)).ToList();
public Indexer Get(string name)
{
return ToIndexer(_indexerRepository.Get(name));
}
public void Save(IndexerDefinition indexer)
private Indexer ToIndexer(IndexerDefinition definition)
{
_indexerRepository.Update(indexer);
var indexer = new Indexer();
indexer.DefinitionId = definition.Id;
indexer.Enable = definition.Enable;
indexer.Instance = GetInstance(definition);
indexer.Name = definition.Name;
if (indexer.Instance.GetType().GetMethod("ImportSettingsFromJson") != null)
{
indexer.Settings = ((dynamic)indexer.Instance).ImportSettingsFromJson(definition.Settings);
}
else
{
indexer.Settings = NullSetting.Instance;
}
return indexer;
}
public IndexerDefinition Get(string name)
private IIndexer GetInstance(IndexerDefinition indexerDefinition)
{
return _indexerRepository.Get(name);
var existingInstance = _indexers.Single(c => c.GetType().Name.Equals(indexerDefinition.Implementation, StringComparison.CurrentCultureIgnoreCase));
var instance = (IIndexer)Activator.CreateInstance(existingInstance.GetType());
instance.InstanceDefinition = indexerDefinition;
return instance;
}
public void Handle(ApplicationStartedEvent message)
{
_logger.Debug("Initializing indexers. Count {0}", _indexers.Count);
var currentIndexers = All();
foreach (var feedProvider in _indexers)
if (!All().Any())
{
IIndexerBase indexerLocal = feedProvider;
if (!currentIndexers.Exists(c => c.Name.Equals(indexerLocal.Name, StringComparison.InvariantCultureIgnoreCase)))
{
var settings = new IndexerDefinition
var definitions = _indexers.SelectMany(delegate(IIndexer indexer)
{
Enable = indexerLocal.EnabledByDefault,
Name = indexerLocal.Name.ToLower()
};
return indexer.DefaultDefinitions;
});
_indexerRepository.Insert(settings);
}
_indexerRepository.InsertMany(definitions.ToList());
}
}
}

@ -4,7 +4,7 @@ namespace NzbDrone.Core.Indexers
{
public interface IProviderIndexerSetting
{
TSetting Get<TSetting>(IIndexerBase indexer) where TSetting : IIndexerSetting, new();
TSetting Get<TSetting>(IIndexer indexer) where TSetting : IIndexerSetting, new();
}
public class IndexerSettingProvider : IProviderIndexerSetting
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers
_indexerRepository = indexerRepository;
}
public TSetting Get<TSetting>(IIndexerBase indexer) where TSetting : IIndexerSetting, new()
public TSetting Get<TSetting>(IIndexer indexer) where TSetting : IIndexerSetting, new()
{
var indexerDef = _indexerRepository.Find(indexer.Name);

@ -1,38 +1,16 @@
using System;
using NzbDrone.Common.Messaging;
using NzbDrone.Common;
namespace NzbDrone.Core.Indexers
{
public abstract class IndexerWithSetting<TSetting> :
Indexer,
IHandle<IndexerSettingUpdatedEvent> where TSetting : IIndexerSetting, new()
public abstract class IndexerWithSetting<TSetting> : IndexerBase where TSetting : class, IIndexerSetting, new()
{
protected IndexerWithSetting(IProviderIndexerSetting settingProvider)
{
Settings = settingProvider.Get<TSetting>(this);
}
public override bool IsConfigured
{
get { return Settings.IsValid; }
}
public override bool EnabledByDefault
{
get
{
return false;
}
}
public TSetting Settings { get; private set; }
public void Handle(IndexerSettingUpdatedEvent message)
public TSetting ImportSettingsFromJson(string json)
{
if (message.IndexerName.Equals(Name, StringComparison.InvariantCultureIgnoreCase))
{
Settings = (TSetting)message.IndexerSetting;
}
Settings = new JsonSerializer().Deserialize<TSetting>(json) ?? new TSetting();
return Settings;
}
}
}

@ -1,22 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common;
namespace NzbDrone.Core.Indexers.Newznab
{
public class Newznab : Indexer
public class Newznab : IndexerWithSetting<NewznabSettings>
{
private readonly INewznabService _newznabProvider;
private readonly IJsonSerializer _jsonSerializer;
public Newznab(INewznabService newznabProvider)
public Newznab()
{
_newznabProvider = newznabProvider;
_jsonSerializer = new JsonSerializer();
}
public override IEnumerable<IndexerDefinition> DefaultDefinitions
{
get
{
var list = new List<IndexerDefinition>();
list.Add(new IndexerDefinition
{
Enable = false,
Name = "Nzbs.org",
Implementation = GetType().Name,
Settings = GetSettings("http://nzbs.org")
});
list.Add(new IndexerDefinition
{
Enable = false,
Name = "Nzb.su",
Implementation = GetType().Name,
Settings = GetSettings("https://nzb.su")
});
list.Add(new IndexerDefinition
{
Enable = false,
Name = "Dognzb.cr",
Implementation = GetType().Name,
Settings = GetSettings("https://dognzb.cr")
});
return list;
}
}
private string GetSettings(string url)
{
return _jsonSerializer.Serialize(new NewznabSettings { Url = url });
}
public override IEnumerable<string> RecentFeed
{
get { return GetUrls(); }
get
{
var url = String.Format("{0}/api?t=tvsearch&cat=5030,5040,5070,5090s", Settings.Url);
if (String.IsNullOrWhiteSpace(Settings.ApiKey))
{
url += "&apikey=" + Settings.ApiKey;
}
yield return url;
}
}
public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
@ -41,35 +93,15 @@ namespace NzbDrone.Core.Indexers.Newznab
public override string Name
{
get { return "Newznab"; }
}
private IEnumerable<string> GetUrls()
{
var urls = new List<string>();
var newznabIndexers = _newznabProvider.Enabled();
foreach (var newznabDefinition in newznabIndexers)
get
{
var url = String.Format("{0}/api?t=tvsearch&cat=5030,5040,5070,5090s", newznabDefinition.Url);
if (String.IsNullOrWhiteSpace(newznabDefinition.ApiKey))
{
url += "&apikey=" + newznabDefinition.ApiKey;
}
urls.Add(url);
return InstanceDefinition.Name;
}
return urls;
}
private static string NewsnabifyTitle(string title)
{
return title.Replace("+", "%20");
}
}
}

@ -1,13 +0,0 @@
using System;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Indexers.Newznab
{
public class NewznabDefinition : ModelBase
{
public Boolean Enable { get; set; }
public String Name { get; set; }
public String Url { get; set; }
public String ApiKey { get; set; }
}
}

@ -1,7 +1,5 @@
using System;
using System.ServiceModel.Syndication;
using NzbDrone.Core.Model;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.Newznab
@ -25,7 +23,9 @@ namespace NzbDrone.Core.Indexers.Newznab
if (currentResult != null)
{
if (item.Links.Count > 1)
{
currentResult.Size = item.Links[1].Length;
}
currentResult.Indexer = GetName(item);
}

@ -1,23 +0,0 @@
using System.Collections.Generic;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Indexers.Newznab
{
public interface INewznabRepository : IBasicRepository<NewznabDefinition>
{
IEnumerable<NewznabDefinition> Enabled();
}
public class NewznabRepository : BasicRepository<NewznabDefinition>, INewznabRepository
{
public NewznabRepository(IDatabase database)
: base(database)
{
}
public IEnumerable<NewznabDefinition> Enabled()
{
return Query.Where(n => n.Enable);
}
}
}

@ -1,138 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using NLog;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Lifecycle;
namespace NzbDrone.Core.Indexers.Newznab
{
public interface INewznabService
{
List<NewznabDefinition> All();
List<NewznabDefinition> Enabled();
NewznabDefinition Insert(NewznabDefinition definition);
void Update(NewznabDefinition definition);
}
public class NewznabService : INewznabService, IHandle<ApplicationStartedEvent>
{
private readonly INewznabRepository _newznabRepository;
private readonly Logger _logger;
public NewznabService(INewznabRepository newznabRepository, Logger logger)
{
_newznabRepository = newznabRepository;
_logger = logger;
}
public List<NewznabDefinition> All()
{
return _newznabRepository.All().ToList();
}
public List<NewznabDefinition> Enabled()
{
return _newznabRepository.Enabled().ToList();
}
public NewznabDefinition Insert(NewznabDefinition definition)
{
definition.Url = definition.Url.ToLower();
_logger.Debug("Adding Newznab definition for {0}", definition.Name);
return _newznabRepository.Insert(definition);
}
public void Update(NewznabDefinition definition)
{
definition.Url = definition.Url.ToLower();
_logger.Debug("Updating Newznab definition for {0}", definition.Name);
_newznabRepository.Update(definition);
}
public void Delete(int id)
{
_newznabRepository.Delete(id);
}
public void CheckHostname(string url)
{
try
{
var uri = new Uri(url);
var hostname = uri.DnsSafeHost;
Dns.GetHostEntry(hostname);
}
catch (Exception ex)
{
_logger.Error("Invalid address {0}, please correct the site URL.", url);
_logger.TraceException(ex.Message, ex);
throw;
}
}
public void Handle(ApplicationStartedEvent message)
{
var newznabIndexers = new List<NewznabDefinition>
{
new NewznabDefinition { Enable = false, Name = "Nzbs.org", Url = "http://nzbs.org" },
new NewznabDefinition { Enable = false, Name = "Nzb.su", Url = "https://nzb.su" },
new NewznabDefinition { Enable = false, Name = "Dognzb.cr", Url = "https://dognzb.cr" }
};
_logger.Debug("Initializing Newznab indexers. Count {0}", newznabIndexers);
try
{
var currentIndexers = All();
_logger.Debug("Deleting broken Newznab indexer");
var brokenIndexers = currentIndexers.Where(i => String.IsNullOrEmpty(i.Name) || String.IsNullOrWhiteSpace(i.Url)).ToList();
brokenIndexers.ForEach(e => Delete(e.Id));
currentIndexers = All();
foreach (var feedProvider in newznabIndexers)
{
try
{
NewznabDefinition indexerLocal = feedProvider;
var currentIndexer = currentIndexers
.FirstOrDefault(c => new Uri(c.Url.ToLower()).Host == new Uri(indexerLocal.Url.ToLower()).Host);
if (currentIndexer == null)
{
var definition = new NewznabDefinition
{
Enable = false,
Name = indexerLocal.Name,
Url = indexerLocal.Url,
ApiKey = indexerLocal.ApiKey,
};
Insert(definition);
}
else
{
currentIndexer.Url = indexerLocal.Url;
Update(currentIndexer);
}
}
catch (Exception ex)
{
_logger.ErrorException("An error occurred while setting up indexer: " + feedProvider.Name, ex);
}
}
}
catch (Exception ex)
{
_logger.ErrorException("An Error occurred while initializing Newznab Indexers", ex);
}
}
}
}

@ -0,0 +1,18 @@
using System;
namespace NzbDrone.Core.Indexers.Newznab
{
public class NewznabSettings : IIndexerSetting
{
public String Url { get; set; }
public String ApiKey { get; set; }
public bool IsValid
{
get
{
return !string.IsNullOrWhiteSpace(Url);
}
}
}
}

@ -3,8 +3,13 @@ using System.Collections.Generic;
namespace NzbDrone.Core.Indexers.NzbClub
{
public class NzbClub : Indexer
public class NzbClub : IndexerBase
{
public override string Name
{
get { return "NzbClub"; }
}
public override IEnumerable<string> RecentFeed
{
get
@ -17,13 +22,6 @@ namespace NzbDrone.Core.Indexers.NzbClub
}
}
public override string Name
{
get { return "NzbClub"; }
}
public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
var searchUrls = new List<string>();

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace NzbDrone.Core.Indexers.NzbIndex
{
public class NzbIndex : Indexer
public class NzbIndex : IndexerBase
{
public override IEnumerable<string> RecentFeed
{
@ -73,11 +73,5 @@ namespace NzbDrone.Core.Indexers.NzbIndex
return searchUrls;
}
}
}

@ -5,20 +5,13 @@ namespace NzbDrone.Core.Indexers.NzbsRUs
{
public class Nzbsrus : IndexerWithSetting<NzbsrusSetting>
{
private readonly NzbsrusSetting _setting;
public Nzbsrus(IProviderIndexerSetting settingProvider):base(settingProvider)
{
}
public override IEnumerable<string> RecentFeed
{
get
{
yield return string.Format("https://www.nzbsrus.com/rssfeed.php?cat=91,75&i={0}&h={1}",
_setting.Uid,
_setting.Hash);
Settings.Uid,
Settings.Hash);
}
}

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace NzbDrone.Core.Indexers.Nzbx
{
public class Nzbx : Indexer
public class Nzbx : IndexerBase
{
public override IParseFeed Parser
{

@ -5,11 +5,6 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
{
public class Omgwtfnzbs : IndexerWithSetting<OmgwtfnzbsSetting>
{
public Omgwtfnzbs(IProviderIndexerSetting settingProvider)
: base(settingProvider)
{
}
public override string Name
{
get { return "omgwtfnzbs"; }
@ -20,8 +15,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
get
{
yield return
String.Format("http://rss.omgwtfnzbs.org/rss-search.php?catid=19,20&user={0}&api={1}&eng=1",
yield return String.Format("http://rss.omgwtfnzbs.org/rss-search.php?catid=19,20&user={0}&api={1}&eng=1",
Settings.Username, Settings.ApiKey);
}
}

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace NzbDrone.Core.Indexers.Wombles
{
public class Wombles : Indexer
public class Wombles : IndexerBase
{
public override IEnumerable<string> RecentFeed
{
@ -34,11 +34,5 @@ namespace NzbDrone.Core.Indexers.Wombles
{
return new List<string>();
}
public bool EnabledByDefault
{
get { return true; }
}
}
}

@ -237,7 +237,7 @@
<Compile Include="Download\DownloadClientType.cs" />
<Compile Include="Download\SabQueueItem.cs" />
<Compile Include="Indexers\FetchAndParseRssService.cs" />
<Compile Include="Indexers\IIndexerBase.cs" />
<Compile Include="Indexers\IIndexer.cs" />
<Compile Include="Indexers\IndexerSettingUpdatedEvent.cs" />
<Compile Include="Indexers\IndexerWithSetting.cs" />
<Compile Include="Indexers\RssSyncCommand.cs" />
@ -258,15 +258,13 @@
<Compile Include="IndexerSearch\SearchAndDownloadService.cs" />
<Compile Include="Indexers\BasicRssParser.cs" />
<Compile Include="Indexers\RssSyncService.cs" />
<Compile Include="Indexers\Indexer.cs" />
<Compile Include="Indexers\IndexerBase.cs" />
<Compile Include="Indexers\IndexerDefinition.cs" />
<Compile Include="Indexers\IndexerRepository.cs" />
<Compile Include="Indexers\IndexerSettingProvider.cs" />
<Compile Include="Indexers\Newznab\Newznab.cs" />
<Compile Include="Indexers\Newznab\NewznabDefinition.cs" />
<Compile Include="Indexers\Newznab\NewznabSettings.cs" />
<Compile Include="Indexers\Newznab\NewznabParser.cs" />
<Compile Include="Indexers\Newznab\NewznabRepository.cs" />
<Compile Include="Indexers\Newznab\NewznabService.cs" />
<Compile Include="Indexers\NzbClub\NzbClub.cs" />
<Compile Include="Indexers\NzbClub\NzbClubParser.cs" />
<Compile Include="Indexers\NzbIndex\NzbIndex.cs" />

Loading…
Cancel
Save