diff --git a/NzbDrone.Api/NancyBootstrapper.cs b/NzbDrone.Api/NancyBootstrapper.cs index e89427841..622906f5f 100644 --- a/NzbDrone.Api/NancyBootstrapper.cs +++ b/NzbDrone.Api/NancyBootstrapper.cs @@ -11,6 +11,7 @@ using NzbDrone.Api.ErrorManagement; 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 @@ namespace NzbDrone.Api private void RegisterReporting(ILifetimeScope container) { - EnvironmentProvider.UGuid = container.Resolve().UGuid; + EnvironmentProvider.UGuid = container.Resolve().UGuid; ReportingService.RestProvider = container.Resolve(); ReportingService.SetupExceptronDriver(); } diff --git a/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs index 2ef538bd0..7479c2f3e 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs @@ -7,6 +7,7 @@ using FizzWare.NBuilder; 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 @@ namespace NzbDrone.Core.Test.DecisionEngineTests [Test] public void should_be_true_when_allowedReleaseGroups_is_empty() { - Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty); + Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty); Mocker.Resolve().IsSatisfiedBy(parseResult).Should().BeTrue(); } [Test] public void should_be_true_when_allowedReleaseGroups_is_nzbs_releaseGroup() { - Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD"); + Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD"); Mocker.Resolve().IsSatisfiedBy(parseResult).Should().BeTrue(); } [Test] public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup() { - Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL"); + Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL"); Mocker.Resolve().IsSatisfiedBy(parseResult).Should().BeTrue(); } [Test] public void should_be_false_when_allowedReleaseGroups_does_not_contain_nzbs_releaseGroup() { - Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD"); + Mocker.GetMock().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD"); Mocker.Resolve().IsSatisfiedBy(parseResult).Should().BeFalse(); } } diff --git a/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs index 3d72fb4d5..51cf23c0e 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs @@ -7,6 +7,7 @@ using FizzWare.NBuilder; 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 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void WithUnlimitedRetention() { - Mocker.GetMock().SetupGet(c => c.Retention).Returns(0); + Mocker.GetMock().SetupGet(c => c.Retention).Returns(0); } private void WithLongRetention() { - Mocker.GetMock().SetupGet(c => c.Retention).Returns(1000); + Mocker.GetMock().SetupGet(c => c.Retention).Returns(1000); } private void WithShortRetention() { - Mocker.GetMock().SetupGet(c => c.Retention).Returns(10); + Mocker.GetMock().SetupGet(c => c.Retention).Returns(10); } private void WithEqualRetention() { - Mocker.GetMock().SetupGet(c => c.Retention).Returns(100); + Mocker.GetMock().SetupGet(c => c.Retention).Returns(100); } [Test] diff --git a/NzbDrone.Core.Test/Framework/SqlCeTest.cs b/NzbDrone.Core.Test/Framework/SqlCeTest.cs index c8a2f1bf6..3d5a5bf62 100644 --- a/NzbDrone.Core.Test/Framework/SqlCeTest.cs +++ b/NzbDrone.Core.Test/Framework/SqlCeTest.cs @@ -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 @@ namespace NzbDrone.Core.Test.Framework [TearDown] public void CoreTestTearDown() { - ConfigProvider.ClearCache(); + ConfigService.ClearCache(); if (EnvironmentProvider.IsMono) { diff --git a/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs b/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs index 533c5766c..077c25e4f 100644 --- a/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs +++ b/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs @@ -10,6 +10,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.IndexerTests { private void WithConfiguredIndexers() { - Mocker.GetMock().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue"); - Mocker.GetMock().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue"); - Mocker.GetMock().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue"); - Mocker.GetMock().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue"); - Mocker.GetMock().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue"); - Mocker.GetMock().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue"); - Mocker.GetMock().SetupGet(c => c.OmgwtfnzbsUsername).Returns("MockedConfigValue"); - Mocker.GetMock().SetupGet(c => c.OmgwtfnzbsApiKey).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.OmgwtfnzbsUsername).Returns("MockedConfigValue"); + Mocker.GetMock().SetupGet(c => c.OmgwtfnzbsApiKey).Returns("MockedConfigValue"); } [TestCase("nzbsrus.xml")] diff --git a/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs b/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs index 1cb6fa3d6..66b80ca7c 100644 --- a/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs +++ b/NzbDrone.Core.Test/Indexers/IndexerServiceTest.cs @@ -8,6 +8,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.Indexers 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 @@ namespace NzbDrone.Core.Test.Indexers 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 @@ namespace NzbDrone.Core.Test.Indexers 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 @@ namespace NzbDrone.Core.Test.Indexers 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 @@ namespace NzbDrone.Core.Test.Indexers public class DefaultEnabledIndexer : IndexerBase { - public DefaultEnabledIndexer(HttpProvider httpProvider, ConfigProvider configProvider) - : base(httpProvider, configProvider) + public DefaultEnabledIndexer(HttpProvider httpProvider, ConfigService configService) + : base(httpProvider, configService) { } diff --git a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs index f87efcbfb..3cd091a86 100644 --- a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs @@ -4,6 +4,7 @@ using FizzWare.NBuilder; 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 @@ namespace NzbDrone.Core.Test.JobTests { private void WithEnableBacklogSearching() { - Mocker.GetMock().SetupGet(s => s.EnableBacklogSearching).Returns(true); + Mocker.GetMock().SetupGet(s => s.EnableBacklogSearching).Returns(true); } [Test] diff --git a/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs b/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs index b92ff1258..98ffaf34d 100644 --- a/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs +++ b/NzbDrone.Core.Test/JobTests/PostDownloadScanJobFixture.cs @@ -7,6 +7,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.JobTests Mocker.GetMock().Setup(s => s.ProcessDropFolder(path)); Mocker.Resolve().Start(MockNotification, new { Path = path }); - Mocker.GetMock().Verify(s => s.DownloadClientTvDirectory, Times.Never()); + Mocker.GetMock().Verify(s => s.DownloadClientTvDirectory, Times.Never()); } [Test] @@ -52,10 +53,10 @@ namespace NzbDrone.Core.Test.JobTests { var path = @"C:\Test\Unsorted TV"; - Mocker.GetMock().SetupGet(s => s.DownloadClientTvDirectory).Returns(path); + Mocker.GetMock().SetupGet(s => s.DownloadClientTvDirectory).Returns(path); Mocker.Resolve().Start(MockNotification, null); - Mocker.GetMock().Verify(s => s.DownloadClientTvDirectory, Times.Once()); + Mocker.GetMock().Verify(s => s.DownloadClientTvDirectory, Times.Once()); } [Test] @@ -63,7 +64,7 @@ namespace NzbDrone.Core.Test.JobTests { var path = @"C:\Test\Unsorted TV"; - Mocker.GetMock().SetupGet(s => s.DownloadClientTvDirectory).Returns(path); + Mocker.GetMock().SetupGet(s => s.DownloadClientTvDirectory).Returns(path); Mocker.Resolve().Start(MockNotification, null); Mocker.GetMock().Verify(s => s.ProcessDropFolder(path), Times.Once()); diff --git a/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs index ee2f4518e..2023d7d6b 100644 --- a/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs @@ -6,6 +6,7 @@ using FizzWare.NBuilder; 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 @@ namespace NzbDrone.Core.Test.JobTests { private void WithEnableBacklogSearching() { - Mocker.GetMock().SetupGet(s => s.EnableBacklogSearching).Returns(true); + Mocker.GetMock().SetupGet(s => s.EnableBacklogSearching).Returns(true); } [SetUp] diff --git a/NzbDrone.Core.Test/JobTests/RssSyncJobTest.cs b/NzbDrone.Core.Test/JobTests/RssSyncJobTest.cs index b6e567ce1..4bf9d2892 100644 --- a/NzbDrone.Core.Test/JobTests/RssSyncJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/RssSyncJobTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; 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 @@ namespace NzbDrone.Core.Test.JobTests { public void WithMinutes(int minutes) { - Mocker.GetMock().SetupGet(s => s.RssSyncInterval).Returns(minutes); + Mocker.GetMock().SetupGet(s => s.RssSyncInterval).Returns(minutes); } [TestCase(10)] diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index fe86bac90..254780bb9 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -172,7 +172,7 @@ - + @@ -250,7 +250,7 @@ - + diff --git a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTests/ConfigCachingFixture.cs b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTests/ConfigCachingFixture.cs deleted file mode 100644 index f71184d43..000000000 --- a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTests/ConfigCachingFixture.cs +++ /dev/null @@ -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().Setup(c => c.Fetch()) - .Returns(new List { new Config { Key = "Key1", Value = "Value1" } }); - - } - - [Test] - public void getting_value_more_than_once_should_hit_db_once() - { - Mocker.Resolve().GetValue("Key1", null).Should().Be("Value1"); - Mocker.Resolve().GetValue("Key1", null).Should().Be("Value1"); - Mocker.Resolve().GetValue("Key1", null).Should().Be("Value1"); - - Mocker.GetMock().Verify(c => c.Fetch(), Times.Once()); - } - - } -} diff --git a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTests/ConfigProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTests/ConfigProviderFixture.cs deleted file mode 100644 index f26d4f1ad..000000000 --- a/NzbDrone.Core.Test/ProviderTests/ConfigProviderTests/ConfigProviderFixture.cs +++ /dev/null @@ -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().SetValue(key, value); - Mocker.Resolve().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().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().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().SetValue(key, newValue); - var result = Mocker.Resolve().GetValue(key, ""); - - //Assert - result.Should().Be(newValue); - Db.Fetch().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().SetValue(key, value); - Mocker.Resolve().SetValue(key, value); - var result = Mocker.Resolve().GetValue(key, ""); - - //Assert - result.Should().Be(value); - Db.Fetch().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().GetValue(key, value, persist: true).Should().Be(value); - Mocker.Resolve().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().GetValue(key, value1).Should().Be(value1); - Mocker.Resolve().GetValue(key, value2).Should().Be(value2); - } - - - - [Test] - public void uguid_should_only_be_set_once() - { - var guid1 = Mocker.Resolve().UGuid; - var guid2 = Mocker.Resolve().UGuid; - - guid1.Should().Be(guid2); - } - - [Test] - public void uguid_should_return_valid_result_on_first_call() - { - var guid = Mocker.Resolve().UGuid; - guid.Should().NotBeEmpty(); - } - - [Test] - public void updating_a_vakye_should_update_its_value() - { - Mocker.Resolve().SabHost = "Test"; - Mocker.Resolve().SabHost.Should().Be("Test"); - - Mocker.Resolve().SabHost = "Test2"; - Mocker.Resolve().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(); - 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().Should() - .HaveSameCount(allProperties, "two different properties are writing to the same key in db. Copy/Past fail."); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs index 4c12a4d58..386a79ab1 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs @@ -8,6 +8,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests Mocker.GetMock() .Setup(e => e.Delete(It.IsAny())); - Mocker.GetMock() + Mocker.GetMock() .SetupGet(s => s.AutoIgnorePreviouslyDownloadedEpisodes) .Returns(true); diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/BlackholeProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/BlackholeProviderFixture.cs index af4c40858..a2a401325 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/BlackholeProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/BlackholeProviderFixture.cs @@ -8,6 +8,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests [SetUp] public void Setup() { - Mocker.GetMock().SetupGet(c => c.BlackholeDirectory).Returns(blackHoleFolder); + Mocker.GetMock().SetupGet(c => c.BlackholeDirectory).Returns(blackHoleFolder); } diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs index 7209241ba..1036b0e4f 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/DownloadNzbFixture.cs @@ -7,6 +7,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTes [SetUp] public void Setup() { - var fakeConfig = Mocker.GetMock(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(c => c.NzbgetHost).Returns("192.168.5.55"); fakeConfig.SetupGet(c => c.NzbgetPort).Returns(6789); fakeConfig.SetupGet(c => c.NzbgetUsername).Returns("nzbget"); diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/QueueFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/QueueFixture.cs index a19381ebb..9ed0aef8c 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/QueueFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/NzbgetProviderTests/QueueFixture.cs @@ -7,6 +7,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTes [SetUp] public void Setup() { - var fakeConfig = Mocker.GetMock(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(c => c.NzbgetHost).Returns("192.168.5.55"); fakeConfig.SetupGet(c => c.NzbgetPort).Returns(6789); fakeConfig.SetupGet(c => c.NzbgetUsername).Returns("nzbget"); diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/PneumaticProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/PneumaticProviderFixture.cs index 19c74d22b..faa791f5b 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/PneumaticProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/PneumaticProviderFixture.cs @@ -8,6 +8,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests { nzbPath = pneumaticFolder + title + ".nzb"; - Mocker.GetMock().SetupGet(c => c.PneumaticDirectory).Returns(pneumaticFolder); - Mocker.GetMock().SetupGet(c => c.DownloadClientTvDirectory).Returns(sabDrop); + Mocker.GetMock().SetupGet(c => c.PneumaticDirectory).Returns(pneumaticFolder); + Mocker.GetMock().SetupGet(c => c.DownloadClientTvDirectory).Returns(sabDrop); } private void WithExistingFile() diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs index aae6fb704..f0ad3b22b 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs @@ -8,6 +8,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests string password = "pass"; string cat = "tv"; - var fakeConfig = Mocker.GetMock(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(c => c.SabHost).Returns(sabHost); fakeConfig.SetupGet(c => c.SabPort).Returns(sabPort); fakeConfig.SetupGet(c => c.SabApiKey).Returns(apikey); diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs index d8e1a3181..3c0f5e0f7 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs @@ -10,6 +10,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests [SetUp] public void Setup() { - var fakeConfig = Mocker.GetMock(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(c => c.SabHost).Returns("192.168.5.55"); fakeConfig.SetupGet(c => c.SabPort).Returns(2222); @@ -209,11 +210,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests [Test] public void downloadNzb_should_use_sabRecentTvPriority_when_recentEpisode_is_true() { - Mocker.GetMock() + Mocker.GetMock() .SetupGet(s => s.SabRecentTvPriority) .Returns(SabPriorityType.High); - Mocker.GetMock() + Mocker.GetMock() .SetupGet(s => s.SabBacklogTvPriority) .Returns(SabPriorityType.Low); @@ -231,11 +232,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests [Test] public void downloadNzb_should_use_sabBackogTvPriority_when_recentEpisode_is_false() { - Mocker.GetMock() + Mocker.GetMock() .SetupGet(s => s.SabRecentTvPriority) .Returns(SabPriorityType.High); - Mocker.GetMock() + Mocker.GetMock() .SetupGet(s => s.SabBacklogTvPriority) .Returns(SabPriorityType.Low); diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadProviderTests/DownloadProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTests/DownloadProviderFixture.cs index c6e2e0879..4bceb3682 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadProviderTests/DownloadProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTests/DownloadProviderFixture.cs @@ -5,6 +5,7 @@ using FizzWare.NBuilder; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests private void SetDownloadClient(DownloadClientType clientType) { - Mocker.GetMock() + Mocker.GetMock() .Setup(c => c.DownloadClient) .Returns(clientType); } diff --git a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs index be8eb7a37..3a4df63ca 100644 --- a/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/MediaFileProviderTest.cs @@ -8,6 +8,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests .Build(); - Mocker.GetMock().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat); + Mocker.GetMock().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat); //Act var result = Mocker.Resolve().CalculateFilePath(fakeSeries, 1, filename, ".mkv"); diff --git a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs index f66716ac0..a5950f0e6 100644 --- a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs @@ -8,6 +8,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata private void WithUseBanners() { - Mocker.GetMock().SetupGet(s => s.MetadataUseBanners).Returns(true); + Mocker.GetMock().SetupGet(s => s.MetadataUseBanners).Returns(true); } private void WithSingleEpisodeFile() diff --git a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs index 300371b4a..3eb746724 100644 --- a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs @@ -7,6 +7,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata private void WithUseBanners() { - Mocker.GetMock().SetupGet(s => s.MetadataUseBanners).Returns(true); + Mocker.GetMock().SetupGet(s => s.MetadataUseBanners).Returns(true); } private void WithSpecials() diff --git a/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs index d0629f4f4..fd14cd274 100644 --- a/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs @@ -10,6 +10,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests { private void WithSingleClient() { - Mocker.GetMock().SetupGet(s => s.PlexClientHosts) + Mocker.GetMock().SetupGet(s => s.PlexClientHosts) .Returns("localhost:3000"); } private void WithMultipleClients() { - Mocker.GetMock().SetupGet(s => s.PlexClientHosts) + Mocker.GetMock().SetupGet(s => s.PlexClientHosts) .Returns("localhost:3000, 192.168.0.10:3000"); } public void WithClientCredentials() { - Mocker.GetMock().SetupGet(s => s.PlexUsername) + Mocker.GetMock().SetupGet(s => s.PlexUsername) .Returns("plex"); - Mocker.GetMock().SetupGet(s => s.PlexPassword) + Mocker.GetMock().SetupGet(s => s.PlexPassword) .Returns("plex"); } diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs index dd4255406..96765c1f1 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs @@ -10,6 +10,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests [SetUp] public void Setup() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(RecycleBin); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(RecycleBin); Mocker.GetMock().Setup(s => s.GetDirectories(RecycleBin)) .Returns(new [] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" }); @@ -61,7 +62,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests [Test] public void should_return_if_recycleBin_not_configured() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); Mocker.Resolve().Cleanup(); diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs index e4cd1fd3b..96fe0f0e1 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs @@ -10,6 +10,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { private void WithRecycleBin() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin"); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin"); } private void WithoutRecycleBin() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); } [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs index 5ac5c3378..5cb50516c 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs @@ -10,6 +10,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { private void WithRecycleBin() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin"); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin"); } private void WithoutRecycleBin() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); } [Test] diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs index 1835dda2a..a099b4efd 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs @@ -10,6 +10,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests [SetUp] public void Setup() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(RecycleBin); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(RecycleBin); Mocker.GetMock().Setup(s => s.GetDirectories(RecycleBin)) .Returns(new [] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" }); @@ -43,7 +44,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests [Test] public void should_return_if_recycleBin_not_configured() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(String.Empty); Mocker.Resolve().Empty(); diff --git a/NzbDrone.Core.Test/ProviderTests/ReferenceDataProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ReferenceDataProviderTest.cs index 644addfac..db4167277 100644 --- a/NzbDrone.Core.Test/ProviderTests/ReferenceDataProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/ReferenceDataProviderTest.cs @@ -6,10 +6,10 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests [SetUp] public void Setup() { - Mocker.GetMock().SetupGet(s => s.ServiceRootUrl) + Mocker.GetMock().SetupGet(s => s.ServiceRootUrl) .Returns("http://services.nzbdrone.com"); } diff --git a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs index 847a1e949..6273247c7 100644 --- a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs @@ -6,6 +6,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests [SetUp] public void Setup() { - Mocker.GetMock().SetupGet(s => s.ServiceRootUrl) + Mocker.GetMock().SetupGet(s => s.ServiceRootUrl) .Returns("http://services.nzbdrone.com"); WithRealDb(); diff --git a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs index f4cd2c542..c68ccadb7 100644 --- a/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/UpdateProviderTests/GetAvilableUpdateFixture.cs @@ -4,6 +4,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests { WithStrictMocker(); - Mocker.GetMock().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/"); + Mocker.GetMock().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/"); Mocker.Resolve(); } diff --git a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs index cb979f5b4..b2fc31659 100644 --- a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs @@ -7,6 +7,7 @@ using FluentAssertions; 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 @@ namespace NzbDrone.Core.Test.ProviderTests var header = "NzbDrone Test"; var message = "Test Message!"; - var fakeConfig = Mocker.GetMock(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080"); //var fakeUdpProvider = Mocker.GetMock(); @@ -440,7 +441,7 @@ namespace NzbDrone.Core.Test.ProviderTests //Setup WithStrictMocker(); - var fakeConfig = Mocker.GetMock(); + var fakeConfig = Mocker.GetMock(); fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080"); var fakeEventClient = Mocker.GetMock(); diff --git a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs index acfaa9618..e1c25ff44 100644 --- a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs @@ -7,6 +7,7 @@ using FizzWare.NBuilder; 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 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests WithRealDb(); Mocker.Resolve(); - Mocker.GetMock() + Mocker.GetMock() .Setup(e => e.DefaultQualityProfile).Returns(1); Db.Insert(Builder.CreateNew().Build()); diff --git a/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs b/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs index 657e399b5..d6f3acf59 100644 Binary files a/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs and b/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs differ diff --git a/NzbDrone.Core/Configuration/Config.cs b/NzbDrone.Core/Configuration/Config.cs new file mode 100644 index 000000000..8a561180d --- /dev/null +++ b/NzbDrone.Core/Configuration/Config.cs @@ -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; } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Configuration/ConfigRepository.cs b/NzbDrone.Core/Configuration/ConfigRepository.cs new file mode 100644 index 000000000..e2a559d41 --- /dev/null +++ b/NzbDrone.Core/Configuration/ConfigRepository.cs @@ -0,0 +1,27 @@ +using System.Linq; +using NzbDrone.Core.Datastore; + +namespace NzbDrone.Core.Configuration +{ + public interface IConfigRepository : IBasicRepository + { + Config Get(string key); + + } + + public class ConfigRepository : BasicRepository, IConfigRepository + { + public ConfigRepository(IObjectDatabase objectDatabase) + : base(objectDatabase) + { + } + + + public Config Get(string key) + { + return Queryable.SingleOrDefault(c => c.Key == key); + } + + + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Configuration/ConfigService.cs similarity index 93% rename from NzbDrone.Core/Providers/Core/ConfigProvider.cs rename to NzbDrone.Core/Configuration/ConfigService.cs index 8b8ee6f01..c92ac563b 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Configuration/ConfigService.cs @@ -5,31 +5,28 @@ using NLog; 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 _cache; - private static Dictionary cache = new Dictionary(); - private readonly IDatabase _database; - - public ConfigProvider(IDatabase database) + public ConfigService(IConfigRepository repository, Logger logger) { - _database = database; + _repository = repository; + _logger = logger; + _cache = new Dictionary(); } - public ConfigProvider() - { - } public IEnumerable All() { - return _database.Fetch(); + return _repository.All(); } public virtual String NzbsOrgUId @@ -619,14 +616,15 @@ namespace NzbDrone.Core.Providers.Core 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 @@ namespace NzbDrone.Core.Providers.Core 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("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 @@ namespace NzbDrone.Core.Providers.Core private void EnsureCache() { - lock (cache) + lock (_cache) { - if (!cache.Any()) + if (!_cache.Any()) { - cache = _database.Fetch().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(); + _cache = new Dictionary(); } } } diff --git a/NzbDrone.Core/Configuration/IConfigService.cs b/NzbDrone.Core/Configuration/IConfigService.cs new file mode 100644 index 000000000..7e30cbc29 --- /dev/null +++ b/NzbDrone.Core/Configuration/IConfigService.cs @@ -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 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); + } +} \ No newline at end of file diff --git a/NzbDrone.Core/DecisionEngine/AllowedReleaseGroupSpecification.cs b/NzbDrone.Core/DecisionEngine/AllowedReleaseGroupSpecification.cs index 1060dcb0e..4540ec870 100644 --- a/NzbDrone.Core/DecisionEngine/AllowedReleaseGroupSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/AllowedReleaseGroupSpecification.cs @@ -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 @@ namespace NzbDrone.Core.DecisionEngine { logger.Trace("Beginning release group check for: {0}", subject); - var allowed = _configProvider.AllowedReleaseGroups; + var allowed = _configService.AllowedReleaseGroups; if (string.IsNullOrWhiteSpace(allowed)) return true; diff --git a/NzbDrone.Core/DecisionEngine/LanguageSpecification.cs b/NzbDrone.Core/DecisionEngine/LanguageSpecification.cs index f20d8be81..4a4c5105b 100644 --- a/NzbDrone.Core/DecisionEngine/LanguageSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/LanguageSpecification.cs @@ -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() diff --git a/NzbDrone.Core/DecisionEngine/RetentionSpecification.cs b/NzbDrone.Core/DecisionEngine/RetentionSpecification.cs index 8f5d23517..8780101d4 100644 --- a/NzbDrone.Core/DecisionEngine/RetentionSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/RetentionSpecification.cs @@ -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 @@ namespace NzbDrone.Core.DecisionEngine 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; diff --git a/NzbDrone.Core/Indexers/FileSharingTalk.cs b/NzbDrone.Core/Indexers/FileSharingTalk.cs index 1d70dd8da..3cc9ed574 100644 --- a/NzbDrone.Core/Indexers/FileSharingTalk.cs +++ b/NzbDrone.Core/Indexers/FileSharingTalk.cs @@ -3,6 +3,7 @@ using System; 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 @@ namespace NzbDrone.Core.Indexers 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 @@ namespace NzbDrone.Core.Indexers { get { - return !string.IsNullOrWhiteSpace(_configProvider.FileSharingTalkUid) && - !string.IsNullOrWhiteSpace(_configProvider.FileSharingTalkSecret); + return !string.IsNullOrWhiteSpace(_configService.FileSharingTalkUid) && + !string.IsNullOrWhiteSpace(_configService.FileSharingTalkSecret); } } diff --git a/NzbDrone.Core/Indexers/IndexerBase.cs b/NzbDrone.Core/Indexers/IndexerBase.cs index 25cd7572f..0777bedb7 100644 --- a/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/NzbDrone.Core/Indexers/IndexerBase.cs @@ -6,6 +6,7 @@ using System.ServiceModel.Syndication; 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 @@ namespace NzbDrone.Core.Indexers { 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()); } diff --git a/NzbDrone.Core/Indexers/Newznab.cs b/NzbDrone.Core/Indexers/Newznab.cs index 55f215873..9485899ae 100644 --- a/NzbDrone.Core/Indexers/Newznab.cs +++ b/NzbDrone.Core/Indexers/Newznab.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; 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 @@ namespace NzbDrone.Core.Indexers { 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; } diff --git a/NzbDrone.Core/Indexers/NzbClub.cs b/NzbDrone.Core/Indexers/NzbClub.cs index 977b5898d..1c22fc132 100644 --- a/NzbDrone.Core/Indexers/NzbClub.cs +++ b/NzbDrone.Core/Indexers/NzbClub.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; 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) { } diff --git a/NzbDrone.Core/Indexers/NzbIndex.cs b/NzbDrone.Core/Indexers/NzbIndex.cs index cd835ba4b..027cc8205 100644 --- a/NzbDrone.Core/Indexers/NzbIndex.cs +++ b/NzbDrone.Core/Indexers/NzbIndex.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; 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) { } diff --git a/NzbDrone.Core/Indexers/NzbsRUs.cs b/NzbDrone.Core/Indexers/NzbsRUs.cs index f0054af8f..80b89bb2c 100644 --- a/NzbDrone.Core/Indexers/NzbsRUs.cs +++ b/NzbDrone.Core/Indexers/NzbsRUs.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; 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 @@ namespace NzbDrone.Core.Indexers { 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 @@ namespace NzbDrone.Core.Indexers { get { - return !string.IsNullOrWhiteSpace(_configProvider.NzbsrusUId) && - !string.IsNullOrWhiteSpace(_configProvider.NzbsrusHash); + return !string.IsNullOrWhiteSpace(_configService.NzbsrusUId) && + !string.IsNullOrWhiteSpace(_configService.NzbsrusHash); } } diff --git a/NzbDrone.Core/Indexers/Nzbx.cs b/NzbDrone.Core/Indexers/Nzbx.cs index eeb84fe17..72fb59a32 100644 --- a/NzbDrone.Core/Indexers/Nzbx.cs +++ b/NzbDrone.Core/Indexers/Nzbx.cs @@ -5,6 +5,7 @@ using System.Net; 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) { } diff --git a/NzbDrone.Core/Indexers/Omgwtfnzbs.cs b/NzbDrone.Core/Indexers/Omgwtfnzbs.cs index d78548c73..ad66101a6 100644 --- a/NzbDrone.Core/Indexers/Omgwtfnzbs.cs +++ b/NzbDrone.Core/Indexers/Omgwtfnzbs.cs @@ -4,6 +4,7 @@ using System.Linq; 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 @@ namespace NzbDrone.Core.Indexers 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 @@ namespace NzbDrone.Core.Indexers { get { - return !string.IsNullOrWhiteSpace(_configProvider.OmgwtfnzbsUsername) && - !string.IsNullOrWhiteSpace(_configProvider.OmgwtfnzbsApiKey); + return !string.IsNullOrWhiteSpace(_configService.OmgwtfnzbsUsername) && + !string.IsNullOrWhiteSpace(_configService.OmgwtfnzbsApiKey); } } diff --git a/NzbDrone.Core/Indexers/Wombles.cs b/NzbDrone.Core/Indexers/Wombles.cs index 3665c8461..9e29fb05e 100644 --- a/NzbDrone.Core/Indexers/Wombles.cs +++ b/NzbDrone.Core/Indexers/Wombles.cs @@ -3,6 +3,7 @@ using System; 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) { } diff --git a/NzbDrone.Core/Jobs/BacklogSearchJob.cs b/NzbDrone.Core/Jobs/BacklogSearchJob.cs index 2103c71e2..d6a12927d 100644 --- a/NzbDrone.Core/Jobs/BacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/BacklogSearchJob.cs @@ -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 @@ namespace NzbDrone.Core.Jobs 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 @@ namespace NzbDrone.Core.Jobs public List 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 => diff --git a/NzbDrone.Core/Jobs/DiskScanJob.cs b/NzbDrone.Core/Jobs/DiskScanJob.cs index 0842c4976..87f2a4b98 100644 --- a/NzbDrone.Core/Jobs/DiskScanJob.cs +++ b/NzbDrone.Core/Jobs/DiskScanJob.cs @@ -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 @@ namespace NzbDrone.Core.Jobs { 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 @@ namespace NzbDrone.Core.Jobs IList seriesToScan; if (options == null || options.SeriesId == 0) { - if (_configProvider.IgnoreArticlesWhenSortingSeries) + if (_configService.IgnoreArticlesWhenSortingSeries) seriesToScan = _seriesRepository.All().OrderBy(o => o.Title.IgnoreArticles()).ToList(); else diff --git a/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs b/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs index a0944770b..cb54b4b39 100644 --- a/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs @@ -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 @@ namespace NzbDrone.Core.Jobs { 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 diff --git a/NzbDrone.Core/Jobs/PostDownloadScanJob.cs b/NzbDrone.Core/Jobs/PostDownloadScanJob.cs index bbaf7e54d..43879a5e4 100644 --- a/NzbDrone.Core/Jobs/PostDownloadScanJob.cs +++ b/NzbDrone.Core/Jobs/PostDownloadScanJob.cs @@ -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 @@ namespace NzbDrone.Core.Jobs 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 @@ namespace NzbDrone.Core.Jobs dropFolder = options.Path; else - dropFolder = _configProvider.DownloadClientTvDirectory; + dropFolder = _configService.DownloadClientTvDirectory; if (String.IsNullOrWhiteSpace(dropFolder)) { diff --git a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs index e5fad085e..097fc104b 100644 --- a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs @@ -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 @@ namespace NzbDrone.Core.Jobs { 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 @@ namespace NzbDrone.Core.Jobs public List 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 => diff --git a/NzbDrone.Core/Jobs/RssSyncJob.cs b/NzbDrone.Core/Jobs/RssSyncJob.cs index 935c30e0a..fd7f4bc18 100644 --- a/NzbDrone.Core/Jobs/RssSyncJob.cs +++ b/NzbDrone.Core/Jobs/RssSyncJob.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; 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 @@ namespace NzbDrone.Core.Jobs 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 @@ namespace NzbDrone.Core.Jobs public TimeSpan DefaultInterval { - get { return TimeSpan.FromMinutes(_configProvider.RssSyncInterval); } + get { return TimeSpan.FromMinutes(_configService.RssSyncInterval); } } public void Start(ProgressNotification notification, dynamic options) diff --git a/NzbDrone.Core/Jobs/UpdateInfoJob.cs b/NzbDrone.Core/Jobs/UpdateInfoJob.cs index 3332c141d..3a3bc55b1 100644 --- a/NzbDrone.Core/Jobs/UpdateInfoJob.cs +++ b/NzbDrone.Core/Jobs/UpdateInfoJob.cs @@ -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 @@ namespace NzbDrone.Core.Jobs 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 @@ namespace NzbDrone.Core.Jobs IList seriesToUpdate; if (options == null || options.SeriesId == 0) { - if (_configProvider.IgnoreArticlesWhenSortingSeries) + if (_configService.IgnoreArticlesWhenSortingSeries) seriesToUpdate = _seriesRepository.All().OrderBy(o => o.Title.IgnoreArticles()).ToList(); else diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index caf87d835..f5fee3620 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -214,6 +214,9 @@ Properties\SharedAssemblyInfo.cs + + + @@ -406,7 +409,7 @@ Code - + Code @@ -589,7 +592,6 @@ - diff --git a/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs b/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs index f33fd9562..44f51c974 100644 --- a/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs +++ b/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs @@ -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 @@ namespace NzbDrone.Core.Providers.Converting { 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); diff --git a/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs b/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs index ac3c84d2b..1a70628b5 100644 --- a/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs +++ b/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs @@ -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 @@ namespace NzbDrone.Core.Providers.Converting 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 @@ namespace NzbDrone.Core.Providers.Converting _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"; diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/DiskScanProvider.cs index 261f9964e..02713490d 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/DiskScanProvider.cs @@ -4,6 +4,7 @@ using System.IO; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers _externalNotificationProvider = externalNotificationProvider; _downloadProvider = downloadProvider; _signalRProvider = signalRProvider; - _configProvider = configProvider; + _configService = configService; _recycleBinProvider = recycleBinProvider; _mediaInfoProvider = mediaInfoProvider; _seriesRepository = seriesRepository; @@ -270,7 +271,7 @@ namespace NzbDrone.Core.Providers { 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); diff --git a/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs b/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs index d22ee5fb3..1e8c12a6b 100644 --- a/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs +++ b/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs @@ -3,6 +3,7 @@ using System.IO; 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 @@ namespace NzbDrone.Core.Providers.DownloadClients 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 @@ namespace NzbDrone.Core.Providers.DownloadClients { title = MediaFileProvider.CleanFilename(title); - var filename = Path.Combine(_configProvider.BlackholeDirectory, title + ".nzb"); + var filename = Path.Combine(_configService.BlackholeDirectory, title + ".nzb"); if (_diskProvider.FileExists(filename)) { diff --git a/NzbDrone.Core/Providers/DownloadClients/NzbgetProvider.cs b/NzbDrone.Core/Providers/DownloadClients/NzbgetProvider.cs index 5347a73e0..f12c8a59a 100644 --- a/NzbDrone.Core/Providers/DownloadClients/NzbgetProvider.cs +++ b/NzbDrone.Core/Providers/DownloadClients/NzbgetProvider.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; 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 @@ namespace NzbDrone.Core.Providers.DownloadClients { 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 @@ namespace NzbDrone.Core.Providers.DownloadClients { //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 @@ namespace NzbDrone.Core.Providers.DownloadClients 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) diff --git a/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs b/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs index e62e11311..59a7d7697 100644 --- a/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs +++ b/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs @@ -3,6 +3,7 @@ using System.IO; 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 @@ namespace NzbDrone.Core.Providers.DownloadClients 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 @@ namespace NzbDrone.Core.Providers.DownloadClients 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; } diff --git a/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs b/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs index d7c74502c..7a5095331 100644 --- a/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs +++ b/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; 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 @@ namespace NzbDrone.Core.Providers.DownloadClients { 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 @@ namespace NzbDrone.Core.Providers.DownloadClients { //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 @@ namespace NzbDrone.Core.Providers.DownloadClients { //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 @@ namespace NzbDrone.Core.Providers.DownloadClients 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) diff --git a/NzbDrone.Core/Providers/DownloadProvider.cs b/NzbDrone.Core/Providers/DownloadProvider.cs index 03e7aea0a..cd9b5ac02 100644 --- a/NzbDrone.Core/Providers/DownloadProvider.cs +++ b/NzbDrone.Core/Providers/DownloadProvider.cs @@ -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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers _historyService = historyService; _episodeService = episodeService; _externalNotificationProvider = externalNotificationProvider; - _configProvider = configProvider; + _configService = configService; _blackholeProvider = blackholeProvider; _signalRProvider = signalRProvider; _pneumaticProvider = pneumaticProvider; @@ -85,7 +86,7 @@ namespace NzbDrone.Core.Providers public virtual IDownloadClient GetActiveDownloadClient() { - switch (_configProvider.DownloadClient) + switch (_configService.DownloadClient) { case DownloadClientType.Blackhole: return _blackholeProvider; @@ -103,7 +104,7 @@ namespace NzbDrone.Core.Providers public virtual String GetDownloadTitle(EpisodeParseResult parseResult) { - if(_configProvider.DownloadClientUseSceneName) + if(_configService.DownloadClientUseSceneName) { logger.Trace("Using scene name: {0}", parseResult.OriginalString); return parseResult.OriginalString; diff --git a/NzbDrone.Core/Providers/ExternalNotification/ExternalNotificationBase.cs b/NzbDrone.Core/Providers/ExternalNotification/ExternalNotificationBase.cs index c8a1433d3..a5ff34a1a 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/ExternalNotificationBase.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/ExternalNotificationBase.cs @@ -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()); } diff --git a/NzbDrone.Core/Providers/ExternalNotification/Growl.cs b/NzbDrone.Core/Providers/ExternalNotification/Growl.cs index 676565ce4..a3af9d79d 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/Growl.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/Growl.cs @@ -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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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); } } diff --git a/NzbDrone.Core/Providers/ExternalNotification/Plex.cs b/NzbDrone.Core/Providers/ExternalNotification/Plex.cs index 19f66cdaf..cfba4a919 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/Plex.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/Plex.cs @@ -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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification private void UpdateIfEnabled() { - if (_configProvider.PlexUpdateLibrary) + if (_configService.PlexUpdateLibrary) { _logger.Trace("Sending Update Request to Plex Server"); _plexProvider.UpdateLibrary(); diff --git a/NzbDrone.Core/Providers/ExternalNotification/Prowl.cs b/NzbDrone.Core/Providers/ExternalNotification/Prowl.cs index 23fbac45e..239e2b674 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/Prowl.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/Prowl.cs @@ -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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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); } diff --git a/NzbDrone.Core/Providers/ExternalNotification/Smtp.cs b/NzbDrone.Core/Providers/ExternalNotification/Smtp.cs index 098db8695..2813b67d7 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/Smtp.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/Smtp.cs @@ -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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification 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); diff --git a/NzbDrone.Core/Providers/ExternalNotification/Twitter.cs b/NzbDrone.Core/Providers/ExternalNotification/Twitter.cs index 0591fdc5c..9fa75713c 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/Twitter.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/Twitter.cs @@ -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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification 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); diff --git a/NzbDrone.Core/Providers/ExternalNotification/Xbmc.cs b/NzbDrone.Core/Providers/ExternalNotification/Xbmc.cs index f9037193c..97cb4a99f 100644 --- a/NzbDrone.Core/Providers/ExternalNotification/Xbmc.cs +++ b/NzbDrone.Core/Providers/ExternalNotification/Xbmc.cs @@ -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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification { 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 @@ namespace NzbDrone.Core.Providers.ExternalNotification 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(); diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index bfc7d5499..5600b3d83 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers string updateString = "UPDATE Episodes SET EpisodeFileId = 0, GrabDate = NULL, PostDownloadStatus = 0"; - if (_configProvider.AutoIgnorePreviouslyDownloadedEpisodes) + if (_configService.AutoIgnorePreviouslyDownloadedEpisodes) { updateString += ", Ignored = 1"; } @@ -143,7 +144,7 @@ namespace NzbDrone.Core.Providers public virtual string GetNewFilename(IList 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 @@ namespace NzbDrone.Core.Providers 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(); @@ -168,7 +169,7 @@ namespace NzbDrone.Core.Providers string result = String.Empty; - if (_configProvider.SortingIncludeSeriesName) + if (_configService.SortingIncludeSeriesName) { result += series.Title + separatorStyle.Pattern; } @@ -181,7 +182,7 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers result += "Unknown"; } - if (_configProvider.SortingIncludeEpisodeTitle) + if (_configService.SortingIncludeEpisodeTitle) { if (episodeNames.Distinct().Count() == 1) result += separatorStyle.Pattern + episodeNames.First(); @@ -224,7 +225,7 @@ namespace NzbDrone.Core.Providers result += separatorStyle.Pattern + String.Join(" + ", episodeNames.Distinct()); } - if (_configProvider.SortingAppendQuality) + if (_configService.SortingAppendQuality) { result += String.Format(" [{0}]", quality); @@ -232,7 +233,7 @@ namespace NzbDrone.Core.Providers result += " [Proper]"; } - if (_configProvider.SortingReplaceSpaces) + if (_configService.SortingReplaceSpaces) result = result.Replace(' ', '.'); Logger.Trace("New File Name is: [{0}]", result.Trim()); diff --git a/NzbDrone.Core/Providers/Metadata/MetadataBase.cs b/NzbDrone.Core/Providers/Metadata/MetadataBase.cs index ee643d78c..205e88a44 100644 --- a/NzbDrone.Core/Providers/Metadata/MetadataBase.cs +++ b/NzbDrone.Core/Providers/Metadata/MetadataBase.cs @@ -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; diff --git a/NzbDrone.Core/Providers/Metadata/Xbmc.cs b/NzbDrone.Core/Providers/Metadata/Xbmc.cs index 48efbc15a..7bf51fc35 100644 --- a/NzbDrone.Core/Providers/Metadata/Xbmc.cs +++ b/NzbDrone.Core/Providers/Metadata/Xbmc.cs @@ -5,6 +5,7 @@ using System.Text; 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 @@ namespace NzbDrone.Core.Providers.Metadata if (!_diskProvider.FileExists(Path.Combine(series.Path, "folder.jpg"))) { - if(_configProvider.MetadataUseBanners) + if(_configService.MetadataUseBanners) { if(!String.IsNullOrWhiteSpace(tvDbSeries.BannerPath)) { diff --git a/NzbDrone.Core/Providers/PlexProvider.cs b/NzbDrone.Core/Providers/PlexProvider.cs index 64c748bb8..41cef0c52 100644 --- a/NzbDrone.Core/Providers/PlexProvider.cs +++ b/NzbDrone.Core/Providers/PlexProvider.cs @@ -6,6 +6,7 @@ using System.Text; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers public virtual void UpdateLibrary() { - var host = _configProvider.PlexServerHost; + var host = _configService.PlexServerHost; try { @@ -98,7 +99,7 @@ namespace NzbDrone.Core.Providers { 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); } } } diff --git a/NzbDrone.Core/Providers/RecycleBinProvider.cs b/NzbDrone.Core/Providers/RecycleBinProvider.cs index 3d1bd4757..2798365b0 100644 --- a/NzbDrone.Core/Providers/RecycleBinProvider.cs +++ b/NzbDrone.Core/Providers/RecycleBinProvider.cs @@ -5,6 +5,7 @@ using System.Linq; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers _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) { diff --git a/NzbDrone.Core/Providers/ReferenceDataProvider.cs b/NzbDrone.Core/Providers/ReferenceDataProvider.cs index b4bc5f800..716f0874f 100644 --- a/NzbDrone.Core/Providers/ReferenceDataProvider.cs +++ b/NzbDrone.Core/Providers/ReferenceDataProvider.cs @@ -6,6 +6,7 @@ using System.Text; 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 @@ namespace NzbDrone.Core.Providers { 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 @@ namespace NzbDrone.Core.Providers { try { - var dailySeriesIds = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/DailySeries/AllIds"); + var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds"); var seriesIds = JsonConvert.DeserializeObject>(dailySeriesIds); diff --git a/NzbDrone.Core/Providers/SceneMappingProvider.cs b/NzbDrone.Core/Providers/SceneMappingProvider.cs index e45282a52..4c99ca879 100644 --- a/NzbDrone.Core/Providers/SceneMappingProvider.cs +++ b/NzbDrone.Core/Providers/SceneMappingProvider.cs @@ -4,6 +4,7 @@ using System.IO; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers { try { - var mappingsJson = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/SceneMapping/Active"); + var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active"); var mappings = JsonConvert.DeserializeObject>(mappingsJson); Logger.Debug("Deleting all existing Scene Mappings."); @@ -92,7 +93,7 @@ namespace NzbDrone.Core.Providers 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(response).Equals("Ok")) return true; diff --git a/NzbDrone.Core/Providers/SmtpProvider.cs b/NzbDrone.Core/Providers/SmtpProvider.cs index b589327d4..d7c0035a6 100644 --- a/NzbDrone.Core/Providers/SmtpProvider.cs +++ b/NzbDrone.Core/Providers/SmtpProvider.cs @@ -5,6 +5,7 @@ using System.Net; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers //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) { diff --git a/NzbDrone.Core/Providers/TwitterProvider.cs b/NzbDrone.Core/Providers/TwitterProvider.cs index 22851a271..81c920e34 100644 --- a/NzbDrone.Core/Providers/TwitterProvider.cs +++ b/NzbDrone.Core/Providers/TwitterProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers { 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)) diff --git a/NzbDrone.Core/Providers/UpdateProvider.cs b/NzbDrone.Core/Providers/UpdateProvider.cs index a42fffa6c..3996c2ede 100644 --- a/NzbDrone.Core/Providers/UpdateProvider.cs +++ b/NzbDrone.Core/Providers/UpdateProvider.cs @@ -7,6 +7,7 @@ using System.Linq; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers private List GetAvailablePackages() { var updateList = new List(); - var updateUrl = _configProvider.UpdateUrl; + var updateUrl = _configService.UpdateUrl; var rawUpdateList = _httpProvider.DownloadString(updateUrl); var matches = parseRegex.Matches(rawUpdateList); diff --git a/NzbDrone.Core/Providers/XbmcProvider.cs b/NzbDrone.Core/Providers/XbmcProvider.cs index bee174805..e94200971 100644 --- a/NzbDrone.Core/Providers/XbmcProvider.cs +++ b/NzbDrone.Core/Providers/XbmcProvider.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers //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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers 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 @@ namespace NzbDrone.Core.Providers { //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))"; diff --git a/NzbDrone.Core/ReferenceData/DailySeriesService.cs b/NzbDrone.Core/ReferenceData/DailySeriesService.cs new file mode 100644 index 000000000..6ae76cec6 --- /dev/null +++ b/NzbDrone.Core/ReferenceData/DailySeriesService.cs @@ -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 GetDailySeriesIds() + { + try + { + var dailySeriesIds = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/DailySeries/AllIds"); + + var seriesIds = JsonConvert.DeserializeObject>(dailySeriesIds); + + return seriesIds; + } + catch (Exception ex) + { + Logger.WarnException("Failed to get Daily Series", ex); + return new List(); + } + + } + } +} diff --git a/NzbDrone.Core/Repository/Config.cs b/NzbDrone.Core/Repository/Config.cs deleted file mode 100644 index 2f351e61a..000000000 --- a/NzbDrone.Core/Repository/Config.cs +++ /dev/null @@ -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; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index 2a727b26f..92bfc6f7e 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -5,6 +5,7 @@ using System.Text.RegularExpressions; 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 @@ namespace NzbDrone.Core.Tv 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 @@ namespace NzbDrone.Core.Tv 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 @@ namespace NzbDrone.Core.Tv 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)