1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

moved config to objectdb.

This commit is contained in:
kay.one 2013-02-23 22:48:52 -08:00
parent 65061cdc96
commit 13658e3c6d
88 changed files with 627 additions and 586 deletions

View File

@ -11,6 +11,7 @@
using NzbDrone.Api.Extensions;
using NzbDrone.Common;
using NzbDrone.Core;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Providers.Core;
using SignalR;
@ -68,7 +69,7 @@ private void KickoffInitilizables(ILifetimeScope container)
private void RegisterReporting(ILifetimeScope container)
{
EnvironmentProvider.UGuid = container.Resolve<ConfigProvider>().UGuid;
EnvironmentProvider.UGuid = container.Resolve<ConfigService>().UGuid;
ReportingService.RestProvider = container.Resolve<RestProvider>();
ReportingService.SetupExceptronDriver();
}

View File

@ -7,6 +7,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -42,28 +43,28 @@ public void Setup()
[Test]
public void should_be_true_when_allowedReleaseGroups_is_empty()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty);
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_true_when_allowedReleaseGroups_is_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD");
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL");
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_false_when_allowedReleaseGroups_does_not_contain_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD");
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeFalse();
}
}

View File

@ -7,6 +7,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -37,22 +38,22 @@ public void Setup()
private void WithUnlimitedRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(0);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(0);
}
private void WithLongRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(1000);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(1000);
}
private void WithShortRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(10);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(10);
}
private void WithEqualRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(100);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(100);
}
[Test]

View File

@ -2,6 +2,7 @@
using System.IO;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
@ -95,7 +96,7 @@ protected void WithRealDb()
[TearDown]
public void CoreTestTearDown()
{
ConfigProvider.ClearCache();
ConfigService.ClearCache();
if (EnvironmentProvider.IsMono)
{

View File

@ -10,6 +10,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -29,17 +30,17 @@ public class IndexerFixture : CoreTest
{
private void WithConfiguredIndexers()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.OmgwtfnzbsUsername).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.OmgwtfnzbsApiKey).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.OmgwtfnzbsUsername).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.OmgwtfnzbsApiKey).Returns("MockedConfigValue");
}
[TestCase("nzbsrus.xml")]

View File

@ -8,6 +8,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -75,8 +76,8 @@ public void Init_indexer_should_not_enable_indexer_that_is_not_enabled_by_defaul
public class MockIndexer : IndexerBase
{
public MockIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public MockIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@ -133,8 +134,8 @@ protected override string NzbInfoUrl(SyndicationItem item)
public class TestUrlIndexer : IndexerBase
{
public TestUrlIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public TestUrlIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@ -186,8 +187,8 @@ protected override string NzbInfoUrl(SyndicationItem item)
public class CustomParserIndexer : IndexerBase
{
public CustomParserIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public CustomParserIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@ -246,8 +247,8 @@ protected override EpisodeParseResult CustomParser(SyndicationItem item, Episode
public class NotConfiguredIndexer : IndexerBase
{
public NotConfiguredIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public NotConfiguredIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@ -299,8 +300,8 @@ protected override string NzbInfoUrl(SyndicationItem item)
public class DefaultEnabledIndexer : IndexerBase
{
public DefaultEnabledIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public DefaultEnabledIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}

View File

@ -4,6 +4,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
@ -21,7 +22,7 @@ public class BacklogSearchJobTest : CoreTest<BacklogSearchJob>
{
private void WithEnableBacklogSearching()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
}
[Test]

View File

@ -7,6 +7,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -44,7 +45,7 @@ public void should_not_get_sabDropDir_when_path_is_supplied()
Mocker.GetMock<PostDownloadProvider>().Setup(s => s.ProcessDropFolder(path));
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, new { Path = path });
Mocker.GetMock<ConfigProvider>().Verify(s => s.DownloadClientTvDirectory, Times.Never());
Mocker.GetMock<ConfigService>().Verify(s => s.DownloadClientTvDirectory, Times.Never());
}
[Test]
@ -52,10 +53,10 @@ public void should_get_sabDropDir_when_path_is_not_supplied()
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.GetMock<ConfigService>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
Mocker.GetMock<ConfigProvider>().Verify(s => s.DownloadClientTvDirectory, Times.Once());
Mocker.GetMock<ConfigService>().Verify(s => s.DownloadClientTvDirectory, Times.Once());
}
[Test]
@ -63,7 +64,7 @@ public void should_use_sabDropDir_when_options_Path_is_not_provided()
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.GetMock<ConfigService>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
Mocker.GetMock<PostDownloadProvider>().Verify(s => s.ProcessDropFolder(path), Times.Once());

View File

@ -6,6 +6,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
@ -24,7 +25,7 @@ public class RecentBacklogSearchJobTest : CoreTest
{
private void WithEnableBacklogSearching()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
}
[SetUp]

View File

@ -3,6 +3,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
@ -18,7 +19,7 @@ public class RssSyncJobTest : CoreTest
{
public void WithMinutes(int minutes)
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RssSyncInterval).Returns(minutes);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RssSyncInterval).Returns(minutes);
}
[TestCase(10)]

View File

@ -172,7 +172,7 @@
<Compile Include="JobTests\PostDownloadScanJobFixture.cs" />
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
<Compile Include="ParserTests\QualityParserFixture.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigCachingFixture.cs" />
<Compile Include="Configuration\ConfigCachingFixture.cs" />
<Compile Include="ProviderTests\BannerProviderTest.cs" />
<Compile Include="DecisionEngineTests\AllowedReleaseGroupSpecificationFixture.cs" />
<Compile Include="DecisionEngineTests\CustomStartDateSpecificationFixture.cs" />
@ -250,7 +250,7 @@
<Compile Include="Indexers\IndexerServiceTest.cs" />
<Compile Include="HistoryTests\HistoryServiceTest.cs" />
<Compile Include="ProviderTests\MediaFileProviderTest.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigProviderFixture.cs" />
<Compile Include="Configuration\ConfigServiceFixture.cs" />
<Compile Include="TvTests\EpisodeProviderTests\EpisodeProviderTest.cs" />
<Compile Include="Framework\TestDbHelper.cs" />
<Compile Include="ParserTests\ParserFixture.cs" />

View File

@ -1,35 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
namespace NzbDrone.Core.Test.ProviderTests.ConfigProviderTests
{
[TestFixture]
public class ConfigCachingFixture : CoreTest
{
[SetUp]
public void Setup()
{
Mocker.GetMock<IDatabase>().Setup(c => c.Fetch<Config>())
.Returns(new List<Config> { new Config { Key = "Key1", Value = "Value1" } });
}
[Test]
public void getting_value_more_than_once_should_hit_db_once()
{
Mocker.Resolve<ConfigProvider>().GetValue("Key1", null).Should().Be("Value1");
Mocker.Resolve<ConfigProvider>().GetValue("Key1", null).Should().Be("Value1");
Mocker.Resolve<ConfigProvider>().GetValue("Key1", null).Should().Be("Value1");
Mocker.GetMock<IDatabase>().Verify(c => c.Fetch<Config>(), Times.Once());
}
}
}

View File

@ -1,192 +0,0 @@
using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.ConfigProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class ConfigProviderFixture : SqlCeTest
{
[SetUp]
public void SetUp()
{
WithRealDb();
}
[Test]
public void Add_new_value_to_database()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
Mocker.Resolve<ConfigProvider>().GetValue(key, "").Should().Be(value);
}
[Test]
public void Get_value_from_database()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
Db.Insert(new Config { Key = key, Value = value });
Db.Insert(new Config { Key = "Other Key", Value = "OtherValue" });
//Act
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(value);
}
[Test]
public void Get_value_should_return_default_when_no_value()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
//Act
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, value);
//Assert
result.Should().Be(value);
}
[Test]
public void New_value_should_update_old_value_new_value()
{
const string key = "MY_KEY";
const string originalValue = "OLD_VALUE";
const string newValue = "NEW_VALUE";
Db.Insert(new Config { Key = key, Value = originalValue });
//Act
Mocker.Resolve<ConfigProvider>().SetValue(key, newValue);
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(newValue);
Db.Fetch<Config>().Should().HaveCount(1);
}
[Test]
public void New_value_should_update_old_value_same_value()
{
const string key = "MY_KEY";
const string value = "OLD_VALUE";
//Act
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(value);
Db.Fetch<Config>().Should().HaveCount(1);
}
[Test]
public void get_value_with_persist_should_store_default_value()
{
const string key = "MY_KEY";
string value = Guid.NewGuid().ToString();
//Act
Mocker.Resolve<ConfigProvider>().GetValue(key, value, persist: true).Should().Be(value);
Mocker.Resolve<ConfigProvider>().GetValue(key, string.Empty).Should().Be(value);
}
[Test]
public void get_value_with_out_persist_should_not_store_default_value()
{
const string key = "MY_KEY";
string value1 = Guid.NewGuid().ToString();
string value2 = Guid.NewGuid().ToString();
//Act
Mocker.Resolve<ConfigProvider>().GetValue(key, value1).Should().Be(value1);
Mocker.Resolve<ConfigProvider>().GetValue(key, value2).Should().Be(value2);
}
[Test]
public void uguid_should_only_be_set_once()
{
var guid1 = Mocker.Resolve<ConfigProvider>().UGuid;
var guid2 = Mocker.Resolve<ConfigProvider>().UGuid;
guid1.Should().Be(guid2);
}
[Test]
public void uguid_should_return_valid_result_on_first_call()
{
var guid = Mocker.Resolve<ConfigProvider>().UGuid;
guid.Should().NotBeEmpty();
}
[Test]
public void updating_a_vakye_should_update_its_value()
{
Mocker.Resolve<ConfigProvider>().SabHost = "Test";
Mocker.Resolve<ConfigProvider>().SabHost.Should().Be("Test");
Mocker.Resolve<ConfigProvider>().SabHost = "Test2";
Mocker.Resolve<ConfigProvider>().SabHost.Should().Be("Test2");
}
[Test]
[Description("This test will use reflection to ensure each config property read/writes to a unique key")]
public void config_properties_should_write_and_read_using_same_key()
{
var configProvider = Mocker.Resolve<ConfigProvider>();
var allProperties = typeof(ConfigProvider).GetProperties().Where(p => p.GetSetMethod() != null);
//Act
foreach (var propertyInfo in allProperties)
{
object value = null;
if (propertyInfo.PropertyType == typeof(string))
{
value = new Guid().ToString();
}
else if (propertyInfo.PropertyType == typeof(int))
{
value = DateTime.Now.Millisecond;
}
else if (propertyInfo.PropertyType == typeof(bool))
{
value = true;
}
else if (propertyInfo.PropertyType.BaseType == typeof(Enum))
{
value = 0;
}
propertyInfo.GetSetMethod().Invoke(configProvider, new[] { value });
var returnValue = propertyInfo.GetGetMethod().Invoke(configProvider, null);
if (propertyInfo.PropertyType.BaseType == typeof(Enum))
{
returnValue = (int)returnValue;
}
returnValue.Should().Be(value, propertyInfo.Name);
}
Db.Fetch<Config>().Should()
.HaveSameCount(allProperties, "two different properties are writing to the same key in db. Copy/Past fail.");
}
}
}

View File

@ -8,6 +8,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -90,7 +91,7 @@ public void should_delete_none_existing_files_remove_links_to_episodes()
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.Delete(It.IsAny<int>()));
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.AutoIgnorePreviouslyDownloadedEpisodes)
.Returns(true);

View File

@ -8,6 +8,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Test.Framework;
@ -26,7 +27,7 @@ public class BlackholeProviderFixture : CoreTest
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.BlackholeDirectory).Returns(blackHoleFolder);
Mocker.GetMock<ConfigService>().SetupGet(c => c.BlackholeDirectory).Returns(blackHoleFolder);
}

View File

@ -7,6 +7,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
@ -19,7 +20,7 @@ public class DownloadNzbFixture : TestBase
[SetUp]
public void Setup()
{
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.NzbgetHost).Returns("192.168.5.55");
fakeConfig.SetupGet(c => c.NzbgetPort).Returns(6789);
fakeConfig.SetupGet(c => c.NzbgetUsername).Returns("nzbget");

View File

@ -7,6 +7,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
@ -19,7 +20,7 @@ public class QueueFixture : TestBase
[SetUp]
public void Setup()
{
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.NzbgetHost).Returns("192.168.5.55");
fakeConfig.SetupGet(c => c.NzbgetPort).Returns(6789);
fakeConfig.SetupGet(c => c.NzbgetUsername).Returns("nzbget");

View File

@ -8,6 +8,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Test.Framework;
@ -29,8 +30,8 @@ public void Setup()
{
nzbPath = pneumaticFolder + title + ".nzb";
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.PneumaticDirectory).Returns(pneumaticFolder);
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.DownloadClientTvDirectory).Returns(sabDrop);
Mocker.GetMock<ConfigService>().SetupGet(c => c.PneumaticDirectory).Returns(pneumaticFolder);
Mocker.GetMock<ConfigService>().SetupGet(c => c.DownloadClientTvDirectory).Returns(sabDrop);
}
private void WithExistingFile()

View File

@ -8,6 +8,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Sabnzbd;
@ -35,7 +36,7 @@ public void Setup()
string password = "pass";
string cat = "tv";
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.SabHost).Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort).Returns(sabPort);
fakeConfig.SetupGet(c => c.SabApiKey).Returns(apikey);

View File

@ -10,6 +10,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Sabnzbd;
using NzbDrone.Core.Providers.Core;
@ -31,7 +32,7 @@ public class SabProviderFixture : CoreTest
[SetUp]
public void Setup()
{
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.SabHost).Returns("192.168.5.55");
fakeConfig.SetupGet(c => c.SabPort).Returns(2222);
@ -209,11 +210,11 @@ public void should_return_false_when_WebException_is_thrown()
[Test]
public void downloadNzb_should_use_sabRecentTvPriority_when_recentEpisode_is_true()
{
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabRecentTvPriority)
.Returns(SabPriorityType.High);
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabBacklogTvPriority)
.Returns(SabPriorityType.Low);
@ -231,11 +232,11 @@ public void downloadNzb_should_use_sabRecentTvPriority_when_recentEpisode_is_tru
[Test]
public void downloadNzb_should_use_sabBackogTvPriority_when_recentEpisode_is_false()
{
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabRecentTvPriority)
.Returns(SabPriorityType.High);
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabBacklogTvPriority)
.Returns(SabPriorityType.Low);

View File

@ -5,6 +5,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.History;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
@ -33,7 +34,7 @@ public class DownloadProviderFixture : CoreTest
private void SetDownloadClient(DownloadClientType clientType)
{
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.Setup(c => c.DownloadClient)
.Returns(clientType);
}

View File

@ -8,6 +8,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -133,7 +134,7 @@ public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int sea
.Build();
Mocker.GetMock<ConfigProvider>().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat);
Mocker.GetMock<ConfigService>().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat);
//Act
var result = Mocker.Resolve<MediaFileProvider>().CalculateFilePath(fakeSeries, 1, filename, ".mkv");

View File

@ -8,6 +8,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
@ -93,7 +94,7 @@ public void Setup()
private void WithUseBanners()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.MetadataUseBanners).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.MetadataUseBanners).Returns(true);
}
private void WithSingleEpisodeFile()

View File

@ -7,6 +7,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
@ -75,7 +76,7 @@ public void Setup()
private void WithUseBanners()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.MetadataUseBanners).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.MetadataUseBanners).Returns(true);
}
private void WithSpecials()

View File

@ -10,6 +10,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model.Xbmc;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -26,22 +27,22 @@ public class PlexProviderTest : CoreTest
{
private void WithSingleClient()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexClientHosts)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexClientHosts)
.Returns("localhost:3000");
}
private void WithMultipleClients()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexClientHosts)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexClientHosts)
.Returns("localhost:3000, 192.168.0.10:3000");
}
public void WithClientCredentials()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexUsername)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexUsername)
.Returns("plex");
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexPassword)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexPassword)
.Returns("plex");
}

View File

@ -10,6 +10,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -49,7 +50,7 @@ private void WithNonExpired()
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
.Returns(new [] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
@ -61,7 +62,7 @@ public void Setup()
[Test]
public void should_return_if_recycleBin_not_configured()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.Resolve<RecycleBinProvider>().Cleanup();

View File

@ -10,6 +10,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -28,12 +29,12 @@ public class DeleteDirectoryFixture : CoreTest
{
private void WithRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
}
private void WithoutRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
}
[Test]

View File

@ -10,6 +10,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -28,12 +29,12 @@ public class DeleteFileFixture : CoreTest
{
private void WithRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
}
private void WithoutRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
}
[Test]

View File

@ -10,6 +10,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -31,7 +32,7 @@ public class EmptyFixture : CoreTest
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
.Returns(new [] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
@ -43,7 +44,7 @@ public void Setup()
[Test]
public void should_return_if_recycleBin_not_configured()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.Resolve<RecycleBinProvider>().Empty();

View File

@ -6,10 +6,10 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@ -27,7 +27,7 @@ public class ReferenceDataProviderTest : SqlCeTest
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
Mocker.GetMock<ConfigService>().SetupGet(s => s.ServiceRootUrl)
.Returns("http://services.nzbdrone.com");
}

View File

@ -6,6 +6,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -23,7 +24,7 @@ public class SceneMappingProviderTest : SqlCeTest
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
Mocker.GetMock<ConfigService>().SetupGet(s => s.ServiceRootUrl)
.Returns("http://services.nzbdrone.com");
WithRealDb();

View File

@ -4,6 +4,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Test.Framework;
@ -22,7 +23,7 @@ public void Setup()
{
WithStrictMocker();
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
Mocker.GetMock<ConfigService>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
Mocker.Resolve<HttpProvider>();
}

View File

@ -7,6 +7,7 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Xbmc;
using NzbDrone.Core.Providers;
@ -296,7 +297,7 @@ public void Notify_true()
var header = "NzbDrone Test";
var message = "Test Message!";
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080");
//var fakeUdpProvider = Mocker.GetMock<EventClient>();
@ -440,7 +441,7 @@ public void Clean()
//Setup
WithStrictMocker();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080");
var fakeEventClient = Mocker.GetMock<EventClientProvider>();

View File

@ -7,6 +7,7 @@
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@ -814,7 +815,7 @@ public void Add_daily_show_episodes()
WithRealDb();
Mocker.Resolve<TvDbProvider>();
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.Setup(e => e.DefaultQualityProfile).Returns(1);
Db.Insert(Builder<QualityProfile>.CreateNew().Build());

View File

@ -0,0 +1,12 @@
using System.Linq;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Configuration
{
public class Config : ModelBase
{
public string Key { get; set; }
public string Value { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System.Linq;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Configuration
{
public interface IConfigRepository : IBasicRepository<Config>
{
Config Get(string key);
}
public class ConfigRepository : BasicRepository<Config>, IConfigRepository
{
public ConfigRepository(IObjectDatabase objectDatabase)
: base(objectDatabase)
{
}
public Config Get(string key)
{
return Queryable.SingleOrDefault(c => c.Key == key);
}
}
}

View File

@ -5,31 +5,28 @@
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Model.Sabnzbd;
using NzbDrone.Core.Repository;
using PetaPoco;
using NzbDrone.Core.Providers;
namespace NzbDrone.Core.Providers.Core
namespace NzbDrone.Core.Configuration
{
public class ConfigProvider
public class ConfigService : IConfigService
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly IConfigRepository _repository;
private readonly Logger _logger;
private static Dictionary<string, string> _cache;
private static Dictionary<string, string> cache = new Dictionary<string, string>();
private readonly IDatabase _database;
public ConfigProvider(IDatabase database)
public ConfigService(IConfigRepository repository, Logger logger)
{
_database = database;
_repository = repository;
_logger = logger;
_cache = new Dictionary<string, string>();
}
public ConfigProvider()
{
}
public IEnumerable<Config> All()
{
return _database.Fetch<Config>();
return _repository.All();
}
public virtual String NzbsOrgUId
@ -619,14 +616,15 @@ public virtual string GetValue(string key, object defaultValue, bool persist = f
string dbValue;
if (cache.TryGetValue(key, out dbValue) && dbValue != null && !String.IsNullOrEmpty(dbValue))
if (_cache.TryGetValue(key, out dbValue) && dbValue != null && !String.IsNullOrEmpty(dbValue))
return dbValue;
logger.Trace("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue);
_logger.Trace("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue);
if (persist)
{
SetValue(key, defaultValue.ToString());
}
return defaultValue.ToString();
}
@ -647,18 +645,18 @@ public void SetValue(string key, string value)
if (value == null)
throw new ArgumentNullException("key");
logger.Trace("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value);
_logger.Trace("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value);
var dbValue = _database.SingleOrDefault<Config>("WHERE [KEY]=@0", key);
var dbValue = _repository.Get(key);
if (dbValue == null)
{
_database.Insert(new Config { Key = key, Value = value });
_repository.Insert(new Config { Key = key, Value = value });
}
else
{
dbValue.Value = value;
_database.Update(dbValue);
_repository.Update(dbValue);
}
ClearCache();
@ -666,20 +664,20 @@ public void SetValue(string key, string value)
private void EnsureCache()
{
lock (cache)
lock (_cache)
{
if (!cache.Any())
if (!_cache.Any())
{
cache = _database.Fetch<Config>().ToDictionary(c => c.Key, c => c.Value);
_cache = All().ToDictionary(c => c.Key, c => c.Value);
}
}
}
public static void ClearCache()
{
lock (cache)
lock (_cache)
{
cache = new Dictionary<string, string>();
_cache = new Dictionary<string, string>();
}
}
}

View File

@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Model.Sabnzbd;
namespace NzbDrone.Core.Configuration
{
public interface IConfigService
{
IEnumerable<Config> All();
String NzbsOrgUId { get; set; }
String NzbsOrgHash { get; set; }
String NzbsrusUId { get; set; }
String NzbsrusHash { get; set; }
String FileSharingTalkUid { get; set; }
String FileSharingTalkSecret { get; set; }
String SabHost { get; set; }
int SabPort { get; set; }
String SabApiKey { get; set; }
String SabUsername { get; set; }
String SabPassword { get; set; }
String SabTvCategory { get; set; }
SabPriorityType SabBacklogTvPriority { get; set; }
SabPriorityType SabRecentTvPriority { get; set; }
String DownloadClientTvDirectory { get; set; }
bool SortingIncludeSeriesName { get; set; }
bool SortingIncludeEpisodeTitle { get; set; }
bool SortingReplaceSpaces { get; set; }
bool SortingAppendQuality { get; set; }
bool UseSeasonFolder { get; set; }
string SortingSeasonFolderFormat { get; set; }
int SortingSeparatorStyle { get; set; }
int SortingNumberStyle { get; set; }
int SortingMultiEpisodeStyle { get; set; }
bool SortingUseSceneName { get; set; }
int DefaultQualityProfile { get; set; }
Boolean XbmcNotifyOnGrab { get; set; }
Boolean XbmcNotifyOnDownload { get; set; }
Boolean XbmcUpdateLibrary { get; set; }
Boolean XbmcCleanLibrary { get; set; }
Boolean XbmcUpdateWhenPlaying { get; set; }
string XbmcHosts { get; set; }
string XbmcUsername { get; set; }
string XbmcPassword { get; set; }
string UpdateUrl { get; set; }
Boolean SmtpNotifyOnGrab { get; set; }
Boolean SmtpNotifyOnDownload { get; set; }
string SmtpServer { get; set; }
int SmtpPort { get; set; }
Boolean SmtpUseSsl { get; set; }
string SmtpUsername { get; set; }
string SmtpPassword { get; set; }
string SmtpFromAddress { get; set; }
string SmtpToAddresses { get; set; }
Boolean TwitterNotifyOnGrab { get; set; }
Boolean TwitterNotifyOnDownload { get; set; }
string TwitterAccessToken { get; set; }
string TwitterAccessTokenSecret { get; set; }
Boolean GrowlNotifyOnGrab { get; set; }
Boolean GrowlNotifyOnDownload { get; set; }
string GrowlHost { get; set; }
string GrowlPassword { get; set; }
Boolean ProwlNotifyOnGrab { get; set; }
Boolean ProwlNotifyOnDownload { get; set; }
string ProwlApiKeys { get; set; }
int ProwlPriority { get; set; }
bool EnableBacklogSearching { get; set; }
bool AutoIgnorePreviouslyDownloadedEpisodes { get; set; }
int Retention { get; set; }
Guid UGuid { get; }
DownloadClientType DownloadClient { get; set; }
string BlackholeDirectory { get; set; }
string ServiceRootUrl { get; }
Boolean PlexNotifyOnGrab { get; set; }
Boolean PlexNotifyOnDownload { get; set; }
Boolean PlexUpdateLibrary { get; set; }
string PlexServerHost { get; set; }
string PlexClientHosts { get; set; }
string PlexUsername { get; set; }
string PlexPassword { get; set; }
Boolean MetadataUseBanners { get; set; }
string AllowedReleaseGroups { get; set; }
string PneumaticDirectory { get; set; }
string RecycleBin { get; set; }
int RssSyncInterval { get; set; }
string OmgwtfnzbsUsername { get; set; }
string OmgwtfnzbsApiKey { get; set; }
Boolean IgnoreArticlesWhenSortingSeries { get; set; }
Boolean DownloadClientUseSceneName { get; set; }
String NzbgetUsername { get; set; }
String NzbgetPassword { get; set; }
String NzbgetHost { get; set; }
Int32 NzbgetPort { get; set; }
String NzbgetTvCategory { get; set; }
Int32 NzbgetPriority { get; set; }
PriorityType NzbgetBacklogTvPriority { get; set; }
PriorityType NzbgetRecentTvPriority { get; set; }
string GetValue(string key, object defaultValue, bool persist = false);
void SetValue(string key, string value);
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -8,12 +9,12 @@ namespace NzbDrone.Core.DecisionEngine
{
public class AllowedReleaseGroupSpecification
{
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public AllowedReleaseGroupSpecification(ConfigProvider configProvider)
public AllowedReleaseGroupSpecification(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
}
public AllowedReleaseGroupSpecification()
@ -25,7 +26,7 @@ public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Beginning release group check for: {0}", subject);
var allowed = _configProvider.AllowedReleaseGroups;
var allowed = _configService.AllowedReleaseGroups;
if (string.IsNullOrWhiteSpace(allowed))
return true;

View File

@ -1,5 +1,6 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -7,12 +8,12 @@ namespace NzbDrone.Core.DecisionEngine
{
public class LanguageSpecification
{
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public LanguageSpecification(ConfigProvider configProvider)
public LanguageSpecification(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
}
public LanguageSpecification()

View File

@ -1,5 +1,6 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -7,12 +8,12 @@ namespace NzbDrone.Core.DecisionEngine
{
public class RetentionSpecification
{
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public RetentionSpecification(ConfigProvider configProvider)
public RetentionSpecification(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
}
public RetentionSpecification()
@ -23,7 +24,7 @@ public RetentionSpecification()
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
{
logger.Trace("Checking if report meets retention requirements. {0}", subject.Age);
if (_configProvider.Retention > 0 && subject.Age > _configProvider.Retention)
if (_configService.Retention > 0 && subject.Age > _configService.Retention)
{
logger.Trace("Report age: {0} rejected by user's retention limit", subject.Age);
return false;

View File

@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -10,8 +11,8 @@ namespace NzbDrone.Core.Indexers
{
public class FileSharingTalk : IndexerBase
{
public FileSharingTalk(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public FileSharingTalk(HttpProvider httpProvider, IConfigService configService)
: base(httpProvider, configService)
{
}
@ -22,7 +23,7 @@ protected override string[] Urls
return new[]
{
string.Format("http://filesharingtalk.com/ng_rss.php?uid={0}&ps={1}&category=tv&subcategory=x264sd,x264720,xvid,webdl720,x2641080",
_configProvider.FileSharingTalkUid, _configProvider.FileSharingTalkSecret)
_configService.FileSharingTalkUid, _configService.FileSharingTalkSecret)
};
}
}
@ -31,8 +32,8 @@ public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.FileSharingTalkUid) &&
!string.IsNullOrWhiteSpace(_configProvider.FileSharingTalkSecret);
return !string.IsNullOrWhiteSpace(_configService.FileSharingTalkUid) &&
!string.IsNullOrWhiteSpace(_configService.FileSharingTalkSecret);
}
}

View File

@ -6,6 +6,7 @@
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -15,15 +16,15 @@ public abstract class IndexerBase
{
protected readonly Logger _logger;
protected readonly HttpProvider _httpProvider;
protected readonly ConfigProvider _configProvider;
protected readonly IConfigService _configService;
protected static readonly Regex TitleSearchRegex = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
protected static readonly Regex RemoveThe = new Regex(@"^the\s", RegexOptions.IgnoreCase | RegexOptions.Compiled);
protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider)
protected IndexerBase(HttpProvider httpProvider, IConfigService configService)
{
_httpProvider = httpProvider;
_configProvider = configProvider;
_configService = configService;
_logger = LogManager.GetLogger(GetType().ToString());
}

View File

@ -4,6 +4,7 @@
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -14,8 +15,8 @@ public class Newznab : IndexerBase
{
private readonly INewznabService _newznabProvider;
public Newznab(HttpProvider httpProvider, ConfigProvider configProvider, INewznabService newznabProvider)
: base(httpProvider, configProvider)
public Newznab(HttpProvider httpProvider, IConfigService configService, INewznabService newznabProvider)
: base(httpProvider, configService)
{
_newznabProvider = newznabProvider;
}

View File

@ -4,6 +4,7 @@
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -11,8 +12,8 @@ namespace NzbDrone.Core.Indexers
{
public class NzbClub : IndexerBase
{
public NzbClub(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public NzbClub(HttpProvider httpProvider, IConfigService configService)
: base(httpProvider, configService)
{
}

View File

@ -4,6 +4,7 @@
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -11,8 +12,8 @@ namespace NzbDrone.Core.Indexers
{
public class NzbIndex : IndexerBase
{
public NzbIndex(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public NzbIndex(HttpProvider httpProvider, IConfigService configService)
: base(httpProvider, configService)
{
}

View File

@ -4,6 +4,7 @@
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -11,7 +12,7 @@ namespace NzbDrone.Core.Indexers
{
public class NzbsRUs : IndexerBase
{
public NzbsRUs(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
public NzbsRUs(HttpProvider httpProvider, IConfigService configService) : base(httpProvider, configService)
{
}
@ -23,8 +24,8 @@ protected override string[] Urls
{
string.Format(
"https://www.nzbsrus.com/rssfeed.php?cat=91,75&i={0}&h={1}",
_configProvider.NzbsrusUId,
_configProvider.NzbsrusHash)
_configService.NzbsrusUId,
_configService.NzbsrusHash)
};
}
}
@ -33,8 +34,8 @@ public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.NzbsrusUId) &&
!string.IsNullOrWhiteSpace(_configProvider.NzbsrusHash);
return !string.IsNullOrWhiteSpace(_configService.NzbsrusUId) &&
!string.IsNullOrWhiteSpace(_configService.NzbsrusHash);
}
}

View File

@ -5,6 +5,7 @@
using System.ServiceModel.Syndication;
using Newtonsoft.Json;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Nzbx;
using NzbDrone.Core.Providers.Core;
@ -13,8 +14,8 @@ namespace NzbDrone.Core.Indexers
{
class Nzbx : IndexerBase
{
public Nzbx(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public Nzbx(HttpProvider httpProvider, IConfigService configService)
: base(httpProvider, configService)
{
}

View File

@ -4,6 +4,7 @@
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -11,8 +12,8 @@ namespace NzbDrone.Core.Indexers
{
class Omgwtfnzbs : IndexerBase
{
public Omgwtfnzbs(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public Omgwtfnzbs(HttpProvider httpProvider, IConfigService configService)
: base(httpProvider, configService)
{
}
@ -28,7 +29,7 @@ protected override string[] Urls
return new string[]
{
String.Format("http://rss.omgwtfnzbs.org/rss-search.php?catid=19,20&user={0}&api={1}&eng=1",
_configProvider.OmgwtfnzbsUsername, _configProvider.OmgwtfnzbsApiKey)
_configService.OmgwtfnzbsUsername, _configService.OmgwtfnzbsApiKey)
};
}
}
@ -37,8 +38,8 @@ public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.OmgwtfnzbsUsername) &&
!string.IsNullOrWhiteSpace(_configProvider.OmgwtfnzbsApiKey);
return !string.IsNullOrWhiteSpace(_configService.OmgwtfnzbsUsername) &&
!string.IsNullOrWhiteSpace(_configService.OmgwtfnzbsApiKey);
}
}

View File

@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -10,7 +11,7 @@ namespace NzbDrone.Core.Indexers
{
public class Wombles : IndexerBase
{
public Wombles(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
public Wombles(HttpProvider httpProvider, IConfigService configService) : base(httpProvider, configService)
{
}

View File

@ -2,12 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Jobs
{
@ -16,17 +14,17 @@ public class BacklogSearchJob : IJob
private readonly IEpisodeService _episodeService;
private readonly EpisodeSearchJob _episodeSearchJob;
private readonly SeasonSearchJob _seasonSearchJob;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public BacklogSearchJob(IEpisodeService episodeService, EpisodeSearchJob episodeSearchJob,
SeasonSearchJob seasonSearchJob, ConfigProvider configProvider)
SeasonSearchJob seasonSearchJob, IConfigService configService)
{
_episodeService = episodeService;
_episodeSearchJob = episodeSearchJob;
_seasonSearchJob = seasonSearchJob;
_configProvider = configProvider;
_configService = configService;
}
public string Name
@ -89,7 +87,7 @@ public void Start(ProgressNotification notification, dynamic options)
public List<Episode> GetMissingForEnabledSeries()
{
if (!_configProvider.EnableBacklogSearching)
if (!_configService.EnableBacklogSearching)
{
Logger.Trace("Backlog searching is not enabled, only running for explicitly enabled series.");
return _episodeService.EpisodesWithoutFiles(true).Where(e =>

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification;
@ -15,16 +16,16 @@ public class DiskScanJob : IJob
{
private readonly ISeriesService _seriesService;
private readonly DiskScanProvider _diskScanProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly ISeriesRepository _seriesRepository;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public DiskScanJob(ISeriesService seriesService, DiskScanProvider diskScanProvider,
ConfigProvider configProvider, ISeriesRepository seriesRepository)
IConfigService configService, ISeriesRepository seriesRepository)
{
_seriesService = seriesService;
_diskScanProvider = diskScanProvider;
_configProvider = configProvider;
_configService = configService;
_seriesRepository = seriesRepository;
}
@ -47,7 +48,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
IList<Series> seriesToScan;
if (options == null || options.SeriesId == 0)
{
if (_configProvider.IgnoreArticlesWhenSortingSeries)
if (_configService.IgnoreArticlesWhenSortingSeries)
seriesToScan = _seriesRepository.All().OrderBy(o => o.Title.IgnoreArticles()).ToList();
else

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
@ -15,16 +16,16 @@ public class PastWeekBacklogSearchJob : IJob
{
private readonly IEpisodeService _episodeService;
private readonly EpisodeSearchJob _episodeSearchJob;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public PastWeekBacklogSearchJob(IEpisodeService episodeService, EpisodeSearchJob episodeSearchJob,
ConfigProvider configProvider)
IConfigService configService)
{
_episodeService = episodeService;
_episodeSearchJob = episodeSearchJob;
_configProvider = configProvider;
_configService = configService;
}
public string Name

View File

@ -2,6 +2,7 @@
using System;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -13,13 +14,13 @@ public class PostDownloadScanJob : IJob
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly PostDownloadProvider _postDownloadProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly DiskProvider _diskProvider;
public PostDownloadScanJob(PostDownloadProvider postDownloadProvider,ConfigProvider configProvider, DiskProvider diskProvider)
public PostDownloadScanJob(PostDownloadProvider postDownloadProvider,IConfigService configService, DiskProvider diskProvider)
{
_postDownloadProvider = postDownloadProvider;
_configProvider = configProvider;
_configService = configService;
_diskProvider = diskProvider;
}
@ -45,7 +46,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
dropFolder = options.Path;
else
dropFolder = _configProvider.DownloadClientTvDirectory;
dropFolder = _configService.DownloadClientTvDirectory;
if (String.IsNullOrWhiteSpace(dropFolder))
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
@ -15,16 +16,16 @@ public class RecentBacklogSearchJob : IJob
{
private readonly IEpisodeService _episodeService;
private readonly EpisodeSearchJob _episodeSearchJob;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public RecentBacklogSearchJob(IEpisodeService episodeService, EpisodeSearchJob episodeSearchJob,
ConfigProvider configProvider)
IConfigService configService)
{
_episodeService = episodeService;
_episodeSearchJob = episodeSearchJob;
_configProvider = configProvider;
_configService = configService;
}
public string Name
@ -50,7 +51,7 @@ public void Start(ProgressNotification notification, dynamic options)
public List<Episode> GetMissingForEnabledSeries()
{
if (!_configProvider.EnableBacklogSearching)
if (!_configService.EnableBacklogSearching)
{
Logger.Trace("Backlog searching is not enabled, only running for explicitly enabled series.");
return _episodeService.EpisodesWithoutFiles(true).Where(e =>

View File

@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
@ -19,21 +20,21 @@ public class RssSyncJob : IJob
private readonly MonitoredEpisodeSpecification _isMonitoredEpisodeSpecification;
private readonly AllowedDownloadSpecification _allowedDownloadSpecification;
private readonly UpgradeHistorySpecification _upgradeHistorySpecification;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public RssSyncJob(DownloadProvider downloadProvider, IIndexerService indexerService,
MonitoredEpisodeSpecification isMonitoredEpisodeSpecification, AllowedDownloadSpecification allowedDownloadSpecification,
UpgradeHistorySpecification upgradeHistorySpecification, ConfigProvider configProvider)
UpgradeHistorySpecification upgradeHistorySpecification, IConfigService configService)
{
_downloadProvider = downloadProvider;
_indexerService = indexerService;
_isMonitoredEpisodeSpecification = isMonitoredEpisodeSpecification;
_allowedDownloadSpecification = allowedDownloadSpecification;
_upgradeHistorySpecification = upgradeHistorySpecification;
_configProvider = configProvider;
_configService = configService;
}
public string Name
@ -43,7 +44,7 @@ public string Name
public TimeSpan DefaultInterval
{
get { return TimeSpan.FromMinutes(_configProvider.RssSyncInterval); }
get { return TimeSpan.FromMinutes(_configService.RssSyncInterval); }
}
public void Start(ProgressNotification notification, dynamic options)

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification;
@ -16,17 +17,17 @@ public class UpdateInfoJob : IJob
private readonly ISeriesService _seriesService;
private readonly IEpisodeService _episodeService;
private readonly ReferenceDataProvider _referenceDataProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly ISeriesRepository _seriesRepository;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public UpdateInfoJob(ISeriesService seriesService, IEpisodeService episodeService,
ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider, ISeriesRepository seriesRepository)
ReferenceDataProvider referenceDataProvider, IConfigService configService, ISeriesRepository seriesRepository)
{
_seriesService = seriesService;
_episodeService = episodeService;
_referenceDataProvider = referenceDataProvider;
_configProvider = configProvider;
_configService = configService;
_seriesRepository = seriesRepository;
}
@ -50,7 +51,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
IList<Series> seriesToUpdate;
if (options == null || options.SeriesId == 0)
{
if (_configProvider.IgnoreArticlesWhenSortingSeries)
if (_configService.IgnoreArticlesWhenSortingSeries)
seriesToUpdate = _seriesRepository.All().OrderBy(o => o.Title.IgnoreArticles()).ToList();
else

View File

@ -214,6 +214,9 @@
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Configuration\Config.cs" />
<Compile Include="Configuration\ConfigRepository.cs" />
<Compile Include="Configuration\IConfigService.cs" />
<Compile Include="Constants.cs" />
<Compile Include="ContainerExtentions.cs" />
<Compile Include="Datastore\ModelBase.cs" />
@ -406,7 +409,7 @@
<Compile Include="Providers\Core\ArchiveProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Providers\Core\ConfigProvider.cs">
<Compile Include="Configuration\ConfigService.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Providers\Core\UdpProvider.cs">
@ -589,7 +592,6 @@
<Compile Include="Tv\Episode.cs" />
<Compile Include="Instrumentation\Log.cs" />
<Compile Include="History\History.cs" />
<Compile Include="Repository\Config.cs" />
<Compile Include="Repository\Quality\QualityType.cs" />
<Compile Include="Repository\Quality\QualityProfile.cs" />
<Compile Include="RootFolders\RootFolder.cs" />

View File

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -11,13 +12,13 @@ namespace NzbDrone.Core.Providers.Converting
{
public class AtomicParsleyProvider
{
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public AtomicParsleyProvider(ConfigProvider configProvider)
public AtomicParsleyProvider(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
}
public AtomicParsleyProvider()
@ -29,8 +30,8 @@ public virtual bool RunAtomicParsley(Episode episode, string outputFile)
{
throw new NotImplementedException();
var atomicParsleyLocation = _configProvider.GetValue("AtomicParsleyLocation", "");
var atomicParsleyTitleType = (AtomicParsleyTitleType) Convert.ToInt32(_configProvider.GetValue("AtomicParsley", 0));
var atomicParsleyLocation = _configService.GetValue("AtomicParsleyLocation", "");
var atomicParsleyTitleType = (AtomicParsleyTitleType) Convert.ToInt32(_configService.GetValue("AtomicParsley", 0));
var atomicParsleyCommand = String.Format("\"{0}\" --overWrite --title \"{1}\" --genre \"TV Shows\" --stik \"TV Show\" --TVShowName \"{2}\" --TVEpisodeNum \"{3}\" --TVSeason \"{4}\"",
outputFile, episode.Title, episode.Series.Title, episode.EpisodeNumber, episode.SeasonNumber);

View File

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
@ -12,7 +13,7 @@ namespace NzbDrone.Core.Providers.Converting
public class HandbrakeProvider
{
//Interacts with Handbrake
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private ProgressNotification _notification;
private Episode _currentEpisode;
@ -22,9 +23,9 @@ public class HandbrakeProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public HandbrakeProvider(ConfigProvider configProvider)
public HandbrakeProvider(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
}
public HandbrakeProvider()
@ -37,9 +38,9 @@ public virtual string ConvertFile(Episode episode, ProgressNotification notifica
_notification = notification;
_currentEpisode = episode;
var outputFile = _configProvider.GetValue("iPodConvertDir", "");
var outputFile = _configService.GetValue("iPodConvertDir", "");
var handBrakePreset = _configProvider.GetValue("HandBrakePreset", "iPhone & iPod Touch");
var handBrakePreset = _configService.GetValue("HandBrakePreset", "iPhone & iPod Touch");
var handBrakeCommand = String.Format("-i \"{0}\" -o \"{1}\" --preset=\"{2}\"", episode.EpisodeFile.Path, outputFile, handBrakePreset);
var handBrakeFile = @"C:\Program Files (x86)\Handbrake\HandBrakeCLI.exe";

View File

@ -4,6 +4,7 @@
using System.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -22,7 +23,7 @@ public class DiskScanProvider
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly DownloadProvider _downloadProvider;
private readonly SignalRProvider _signalRProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly RecycleBinProvider _recycleBinProvider;
private readonly MediaInfoProvider _mediaInfoProvider;
private readonly ISeriesRepository _seriesRepository;
@ -30,7 +31,7 @@ public class DiskScanProvider
public DiskScanProvider(DiskProvider diskProvider, IEpisodeService episodeService,
ISeriesService seriesService, MediaFileProvider mediaFileProvider,
ExternalNotificationProvider externalNotificationProvider, DownloadProvider downloadProvider,
SignalRProvider signalRProvider, ConfigProvider configProvider,
SignalRProvider signalRProvider, IConfigService configService,
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider, ISeriesRepository seriesRepository)
{
_diskProvider = diskProvider;
@ -40,7 +41,7 @@ public DiskScanProvider(DiskProvider diskProvider, IEpisodeService episodeServic
_externalNotificationProvider = externalNotificationProvider;
_downloadProvider = downloadProvider;
_signalRProvider = signalRProvider;
_configProvider = configProvider;
_configService = configService;
_recycleBinProvider = recycleBinProvider;
_mediaInfoProvider = mediaInfoProvider;
_seriesRepository = seriesRepository;
@ -270,7 +271,7 @@ public virtual void CleanUp(IList<EpisodeFile> files)
{
Logger.Trace("Detaching episode {0} from file.", episode.OID);
episode.EpisodeFile = null;
episode.Ignored = _configProvider.AutoIgnorePreviouslyDownloadedEpisodes;
episode.Ignored = _configService.AutoIgnorePreviouslyDownloadedEpisodes;
episode.GrabDate = null;
episode.PostDownloadStatus = PostDownloadStatusType.Unknown;
_episodeService.UpdateEpisode(episode);

View File

@ -3,6 +3,7 @@
using System.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.History;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -12,7 +13,7 @@ namespace NzbDrone.Core.Providers.DownloadClients
{
public class BlackholeProvider : IDownloadClient
{
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly HttpProvider _httpProvider;
private readonly DiskProvider _diskProvider;
private readonly UpgradeHistorySpecification _upgradeHistorySpecification;
@ -20,10 +21,10 @@ public class BlackholeProvider : IDownloadClient
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public BlackholeProvider(ConfigProvider configProvider, HttpProvider httpProvider,
public BlackholeProvider(IConfigService configService, HttpProvider httpProvider,
DiskProvider diskProvider, UpgradeHistorySpecification upgradeHistorySpecification)
{
_configProvider = configProvider;
_configService = configService;
_httpProvider = httpProvider;
_diskProvider = diskProvider;
_upgradeHistorySpecification = upgradeHistorySpecification;
@ -39,7 +40,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
{
title = MediaFileProvider.CleanFilename(title);
var filename = Path.Combine(_configProvider.BlackholeDirectory, title + ".nzb");
var filename = Path.Combine(_configService.BlackholeDirectory, title + ".nzb");
if (_diskProvider.FileExists(filename))
{

View File

@ -8,6 +8,7 @@
using Newtonsoft.Json.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Providers.Core;
@ -18,12 +19,12 @@ namespace NzbDrone.Core.Providers.DownloadClients
public class NzbgetProvider : IDownloadClient
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly HttpProvider _httpProvider;
public NzbgetProvider(ConfigProvider configProvider, HttpProvider httpProvider)
public NzbgetProvider(IConfigService configService, HttpProvider httpProvider)
{
_configProvider = configProvider;
_configService = configService;
_httpProvider = httpProvider;
}
@ -68,8 +69,8 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
{
try
{
string cat = _configProvider.NzbgetTvCategory;
int priority = recentlyAired ? (int)_configProvider.NzbgetRecentTvPriority : (int)_configProvider.NzbgetBacklogTvPriority;
string cat = _configService.NzbgetTvCategory;
int priority = recentlyAired ? (int)_configService.NzbgetRecentTvPriority : (int)_configService.NzbgetBacklogTvPriority;
var command = new JsonRequest
{
@ -115,16 +116,16 @@ public virtual VersionModel GetVersion(string host = null, int port = 0, string
{
//Get saved values if any of these are defaults
if (host == null)
host = _configProvider.NzbgetHost;
host = _configService.NzbgetHost;
if (port == 0)
port = _configProvider.NzbgetPort;
port = _configService.NzbgetPort;
if (username == null)
username = _configProvider.NzbgetUsername;
username = _configService.NzbgetUsername;
if (password == null)
password = _configProvider.NzbgetPassword;
password = _configService.NzbgetPassword;
var command = new JsonRequest
{
@ -158,10 +159,10 @@ public virtual string Test(string host, int port, string username, string passwo
private string PostCommand(string command)
{
var url = String.Format(@"{0}:{1}",
_configProvider.NzbgetHost,
_configProvider.NzbgetPort);
_configService.NzbgetHost,
_configService.NzbgetPort);
return _httpProvider.PostCommand(url, _configProvider.NzbgetUsername, _configProvider.NzbgetPassword, command);
return _httpProvider.PostCommand(url, _configService.NzbgetUsername, _configService.NzbgetPassword, command);
}
private void CheckForError(string response)

View File

@ -3,6 +3,7 @@
using System.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.DecisionEngine;
@ -11,17 +12,17 @@ namespace NzbDrone.Core.Providers.DownloadClients
{
public class PneumaticProvider : IDownloadClient
{
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly HttpProvider _httpProvider;
private readonly DiskProvider _diskProvider;
private readonly UpgradeHistorySpecification _upgradeHistorySpecification;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public PneumaticProvider(ConfigProvider configProvider, HttpProvider httpProvider,
public PneumaticProvider(IConfigService configService, HttpProvider httpProvider,
DiskProvider diskProvider, UpgradeHistorySpecification upgradeHistorySpecification)
{
_configProvider = configProvider;
_configService = configService;
_httpProvider = httpProvider;
_diskProvider = diskProvider;
_upgradeHistorySpecification = upgradeHistorySpecification;
@ -45,7 +46,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
title = MediaFileProvider.CleanFilename(title);
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
var filename = Path.Combine(_configProvider.PneumaticDirectory, title + ".nzb");
var filename = Path.Combine(_configService.PneumaticDirectory, title + ".nzb");
if (_diskProvider.FileExists(filename))
{
@ -60,7 +61,7 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
logger.Trace("NZB Download succeeded, saved to: {0}", filename);
var contents = String.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", filename, title);
_diskProvider.WriteAllText(Path.Combine(_configProvider.DownloadClientTvDirectory, title + ".strm"), contents);
_diskProvider.WriteAllText(Path.Combine(_configService.DownloadClientTvDirectory, title + ".strm"), contents);
return true;
}

View File

@ -8,6 +8,7 @@
using Newtonsoft.Json.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Sabnzbd;
using NzbDrone.Core.Providers.Core;
@ -18,12 +19,12 @@ namespace NzbDrone.Core.Providers.DownloadClients
public class SabProvider : IDownloadClient
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly HttpProvider _httpProvider;
public SabProvider(ConfigProvider configProvider, HttpProvider httpProvider)
public SabProvider(IConfigService configService, HttpProvider httpProvider)
{
_configProvider = configProvider;
_configService = configService;
_httpProvider = httpProvider;
}
@ -67,8 +68,8 @@ public virtual bool DownloadNzb(string url, string title, bool recentlyAired)
{
try
{
string cat = _configProvider.SabTvCategory;
int priority = recentlyAired ? (int)_configProvider.SabRecentTvPriority : (int)_configProvider.SabBacklogTvPriority;
string cat = _configService.SabTvCategory;
int priority = recentlyAired ? (int)_configService.SabRecentTvPriority : (int)_configService.SabBacklogTvPriority;
string name = url.Replace("&", "%26");
string nzbName = HttpUtility.UrlEncode(title);
@ -122,19 +123,19 @@ public virtual SabCategoryModel GetCategories(string host = null, int port = 0,
{
//Get saved values if any of these are defaults
if (host == null)
host = _configProvider.SabHost;
host = _configService.SabHost;
if (port == 0)
port = _configProvider.SabPort;
port = _configService.SabPort;
if (apiKey == null)
apiKey = _configProvider.SabApiKey;
apiKey = _configService.SabApiKey;
if (username == null)
username = _configProvider.SabUsername;
username = _configService.SabUsername;
if (password == null)
password = _configProvider.SabPassword;
password = _configService.SabPassword;
const string action = "mode=get_cats&output=json";
@ -155,19 +156,19 @@ public virtual SabVersionModel GetVersion(string host = null, int port = 0, stri
{
//Get saved values if any of these are defaults
if (host == null)
host = _configProvider.SabHost;
host = _configService.SabHost;
if (port == 0)
port = _configProvider.SabPort;
port = _configService.SabPort;
if (apiKey == null)
apiKey = _configProvider.SabApiKey;
apiKey = _configService.SabApiKey;
if (username == null)
username = _configProvider.SabUsername;
username = _configService.SabUsername;
if (password == null)
password = _configProvider.SabPassword;
password = _configService.SabPassword;
const string action = "mode=version&output=json";
@ -202,12 +203,12 @@ public virtual string Test(string host, int port, string apiKey, string username
private string GetSabRequest(string action)
{
return string.Format(@"http://{0}:{1}/api?{2}&apikey={3}&ma_username={4}&ma_password={5}",
_configProvider.SabHost,
_configProvider.SabPort,
_configService.SabHost,
_configService.SabPort,
action,
_configProvider.SabApiKey,
_configProvider.SabUsername,
_configProvider.SabPassword);
_configService.SabApiKey,
_configService.SabUsername,
_configService.SabPassword);
}
private void CheckForError(string response)

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.History;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
@ -17,7 +18,7 @@ public class DownloadProvider
private readonly HistoryService _historyService;
private readonly IEpisodeService _episodeService;
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly BlackholeProvider _blackholeProvider;
private readonly SignalRProvider _signalRProvider;
private readonly PneumaticProvider _pneumaticProvider;
@ -27,7 +28,7 @@ public class DownloadProvider
public DownloadProvider(SabProvider sabProvider, HistoryService historyService,
IEpisodeService episodeService, ExternalNotificationProvider externalNotificationProvider,
ConfigProvider configProvider, BlackholeProvider blackholeProvider,
IConfigService configService, BlackholeProvider blackholeProvider,
SignalRProvider signalRProvider, PneumaticProvider pneumaticProvider,
NzbgetProvider nzbgetProvider)
{
@ -35,7 +36,7 @@ public DownloadProvider(SabProvider sabProvider, HistoryService historyService,
_historyService = historyService;
_episodeService = episodeService;
_externalNotificationProvider = externalNotificationProvider;
_configProvider = configProvider;
_configService = configService;
_blackholeProvider = blackholeProvider;
_signalRProvider = signalRProvider;
_pneumaticProvider = pneumaticProvider;
@ -85,7 +86,7 @@ public virtual bool DownloadReport(EpisodeParseResult parseResult)
public virtual IDownloadClient GetActiveDownloadClient()
{
switch (_configProvider.DownloadClient)
switch (_configService.DownloadClient)
{
case DownloadClientType.Blackhole:
return _blackholeProvider;
@ -103,7 +104,7 @@ public virtual IDownloadClient GetActiveDownloadClient()
public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
{
if(_configProvider.DownloadClientUseSceneName)
if(_configService.DownloadClientUseSceneName)
{
logger.Trace("Using scene name: {0}", parseResult.OriginalString);
return parseResult.OriginalString;

View File

@ -1,4 +1,5 @@
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -8,11 +9,11 @@ namespace NzbDrone.Core.Providers.ExternalNotification
public abstract class ExternalNotificationBase
{
protected readonly Logger _logger;
protected readonly ConfigProvider _configProvider;
protected readonly IConfigService _configService;
protected ExternalNotificationBase(ConfigProvider configProvider)
protected ExternalNotificationBase(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
_logger = LogManager.GetLogger(GetType().ToString());
}

View File

@ -1,5 +1,6 @@
using System;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -10,8 +11,8 @@ public class Growl : ExternalNotificationBase
{
private readonly GrowlProvider _growlProvider;
public Growl(ConfigProvider configProvider, GrowlProvider growlProvider)
: base(configProvider)
public Growl(IConfigService configService, GrowlProvider growlProvider)
: base(configService)
{
_growlProvider = growlProvider;
}
@ -25,16 +26,16 @@ public override void OnGrab(string message)
{
try
{
if(_configProvider.GrowlNotifyOnGrab)
if(_configService.GrowlNotifyOnGrab)
{
_logger.Trace("Sending Notification to Growl");
const string title = "Episode Grabbed";
var growlHost = _configProvider.GrowlHost.Split(':');
var growlHost = _configService.GrowlHost.Split(':');
var host = growlHost[0];
var port = Convert.ToInt32(growlHost[1]);
_growlProvider.SendNotification(title, message, "GRAB", host, port, _configProvider.GrowlPassword);
_growlProvider.SendNotification(title, message, "GRAB", host, port, _configService.GrowlPassword);
}
}
@ -48,16 +49,16 @@ public override void OnDownload(string message, Series series)
{
try
{
if (_configProvider.GrowlNotifyOnDownload)
if (_configService.GrowlNotifyOnDownload)
{
_logger.Trace("Sending Notification to Growl");
const string title = "Episode Downloaded";
var growlHost = _configProvider.GrowlHost.Split(':');
var growlHost = _configService.GrowlHost.Split(':');
var host = growlHost[0];
var port = Convert.ToInt32(growlHost[1]);
_growlProvider.SendNotification(title, message, "DOWNLOAD", host, port, _configProvider.GrowlPassword);
_growlProvider.SendNotification(title, message, "DOWNLOAD", host, port, _configService.GrowlPassword);
}
}

View File

@ -1,5 +1,6 @@
using System;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -10,8 +11,8 @@ public class Plex : ExternalNotificationBase
{
private readonly PlexProvider _plexProvider;
public Plex(ConfigProvider configProvider, PlexProvider plexProvider)
: base(configProvider)
public Plex(IConfigService configService, PlexProvider plexProvider)
: base(configService)
{
_plexProvider = plexProvider;
}
@ -25,7 +26,7 @@ public override void OnGrab(string message)
{
const string header = "NzbDrone [TV] - Grabbed";
if (_configProvider.PlexNotifyOnGrab)
if (_configService.PlexNotifyOnGrab)
{
_logger.Trace("Sending Notification to Plex Clients");
_plexProvider.Notify(header, message);
@ -36,7 +37,7 @@ public override void OnDownload(string message, Series series)
{
const string header = "NzbDrone [TV] - Downloaded";
if (_configProvider.PlexNotifyOnDownload)
if (_configService.PlexNotifyOnDownload)
{
_logger.Trace("Sending Notification to Plex Clients");
_plexProvider.Notify(header, message);
@ -57,7 +58,7 @@ public override void AfterRename(string message, Series series)
private void UpdateIfEnabled()
{
if (_configProvider.PlexUpdateLibrary)
if (_configService.PlexUpdateLibrary)
{
_logger.Trace("Sending Update Request to Plex Server");
_plexProvider.UpdateLibrary();

View File

@ -1,5 +1,6 @@
using System;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -11,8 +12,8 @@ public class Prowl : ExternalNotificationBase
{
private readonly ProwlProvider _prowlProvider;
public Prowl(ConfigProvider configProvider, ProwlProvider prowlProvider)
: base(configProvider)
public Prowl(IConfigService configService, ProwlProvider prowlProvider)
: base(configService)
{
_prowlProvider = prowlProvider;
}
@ -26,13 +27,13 @@ public override void OnGrab(string message)
{
try
{
if(_configProvider.GrowlNotifyOnGrab)
if(_configService.GrowlNotifyOnGrab)
{
_logger.Trace("Sending Notification to Prowl");
const string title = "Episode Grabbed";
var apiKeys = _configProvider.ProwlApiKeys;
var priority = _configProvider.ProwlPriority;
var apiKeys = _configService.ProwlApiKeys;
var priority = _configService.ProwlPriority;
_prowlProvider.SendNotification(title, message, apiKeys, (NotificationPriority)priority);
}
@ -48,13 +49,13 @@ public override void OnDownload(string message, Series series)
{
try
{
if (_configProvider.GrowlNotifyOnDownload)
if (_configService.GrowlNotifyOnDownload)
{
_logger.Trace("Sending Notification to Prowl");
const string title = "Episode Downloaded";
var apiKeys = _configProvider.ProwlApiKeys;
var priority = _configProvider.ProwlPriority;
var apiKeys = _configService.ProwlApiKeys;
var priority = _configService.ProwlPriority;
_prowlProvider.SendNotification(title, message, apiKeys, (NotificationPriority)priority);
}

View File

@ -1,4 +1,5 @@
using System;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -9,8 +10,8 @@ public class Smtp: ExternalNotificationBase
{
private readonly SmtpProvider _smtpProvider;
public Smtp(ConfigProvider configProvider, SmtpProvider smtpProvider)
: base(configProvider)
public Smtp(IConfigService configService, SmtpProvider smtpProvider)
: base(configService)
{
_smtpProvider = smtpProvider;
}
@ -25,7 +26,7 @@ public override void OnGrab(string message)
const string subject = "NzbDrone [TV] - Grabbed";
var body = String.Format("{0} sent to SABnzbd queue.", message);
if (_configProvider.SmtpNotifyOnGrab)
if (_configService.SmtpNotifyOnGrab)
{
_logger.Trace("Sending SMTP Notification");
_smtpProvider.SendEmail(subject, body);
@ -37,7 +38,7 @@ public override void OnDownload(string message, Series series)
const string subject = "NzbDrone [TV] - Downloaded";
var body = String.Format("{0} Downloaded and sorted.", message);
if (_configProvider.SmtpNotifyOnDownload)
if (_configService.SmtpNotifyOnDownload)
{
_logger.Trace("Sending SMTP Notification");
_smtpProvider.SendEmail(subject, body);

View File

@ -1,4 +1,5 @@
using System;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -9,8 +10,8 @@ public class Twitter : ExternalNotificationBase
{
private readonly TwitterProvider _twitterProvider;
public Twitter(ConfigProvider configProvider, TwitterProvider twitterProvider)
: base(configProvider)
public Twitter(IConfigService configService, TwitterProvider twitterProvider)
: base(configService)
{
_twitterProvider = twitterProvider;
}
@ -22,7 +23,7 @@ public override string Name
public override void OnGrab(string message)
{
if (_configProvider.TwitterNotifyOnGrab)
if (_configService.TwitterNotifyOnGrab)
{
_logger.Trace("Sending Notification to Twitter (On Grab)");
_twitterProvider.SendTweet("Download Started: " + message);
@ -31,7 +32,7 @@ public override void OnGrab(string message)
public override void OnDownload(string message, Series series)
{
if (_configProvider.TwitterNotifyOnDownload)
if (_configService.TwitterNotifyOnDownload)
{
_logger.Trace("Sending Notification to Twitter (On Grab)");
_twitterProvider.SendTweet("Download Completed: " + message);

View File

@ -1,4 +1,5 @@
using System;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -9,8 +10,8 @@ public class Xbmc : ExternalNotificationBase
{
private readonly XbmcProvider _xbmcProvider;
public Xbmc(ConfigProvider configProvider, XbmcProvider xbmcProvider)
: base(configProvider)
public Xbmc(IConfigService configService, XbmcProvider xbmcProvider)
: base(configService)
{
_xbmcProvider = xbmcProvider;
}
@ -24,7 +25,7 @@ public override void OnGrab(string message)
{
const string header = "NzbDrone [TV] - Grabbed";
if (_configProvider.XbmcNotifyOnGrab)
if (_configService.XbmcNotifyOnGrab)
{
_logger.Trace("Sending Notification to XBMC");
_xbmcProvider.Notify(header, message);
@ -35,7 +36,7 @@ public override void OnDownload(string message, Series series)
{
const string header = "NzbDrone [TV] - Downloaded";
if (_configProvider.XbmcNotifyOnDownload)
if (_configService.XbmcNotifyOnDownload)
{
_logger.Trace("Sending Notification to XBMC");
_xbmcProvider.Notify(header, message);
@ -56,13 +57,13 @@ public override void AfterRename(string message, Series series)
private void UpdateAndClean(Series series)
{
if (_configProvider.XbmcUpdateLibrary)
if (_configService.XbmcUpdateLibrary)
{
_logger.Trace("Sending Update Request to XBMC");
_xbmcProvider.Update(series);
}
if (_configProvider.XbmcCleanLibrary)
if (_configService.XbmcCleanLibrary)
{
_logger.Trace("Sending Clean DB Request to XBMC");
_xbmcProvider.Clean();

View File

@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
@ -16,14 +17,14 @@ namespace NzbDrone.Core.Providers
public class MediaFileProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly IDatabase _database;
private readonly IEpisodeService _episodeService;
public MediaFileProvider(IEpisodeService episodeService, ConfigProvider configProvider, IDatabase database)
public MediaFileProvider(IEpisodeService episodeService, IConfigService configService, IDatabase database)
{
_episodeService = episodeService;
_configProvider = configProvider;
_configService = configService;
_database = database;
}
@ -91,7 +92,7 @@ public virtual FileInfo CalculateFilePath(Series series, int seasonNumber, strin
string path = series.Path;
if (series.SeasonFolder)
{
var seasonFolder = _configProvider.SortingSeasonFolderFormat
var seasonFolder = _configService.SortingSeasonFolderFormat
.Replace("%0s", seasonNumber.ToString("00"))
.Replace("%s", seasonNumber.ToString());
@ -109,7 +110,7 @@ public virtual void CleanUpDatabase()
string updateString = "UPDATE Episodes SET EpisodeFileId = 0, GrabDate = NULL, PostDownloadStatus = 0";
if (_configProvider.AutoIgnorePreviouslyDownloadedEpisodes)
if (_configService.AutoIgnorePreviouslyDownloadedEpisodes)
{
updateString += ", Ignored = 1";
}
@ -143,7 +144,7 @@ LEFT OUTER JOIN Episodes
public virtual string GetNewFilename(IList<Episode> episodes, Series series, QualityTypes quality, bool proper, EpisodeFile episodeFile)
{
if (_configProvider.SortingUseSceneName)
if (_configService.SortingUseSceneName)
{
Logger.Trace("Attempting to use scene name");
if (String.IsNullOrWhiteSpace(episodeFile.SceneName))
@ -159,8 +160,8 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
var sortedEpisodes = episodes.OrderBy(e => e.EpisodeNumber);
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configProvider.SortingSeparatorStyle);
var numberStyle = EpisodeSortingHelper.GetNumberStyle(_configProvider.SortingNumberStyle);
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configService.SortingSeparatorStyle);
var numberStyle = EpisodeSortingHelper.GetNumberStyle(_configService.SortingNumberStyle);
var episodeNames = new List<String>();
@ -168,7 +169,7 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
string result = String.Empty;
if (_configProvider.SortingIncludeSeriesName)
if (_configService.SortingIncludeSeriesName)
{
result += series.Title + separatorStyle.Pattern;
}
@ -181,7 +182,7 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
if(episodes.Count > 1)
{
var multiEpisodeStyle =
EpisodeSortingHelper.GetMultiEpisodeStyle(_configProvider.SortingMultiEpisodeStyle);
EpisodeSortingHelper.GetMultiEpisodeStyle(_configService.SortingMultiEpisodeStyle);
foreach(var episode in sortedEpisodes.Skip(1))
{
@ -215,7 +216,7 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
result += "Unknown";
}
if (_configProvider.SortingIncludeEpisodeTitle)
if (_configService.SortingIncludeEpisodeTitle)
{
if (episodeNames.Distinct().Count() == 1)
result += separatorStyle.Pattern + episodeNames.First();
@ -224,7 +225,7 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
result += separatorStyle.Pattern + String.Join(" + ", episodeNames.Distinct());
}
if (_configProvider.SortingAppendQuality)
if (_configService.SortingAppendQuality)
{
result += String.Format(" [{0}]", quality);
@ -232,7 +233,7 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
result += " [Proper]";
}
if (_configProvider.SortingReplaceSpaces)
if (_configService.SortingReplaceSpaces)
result = result.Replace(' ', '.');
Logger.Trace("New File Name is: [{0}]", result.Trim());

View File

@ -1,6 +1,7 @@
using System;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -12,15 +13,15 @@ namespace NzbDrone.Core.Providers.Metadata
public abstract class MetadataBase
{
protected readonly Logger _logger;
protected readonly ConfigProvider _configProvider;
protected readonly IConfigService _configService;
protected readonly DiskProvider _diskProvider;
protected readonly BannerProvider _bannerProvider;
protected readonly IEpisodeService _episodeService;
protected MetadataBase(ConfigProvider configProvider, DiskProvider diskProvider,
protected MetadataBase(IConfigService configService, DiskProvider diskProvider,
BannerProvider bannerProvider, IEpisodeService episodeService)
{
_configProvider = configProvider;
_configService = configService;
_diskProvider = diskProvider;
_bannerProvider = bannerProvider;
_episodeService = episodeService;

View File

@ -5,6 +5,7 @@
using System.Xml;
using System.Xml.Linq;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -16,9 +17,9 @@ namespace NzbDrone.Core.Providers.Metadata
{
public class Xbmc : MetadataBase
{
public Xbmc(ConfigProvider configProvider, DiskProvider diskProvider,
public Xbmc(IConfigService configService, DiskProvider diskProvider,
BannerProvider bannerProvider, IEpisodeService episodeService)
: base(configProvider, diskProvider, bannerProvider, episodeService)
: base(configService, diskProvider, bannerProvider, episodeService)
{
}
@ -84,7 +85,7 @@ public override void CreateForSeries(Series series, TvdbSeries tvDbSeries)
if (!_diskProvider.FileExists(Path.Combine(series.Path, "folder.jpg")))
{
if(_configProvider.MetadataUseBanners)
if(_configService.MetadataUseBanners)
{
if(!String.IsNullOrWhiteSpace(tvDbSeries.BannerPath))
{

View File

@ -6,6 +6,7 @@
using System.Xml.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
@ -13,13 +14,13 @@ namespace NzbDrone.Core.Providers
public class PlexProvider
{
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public PlexProvider(HttpProvider httpProvider, ConfigProvider configProvider)
public PlexProvider(HttpProvider httpProvider, IConfigService configService)
{
_httpProvider = httpProvider;
_configProvider = configProvider;
_configService = configService;
}
public PlexProvider()
@ -30,12 +31,12 @@ public PlexProvider()
public virtual void Notify(string header, string message)
{
//Foreach plex client send a notification
foreach(var host in _configProvider.PlexClientHosts.Split(','))
foreach(var host in _configService.PlexClientHosts.Split(','))
{
try
{
var command = String.Format("ExecBuiltIn(Notification({0}, {1}))", header, message);
SendCommand(host.Trim(), command, _configProvider.PlexUsername, _configProvider.PlexPassword);
SendCommand(host.Trim(), command, _configService.PlexUsername, _configService.PlexPassword);
}
catch(Exception ex)
{
@ -46,7 +47,7 @@ public virtual void Notify(string header, string message)
public virtual void UpdateLibrary()
{
var host = _configProvider.PlexServerHost;
var host = _configService.PlexServerHost;
try
{
@ -98,7 +99,7 @@ public virtual void TestNotification(string hosts, string username, string passw
{
logger.Trace("Sending Test Notifcation to XBMC Host: {0}", host);
var command = String.Format("ExecBuiltIn(Notification({0}, {1}))", "Test Notification", "Success! Notifications are setup correctly");
SendCommand(host.Trim(), command, _configProvider.PlexUsername, _configProvider.PlexPassword);
SendCommand(host.Trim(), command, _configService.PlexUsername, _configService.PlexPassword);
}
}
}

View File

@ -5,6 +5,7 @@
using System.Text;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
@ -12,14 +13,14 @@ namespace NzbDrone.Core.Providers
public class RecycleBinProvider
{
private readonly DiskProvider _diskProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public RecycleBinProvider(DiskProvider diskProvider, ConfigProvider configProvider)
public RecycleBinProvider(DiskProvider diskProvider, IConfigService configService)
{
_diskProvider = diskProvider;
_configProvider = configProvider;
_configService = configService;
}
public RecycleBinProvider()
@ -29,7 +30,7 @@ public RecycleBinProvider()
public virtual void DeleteDirectory(string path)
{
logger.Trace("Attempting to send '{0}' to recycling bin", path);
var recyclingBin = _configProvider.RecycleBin;
var recyclingBin = _configService.RecycleBin;
if (String.IsNullOrWhiteSpace(recyclingBin))
{
@ -59,7 +60,7 @@ public virtual void DeleteDirectory(string path)
public virtual void DeleteFile(string path)
{
logger.Trace("Attempting to send '{0}' to recycling bin", path);
var recyclingBin = _configProvider.RecycleBin;
var recyclingBin = _configService.RecycleBin;
if (String.IsNullOrWhiteSpace(recyclingBin))
{
@ -81,7 +82,7 @@ public virtual void DeleteFile(string path)
public virtual void Empty()
{
if (String.IsNullOrWhiteSpace(_configProvider.RecycleBin))
if (String.IsNullOrWhiteSpace(_configService.RecycleBin))
{
logger.Info("Recycle Bin has not been configured, cannot empty.");
return;
@ -89,12 +90,12 @@ public virtual void Empty()
logger.Info("Removing all items from the recycling bin");
foreach (var folder in _diskProvider.GetDirectories(_configProvider.RecycleBin))
foreach (var folder in _diskProvider.GetDirectories(_configService.RecycleBin))
{
_diskProvider.DeleteFolder(folder, true);
}
foreach (var file in _diskProvider.GetFiles(_configProvider.RecycleBin, SearchOption.TopDirectoryOnly))
foreach (var file in _diskProvider.GetFiles(_configService.RecycleBin, SearchOption.TopDirectoryOnly))
{
_diskProvider.DeleteFile(file);
}
@ -104,7 +105,7 @@ public virtual void Empty()
public virtual void Cleanup()
{
if (String.IsNullOrWhiteSpace(_configProvider.RecycleBin))
if (String.IsNullOrWhiteSpace(_configService.RecycleBin))
{
logger.Info("Recycle Bin has not been configured, cannot cleanup.");
return;
@ -112,7 +113,7 @@ public virtual void Cleanup()
logger.Info("Removing items older than 7 days from the recycling bin");
foreach (var folder in _diskProvider.GetDirectories(_configProvider.RecycleBin))
foreach (var folder in _diskProvider.GetDirectories(_configService.RecycleBin))
{
if (_diskProvider.GetLastDirectoryWrite(folder).AddDays(7) > DateTime.UtcNow)
{
@ -123,7 +124,7 @@ public virtual void Cleanup()
_diskProvider.DeleteFolder(folder, true);
}
foreach (var file in _diskProvider.GetFiles(_configProvider.RecycleBin, SearchOption.TopDirectoryOnly))
foreach (var file in _diskProvider.GetFiles(_configService.RecycleBin, SearchOption.TopDirectoryOnly))
{
if (_diskProvider.GetLastFileWrite(file).AddDays(7) > DateTime.UtcNow)
{

View File

@ -6,6 +6,7 @@
using NLog;
using Newtonsoft.Json;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
@ -16,15 +17,15 @@ public class ReferenceDataProvider
{
private readonly IDatabase _database;
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public ReferenceDataProvider(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider)
public ReferenceDataProvider(IDatabase database, HttpProvider httpProvider, IConfigService configService)
{
_database = database;
_httpProvider = httpProvider;
_configProvider = configProvider;
_configService = configService;
}
public virtual void UpdateDailySeries()
@ -52,7 +53,7 @@ public List<int> GetDailySeriesIds()
{
try
{
var dailySeriesIds = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/DailySeries/AllIds");
var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);

View File

@ -4,6 +4,7 @@
using NLog;
using Newtonsoft.Json;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
@ -15,13 +16,13 @@ public class SceneMappingProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IDatabase _database;
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
public SceneMappingProvider(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider)
public SceneMappingProvider(IDatabase database, HttpProvider httpProvider, IConfigService configService)
{
_database = database;
_httpProvider = httpProvider;
_configProvider = configProvider;
_configService = configService;
}
public SceneMappingProvider()
@ -33,7 +34,7 @@ public virtual bool UpdateMappings()
{
try
{
var mappingsJson = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/SceneMapping/Active");
var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active");
var mappings = JsonConvert.DeserializeObject<List<SceneMapping>>(mappingsJson);
Logger.Debug("Deleting all existing Scene Mappings.");
@ -92,7 +93,7 @@ public virtual bool SubmitMapping(int id, string postTitle)
Logger.Trace("Example post parsed. CleanTitle: {0}, Title: {1}", cleanTitle, title);
var newMapping = String.Format("/SceneMapping/AddPending?cleanTitle={0}&id={1}&title={2}", cleanTitle, id, title);
var response = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + newMapping);
var response = _httpProvider.DownloadString(_configService.ServiceRootUrl + newMapping);
if (JsonConvert.DeserializeObject<String>(response).Equals("Ok"))
return true;

View File

@ -5,6 +5,7 @@
using System.Net.Mail;
using System.Text;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
@ -12,11 +13,11 @@ namespace NzbDrone.Core.Providers
public class SmtpProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
public SmtpProvider(ConfigProvider configProvider)
public SmtpProvider(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
}
public virtual void SendEmail(string subject, string body, bool htmlBody = false)
@ -25,10 +26,10 @@ public virtual void SendEmail(string subject, string body, bool htmlBody = false
var email = new MailMessage();
//Set the addresses
email.From = new MailAddress(_configProvider.SmtpFromAddress);
email.From = new MailAddress(_configService.SmtpFromAddress);
//Allow multiple to addresses (split on each comma)
foreach (var toAddress in _configProvider.SmtpToAddresses.Split(','))
foreach (var toAddress in _configService.SmtpToAddresses.Split(','))
{
email.To.Add(toAddress.Trim());
}
@ -43,8 +44,8 @@ public virtual void SendEmail(string subject, string body, bool htmlBody = false
email.IsBodyHtml = htmlBody;
//Handle credentials
var username = _configProvider.SmtpUsername;
var password = _configProvider.SmtpPassword;
var username = _configService.SmtpUsername;
var password = _configService.SmtpPassword;
NetworkCredential credentials = null;
@ -54,7 +55,7 @@ public virtual void SendEmail(string subject, string body, bool htmlBody = false
//Send the email
try
{
Send(email, _configProvider.SmtpServer, _configProvider.SmtpPort, _configProvider.SmtpUseSsl, credentials);
Send(email, _configService.SmtpServer, _configService.SmtpPort, _configService.SmtpUseSsl, credentials);
}
catch(Exception ex)
{

View File

@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Twitter;
using NzbDrone.Core.Providers.Core;
@ -12,16 +13,16 @@ namespace NzbDrone.Core.Providers
{
public class TwitterProvider
{
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private const string ConsumerKey = "umKU6jBWpFbHTuqQbW2VlQ";
private const string ConsumerSecret = "e30OXkI6qrZWS35hbUUnrQQ8J2R9XNpccQNWAVK10";
public TwitterProvider(ConfigProvider configProvider)
public TwitterProvider(IConfigService configService)
{
_configProvider = configProvider;
_configService = configService;
}
public virtual TwitterAuthorizationModel GetAuthorization()
@ -55,8 +56,8 @@ public virtual bool GetAndSaveAccessToken(string authToken, string verifier)
OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(ConsumerKey, ConsumerSecret, authToken, verifier);
_configProvider.TwitterAccessToken = accessToken.Token;
_configProvider.TwitterAccessTokenSecret = accessToken.TokenSecret;
_configService.TwitterAccessToken = accessToken.Token;
_configService.TwitterAccessTokenSecret = accessToken.TokenSecret;
//Send a tweet to test!
SendTweet("I have just setup tweet notifications for NzbDrone!");
@ -77,8 +78,8 @@ public virtual bool SendTweet(string message)
{
Logger.Trace("Sending status update to twitter: {0}", message);
var accessToken = _configProvider.TwitterAccessToken;
var accessTokenSecret = _configProvider.TwitterAccessTokenSecret;
var accessToken = _configService.TwitterAccessToken;
var accessTokenSecret = _configService.TwitterAccessTokenSecret;
//If the access token or access token secret are not configured, log an error and return
if (String.IsNullOrWhiteSpace(accessToken) || String.IsNullOrWhiteSpace(accessTokenSecret))

View File

@ -7,6 +7,7 @@
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -16,7 +17,7 @@ namespace NzbDrone.Core.Providers
public class UpdateProvider
{
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly EnvironmentProvider _environmentProvider;
private readonly DiskProvider _diskProvider;
@ -26,11 +27,11 @@ public class UpdateProvider
public const string DEFAULT_UPDATE_URL = @"http://update.nzbdrone.com/_release/";
public UpdateProvider(HttpProvider httpProvider, ConfigProvider configProvider,
public UpdateProvider(HttpProvider httpProvider, IConfigService configService,
EnvironmentProvider environmentProvider, DiskProvider diskProvider)
{
_httpProvider = httpProvider;
_configProvider = configProvider;
_configService = configService;
_environmentProvider = environmentProvider;
_diskProvider = diskProvider;
}
@ -43,7 +44,7 @@ public UpdateProvider()
private List<UpdatePackage> GetAvailablePackages()
{
var updateList = new List<UpdatePackage>();
var updateUrl = _configProvider.UpdateUrl;
var updateUrl = _configService.UpdateUrl;
var rawUpdateList = _httpProvider.DownloadString(updateUrl);
var matches = parseRegex.Matches(rawUpdateList);

View File

@ -8,6 +8,7 @@
using Newtonsoft.Json.Linq;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Xbmc;
using NzbDrone.Core.Providers.Core;
@ -19,13 +20,13 @@ namespace NzbDrone.Core.Providers
public class XbmcProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly HttpProvider _httpProvider;
private readonly EventClientProvider _eventClientProvider;
public XbmcProvider(ConfigProvider configProvider, HttpProvider httpProvider, EventClientProvider eventClientProvider)
public XbmcProvider(IConfigService configService, HttpProvider httpProvider, EventClientProvider eventClientProvider)
{
_configProvider = configProvider;
_configService = configService;
_httpProvider = httpProvider;
_eventClientProvider = eventClientProvider;
}
@ -38,7 +39,7 @@ public XbmcProvider()
public virtual void Notify(string header, string message)
{
//Always use EventServer, until Json has real support for it
foreach (var host in _configProvider.XbmcHosts.Split(','))
foreach (var host in _configService.XbmcHosts.Split(','))
{
Logger.Trace("Sending Notifcation to XBMC Host: {0}", host);
_eventClientProvider.SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", GetHostWithoutPort(host));
@ -50,10 +51,10 @@ public virtual void Update(Series series)
//Use Json for Eden/Nightly or depricated HTTP for 10.x (Dharma) to get the proper path
//Perform update with EventServer (Json currently doesn't support updating a specific path only - July 2011)
var username = _configProvider.XbmcUsername;
var password = _configProvider.XbmcPassword;
var username = _configService.XbmcUsername;
var password = _configService.XbmcPassword;
foreach (var host in _configProvider.XbmcHosts.Split(','))
foreach (var host in _configService.XbmcHosts.Split(','))
{
Logger.Trace("Determining version of XBMC Host: {0}", host);
var version = GetJsonVersion(host, username, password);
@ -62,7 +63,7 @@ public virtual void Update(Series series)
if (version == new XbmcVersion(2))
{
//Check for active player only when we should skip updates when playing
if (!_configProvider.XbmcUpdateWhenPlaying)
if (!_configService.XbmcUpdateWhenPlaying)
{
Logger.Trace("Determining if there are any active players on XBMC host: {0}", host);
var activePlayers = GetActivePlayersDharma(host, username, password);
@ -82,7 +83,7 @@ public virtual void Update(Series series)
else if (version == new XbmcVersion(3) || version == new XbmcVersion(4))
{
//Check for active player only when we should skip updates when playing
if (!_configProvider.XbmcUpdateWhenPlaying)
if (!_configService.XbmcUpdateWhenPlaying)
{
Logger.Trace("Determining if there are any active players on XBMC host: {0}", host);
var activePlayers = GetActivePlayersEden(host, username, password);
@ -101,7 +102,7 @@ public virtual void Update(Series series)
else if (version >= new XbmcVersion(5))
{
//Check for active player only when we should skip updates when playing
if (!_configProvider.XbmcUpdateWhenPlaying)
if (!_configService.XbmcUpdateWhenPlaying)
{
Logger.Trace("Determining if there are any active players on XBMC host: {0}", host);
var activePlayers = GetActivePlayersEden(host, username, password);
@ -251,7 +252,7 @@ public virtual void Clean()
{
//Use EventServer, once Dharma is extinct use Json?
foreach (var host in _configProvider.XbmcHosts.Split(','))
foreach (var host in _configService.XbmcHosts.Split(','))
{
Logger.Trace("Sending DB Clean Request to XBMC Host: {0}", host);
var command = "ExecBuiltIn(CleanLibrary(video))";

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using Newtonsoft.Json;
using NzbDrone.Common;
using NzbDrone.Core.Providers.Core;
using PetaPoco;
namespace NzbDrone.Core.ReferenceData
{
public class DailySeriesService
{
private readonly IDatabase _database;
private readonly HttpProvider _httpProvider;
private readonly ConfigProvider _configProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public DailySeriesService(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider)
{
_database = database;
_httpProvider = httpProvider;
_configProvider = configProvider;
}
public virtual void UpdateDailySeries()
{
//Update all series in DB
//DailySeries.csv
var seriesIds = GetDailySeriesIds();
if (seriesIds.Any())
{
var dailySeriesString = String.Join(", ", seriesIds);
var sql = String.Format("UPDATE Series SET IsDaily = 1 WHERE SeriesId in ({0})", dailySeriesString);
_database.Execute(sql);
}
}
public virtual bool IsSeriesDaily(int seriesId)
{
return GetDailySeriesIds().Contains(seriesId);
}
public List<int> GetDailySeriesIds()
{
try
{
var dailySeriesIds = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/DailySeries/AllIds");
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);
return seriesIds;
}
catch (Exception ex)
{
Logger.WarnException("Failed to get Daily Series", ex);
return new List<int>();
}
}
}
}

View File

@ -1,12 +0,0 @@
using PetaPoco;
namespace NzbDrone.Core.Repository
{
[PrimaryKey("Key", autoIncrement = false)]
public class Config
{
public string Key { get; set; }
public string Value { get; set; }
}
}

View File

@ -5,6 +5,7 @@
using NLog;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Eventing;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@ -24,7 +25,7 @@ public interface ISeriesService
public class SeriesService : ISeriesService
{
private readonly ISeriesRepository _seriesRepository;
private readonly ConfigProvider _configProvider;
private readonly IConfigService _configService;
private readonly TvDbProvider _tvDbProvider;
private readonly MetadataProvider _metadataProvider;
private readonly TvRageMappingProvider _tvRageMappingProvider;
@ -34,12 +35,12 @@ public class SeriesService : ISeriesService
private readonly SceneMappingProvider _sceneNameMappingProvider;
public SeriesService(ISeriesRepository seriesRepository, ConfigProvider configProviderProvider,
public SeriesService(ISeriesRepository seriesRepository, ConfigService configServiceService,
TvDbProvider tvDbProviderProvider, SceneMappingProvider sceneNameMappingProvider, MetadataProvider metadataProvider,
TvRageMappingProvider tvRageMappingProvider, IEventAggregator eventAggregator)
{
_seriesRepository = seriesRepository;
_configProvider = configProviderProvider;
_configService = configServiceService;
_tvDbProvider = tvDbProviderProvider;
_sceneNameMappingProvider = sceneNameMappingProvider;
_metadataProvider = metadataProvider;
@ -123,9 +124,9 @@ public void AddSeries(string title, string path, int tvDbSeriesId, int qualityPr
repoSeries.QualityProfileId = qualityProfileId;
repoSeries.Title = title;
if (qualityProfileId == 0)
repoSeries.QualityProfileId = _configProvider.DefaultQualityProfile;
repoSeries.QualityProfileId = _configService.DefaultQualityProfile;
repoSeries.SeasonFolder = _configProvider.UseSeasonFolder;
repoSeries.SeasonFolder = _configService.UseSeasonFolder;
repoSeries.BacklogSetting = BacklogSettingType.Inherit;
if (airedAfter.HasValue)