diff --git a/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs b/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs new file mode 100644 index 000000000..a4398f3a4 --- /dev/null +++ b/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs @@ -0,0 +1,61 @@ +using System.Net; +using FluentAssertions; +using NUnit.Framework; +using Newtonsoft.Json; +using NzbDrone.Common; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.DataAugmentation.Scene; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.DataAugmentationFixture.Scene +{ + [TestFixture] + + public class SceneMappingProxyFixture : CoreTest + { + private const string SCENE_MAPPING_URL = "http://services.nzbdrone.com/SceneMapping/Active"; + + [SetUp] + public void Setup() + { + Mocker.GetMock().SetupGet(s => s.ServiceRootUrl) + .Returns("http://services.nzbdrone.com"); + + } + + [Test] + public void fetch_should_return_list_of_mappings() + { + Mocker.GetMock() + .Setup(s => s.DownloadString(SCENE_MAPPING_URL)) + .Returns(ReadAllText("Files", "SceneMappings.json")); + + var mappings = Subject.Fetch(); + + mappings.Should().NotBeEmpty(); + + mappings.Should().NotContain(c => string.IsNullOrWhiteSpace(c.CleanTitle)); + mappings.Should().NotContain(c => string.IsNullOrWhiteSpace(c.SceneName)); + mappings.Should().NotContain(c => c.TvdbId == 0); + } + + + [Test] + public void should_throw_on_server_error() + { + Mocker.GetMock() + .Setup(s => s.DownloadString(SCENE_MAPPING_URL)) + .Throws(new WebException()); + Assert.Throws(() => Subject.Fetch()); + } + + [Test] + public void should_throw_on_bad_json() + { + Mocker.GetMock() + .Setup(s => s.DownloadString(SCENE_MAPPING_URL)) + .Returns("bad json"); + Assert.Throws(() => Subject.Fetch()); + } + } +} diff --git a/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingServiceFixture.cs b/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingServiceFixture.cs new file mode 100644 index 000000000..7509d08c2 --- /dev/null +++ b/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingServiceFixture.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; +using System.Net; +using FizzWare.NBuilder; +using Moq; +using NUnit.Framework; +using NzbDrone.Core.DataAugmentation.Scene; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.DataAugmentationFixture.Scene +{ + [TestFixture] + + public class SceneMappingServiceFixture : DbTest + { + + private List _fakeMappings; + + [SetUp] + public void Setup() + { + _fakeMappings = Builder.CreateListOfSize(5).BuildListOfNew(); + } + + + + [Test] + public void UpdateMappings_purge_existing_mapping_and_add_new_ones() + { + Mocker.GetMock().Setup(c => c.Fetch()).Returns(_fakeMappings); + + Subject.UpdateMappings(); + + AssertMappingUpdated(); + } + + + + [Test] + public void UpdateMappings_should_not_delete_if_fetch_fails() + { + + Mocker.GetMock().Setup(c => c.Fetch()).Throws(new WebException()); + + Subject.UpdateMappings(); + + AssertNoUpdate(); + + ExceptionVerification.ExpectedErrors(1); + + } + + [Test] + public void UpdateMappings_should_not_delete_if_fetch_returns_empty_list() + { + + Mocker.GetMock().Setup(c => c.Fetch()).Returns(new List()); + + Subject.UpdateMappings(); + + AssertNoUpdate(); + + ExceptionVerification.ExpectedWarns(1); + } + + private void AssertNoUpdate() + { + Mocker.GetMock().Verify(c => c.Fetch(), Times.Once()); + Mocker.GetMock().Verify(c => c.Purge(), Times.Never()); + Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Never()); + } + + private void AssertMappingUpdated() + { + Mocker.GetMock().Verify(c => c.Fetch(), Times.Once()); + Mocker.GetMock().Verify(c => c.Purge(), Times.Once()); + Mocker.GetMock().Verify(c => c.InsertMany(_fakeMappings), Times.Once()); + } + + } +} diff --git a/NzbDrone.Core.Test/Framework/NBuilderExtensions.cs b/NzbDrone.Core.Test/Framework/NBuilderExtensions.cs index 197cb3310..338e73302 100644 --- a/NzbDrone.Core.Test/Framework/NBuilderExtensions.cs +++ b/NzbDrone.Core.Test/Framework/NBuilderExtensions.cs @@ -12,12 +12,12 @@ namespace NzbDrone.Core.Test.Framework return builder.With(c => c.Id = 0).Build(); } - public static List BuildList(this IOperable builder) where T : ModelBase, new() + public static List BuildList(this IListBuilder builder) where T : ModelBase, new() { return builder.Build().ToList(); } - public static List BuildListOfNew(this IOperable builder) where T : ModelBase, new() + public static List BuildListOfNew(this IListBuilder builder) where T : ModelBase, new() { return BuildList(builder.All().With(c => c.Id = 0)); } diff --git a/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs b/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs index 0a40b2b68..76f0e2f70 100644 --- a/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/GetSearchTitleFixture.cs @@ -1,7 +1,8 @@ using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Core.ReferenceData; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; diff --git a/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs b/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs index 4a4f33f1c..c7349614c 100644 --- a/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs +++ b/NzbDrone.Core.Test/IndexerSearchTests/TestSearch.cs @@ -3,12 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using NLog; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Test.IndexerSearchTests diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index e02b20f08..1e35c6cbb 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -129,6 +129,8 @@ + + @@ -239,7 +241,6 @@ - diff --git a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs deleted file mode 100644 index e1afb1f0b..000000000 --- a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs +++ /dev/null @@ -1,230 +0,0 @@ -using System.Linq; -using System.IO; -using System.Net; -using FizzWare.NBuilder; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Common; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.ReferenceData; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.Test.TvTests; -using NzbDrone.Test.Common; - -namespace NzbDrone.Core.Test.ProviderTests -{ - [TestFixture] - - public class SceneMappingProviderTest : DbTest - { - private const string SceneMappingUrl = "http://services.nzbdrone.com/SceneMapping/Active"; - - [SetUp] - public void Setup() - { - Mocker.GetMock().SetupGet(s => s.ServiceRootUrl) - .Returns("http://services.nzbdrone.com"); - - } - - private void WithValidJson() - { - Mocker.GetMock() - .Setup(s => s.DownloadString(SceneMappingUrl)) - .Returns(ReadAllText("Files", "SceneMappings.json")); - } - - private void WithErrorDownloadingJson() - { - Mocker.GetMock() - .Setup(s => s.DownloadString(SceneMappingUrl)) - .Throws(new WebException()); - } - - [Test] - public void GetSceneName_exists() - { - - - var fakeMap = Builder.CreateNew() - .With(f => f.CleanTitle = "laworder") - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "Law and Order") - .With(f => f.SeasonNumber = -1) - .BuildNew(); - - Db.Insert(fakeMap); - - - var sceneName = Mocker.Resolve().GetSceneName(fakeMap.TvdbId); - - - Assert.AreEqual(fakeMap.SceneName, sceneName); - } - - [Test] - public void GetSeriesId_exists() - { - - - var fakeMap = Builder.CreateNew() - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "Law and Order") - .With(f => f.SceneName = "laworder") - .Build(); - - - Db.Insert(fakeMap); - - - var seriesId = Mocker.Resolve().GetTvDbId(fakeMap.CleanTitle); - - - Assert.AreEqual(fakeMap.TvdbId, seriesId); - } - - [Test] - public void GetSceneName_null() - { - - - var fakeMap = Builder.CreateNew() - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "Law and Order") - .With(f => f.SceneName = "laworder") - .Build(); - - - Db.Insert(fakeMap); - - - var sceneName = Mocker.Resolve().GetSceneName(54321); - - - Assert.AreEqual(null, sceneName); - } - - [Test] - public void GetSeriesId_null() - { - - - var fakeMap = Builder.CreateNew() - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "Law and Order") - .With(f => f.CleanTitle = "laworder") - .Build(); - - Db.Insert(fakeMap); - - - var seriesId = Mocker.Resolve().GetTvDbId("notlaworder"); - - - Assert.AreEqual(null, seriesId); - } - - [Test] - public void GetSceneName_multiple_clean_names() - { - //Test that ensures a series with clean names (office, officeus) can be looked up by seriesId - - - var fakeMap = Builder.CreateNew() - .With(f => f.CleanTitle = "office") - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "The Office") - .With(f => f.SeasonNumber = -1) - .Build(); - - var fakeMap2 = Builder.CreateNew() - .With(f => f.CleanTitle = "officeus") - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "The Office") - .With(f => f.SeasonNumber = -1) - .Build(); - - - - Db.Insert(fakeMap); - Db.Insert(fakeMap2); - - - var sceneName = Mocker.Resolve().GetSceneName(fakeMap.TvdbId); - - - Assert.AreEqual(fakeMap.SceneName, sceneName); - } - - [Test] - public void GetSceneName_should_be_null_when_seasonNumber_does_not_match() - { - - - var fakeMap = Builder.CreateNew() - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "Law and Order") - .With(f => f.SceneName = "laworder") - .With(f => f.SeasonNumber = 10) - .Build(); - - Db.Insert(fakeMap); - - Mocker.Resolve().GetSceneName(54321, 5).Should().BeNull(); - } - - [Test] - public void UpdateMappings_should_add_all_mappings_to_database() - { - WithValidJson(); - - - Mocker.Resolve().UpdateMappings(); - - - Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once()); - } - - [Test] - public void UpdateMappings_should_overwrite_existing_mappings() - { - - var fakeMap = Builder.CreateNew() - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "Law and Order") - .With(f => f.SceneName = "laworder") - .Build(); - - WithValidJson(); - Db.Insert(fakeMap); - - - Mocker.Resolve().UpdateMappings(); - - - Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once()); - } - - [Test] - public void UpdateMappings_should_not_delete_if_csv_download_fails() - { - - var fakeMap = Builder.CreateNew() - .With(f => f.TvdbId = 12345) - .With(f => f.SceneName = "Law and Order") - .With(f => f.SceneName = "laworder") - .Build(); - - WithErrorDownloadingJson(); - Db.Insert(fakeMap); - - - Mocker.Resolve().UpdateMappings(); - - - Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once()); - } - - } -} diff --git a/NzbDrone.Core/ReferenceData/DailySeriesDataProxy.cs b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs similarity index 95% rename from NzbDrone.Core/ReferenceData/DailySeriesDataProxy.cs rename to NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs index 10dc9888f..7069fb466 100644 --- a/NzbDrone.Core/ReferenceData/DailySeriesDataProxy.cs +++ b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs @@ -1,12 +1,11 @@ using System; using System.Collections.Generic; -using System.Linq; using NLog; using Newtonsoft.Json; using NzbDrone.Common; using NzbDrone.Core.Configuration; -namespace NzbDrone.Core.ReferenceData +namespace NzbDrone.Core.DataAugmentation.DailySeries { public interface IDailySeriesDataProxy diff --git a/NzbDrone.Core/ReferenceData/DailySeriesService.cs b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs similarity index 92% rename from NzbDrone.Core/ReferenceData/DailySeriesService.cs rename to NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs index 7fa9c26ad..1992a94dd 100644 --- a/NzbDrone.Core/ReferenceData/DailySeriesService.cs +++ b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesService.cs @@ -1,7 +1,6 @@ -using System.Linq; using NzbDrone.Core.Tv; -namespace NzbDrone.Core.ReferenceData +namespace NzbDrone.Core.DataAugmentation.DailySeries { public class DailySeriesService { diff --git a/NzbDrone.Core/ReferenceData/SceneMapping.cs b/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs similarity index 85% rename from NzbDrone.Core/ReferenceData/SceneMapping.cs rename to NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs index 8030bfef6..9c846de37 100644 --- a/NzbDrone.Core/ReferenceData/SceneMapping.cs +++ b/NzbDrone.Core/DataAugmentation/Scene/SceneMapping.cs @@ -1,8 +1,7 @@ -using System.Linq; using Newtonsoft.Json; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.ReferenceData +namespace NzbDrone.Core.DataAugmentation.Scene { public class SceneMapping : ModelBase { diff --git a/NzbDrone.Core/ReferenceData/SceneMappingProvider.cs b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProvider.cs similarity index 76% rename from NzbDrone.Core/ReferenceData/SceneMappingProvider.cs rename to NzbDrone.Core/DataAugmentation/Scene/SceneMappingProvider.cs index abac0e5a0..ca987fc5c 100644 --- a/NzbDrone.Core/ReferenceData/SceneMappingProvider.cs +++ b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProvider.cs @@ -1,15 +1,15 @@ -using System.Linq; using System; +using System.Linq; using NLog; using NzbDrone.Core.Lifecycle; -namespace NzbDrone.Core.ReferenceData +namespace NzbDrone.Core.DataAugmentation.Scene { public interface ISceneMappingService { void UpdateMappings(); string GetSceneName(int tvdbId, int seasonNumber = -1); - Nullable GetTvDbId(string cleanName); + Nullable GetTvDbId(string cleanName); string GetCleanName(int tvdbId); } @@ -32,12 +32,19 @@ namespace NzbDrone.Core.ReferenceData { var mappings = _sceneMappingProxy.Fetch(); - _repository.Purge(); - _repository.InsertMany(mappings); + if (mappings.Any()) + { + _repository.Purge(); + _repository.InsertMany(mappings); + } + else + { + _logger.Warn("Received empty list of mapping. will not update."); + } } catch (Exception ex) { - _logger.InfoException("Failed to Update Scene Mappings:", ex); + _logger.ErrorException("Failed to Update Scene Mappings:", ex); } } @@ -45,7 +52,7 @@ namespace NzbDrone.Core.ReferenceData { var mapping = _repository.FindByTvdbId(tvdbId); - if(mapping == null) return null; + if (mapping == null) return null; return mapping.SceneName; } diff --git a/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs new file mode 100644 index 000000000..601175deb --- /dev/null +++ b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using NzbDrone.Common; +using NzbDrone.Core.Configuration; + +namespace NzbDrone.Core.DataAugmentation.Scene +{ + public interface ISceneMappingProxy + { + List Fetch(); + } + + public class SceneMappingProxy : ISceneMappingProxy + { + private readonly HttpProvider _httpProvider; + private readonly IConfigService _configService; + + public SceneMappingProxy(HttpProvider httpProvider, IConfigService configService) + { + _httpProvider = httpProvider; + _configService = configService; + } + + public List Fetch() + { + var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active"); + return JsonConvert.DeserializeObject>(mappingsJson); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/ReferenceData/SceneMappingRepository.cs b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs similarity index 92% rename from NzbDrone.Core/ReferenceData/SceneMappingRepository.cs rename to NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs index 164d98993..1bc2fd21d 100644 --- a/NzbDrone.Core/ReferenceData/SceneMappingRepository.cs +++ b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingRepository.cs @@ -1,8 +1,7 @@ -using System.Data; using System.Linq; using NzbDrone.Core.Datastore; -namespace NzbDrone.Core.ReferenceData +namespace NzbDrone.Core.DataAugmentation.Scene { public interface ISceneMappingRepository : IBasicRepository { diff --git a/NzbDrone.Core/Datastore/TableMapping.cs b/NzbDrone.Core/Datastore/TableMapping.cs index 1343dc38b..ec05af36e 100644 --- a/NzbDrone.Core/Datastore/TableMapping.cs +++ b/NzbDrone.Core/Datastore/TableMapping.cs @@ -4,6 +4,8 @@ using System.Linq; using Marr.Data; using Marr.Data.Mapping; using NzbDrone.Core.Configuration; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Datastore.Converters; using NzbDrone.Core.ExternalNotification; using NzbDrone.Core.Indexers; @@ -11,10 +13,8 @@ using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Jobs; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Qualities; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.RootFolders; using NzbDrone.Core.Tv; -using BooleanIntConverter = NzbDrone.Core.Datastore.Converters.BooleanIntConverter; namespace NzbDrone.Core.Datastore { diff --git a/NzbDrone.Core/IndexerSearch/DailyEpisodeSearch.cs b/NzbDrone.Core/IndexerSearch/DailyEpisodeSearch.cs index 2841dc517..61b3848a2 100644 --- a/NzbDrone.Core/IndexerSearch/DailyEpisodeSearch.cs +++ b/NzbDrone.Core/IndexerSearch/DailyEpisodeSearch.cs @@ -4,12 +4,13 @@ using System.Linq; using System.Threading.Tasks; using NLog; using NzbDrone.Common.EnsureThat; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; namespace NzbDrone.Core.IndexerSearch diff --git a/NzbDrone.Core/IndexerSearch/EpisodeSearch.cs b/NzbDrone.Core/IndexerSearch/EpisodeSearch.cs index 3bbddd031..af25d7135 100644 --- a/NzbDrone.Core/IndexerSearch/EpisodeSearch.cs +++ b/NzbDrone.Core/IndexerSearch/EpisodeSearch.cs @@ -3,12 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using NLog; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; namespace NzbDrone.Core.IndexerSearch diff --git a/NzbDrone.Core/IndexerSearch/IndexerSearchBase.cs b/NzbDrone.Core/IndexerSearch/IndexerSearchBase.cs index 9a6d37de0..28c57f1df 100644 --- a/NzbDrone.Core/IndexerSearch/IndexerSearchBase.cs +++ b/NzbDrone.Core/IndexerSearch/IndexerSearchBase.cs @@ -3,12 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using NLog; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; namespace NzbDrone.Core.IndexerSearch diff --git a/NzbDrone.Core/IndexerSearch/PartialSeasonSearch.cs b/NzbDrone.Core/IndexerSearch/PartialSeasonSearch.cs index 89b859b91..a4228bd49 100644 --- a/NzbDrone.Core/IndexerSearch/PartialSeasonSearch.cs +++ b/NzbDrone.Core/IndexerSearch/PartialSeasonSearch.cs @@ -3,12 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using NLog; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; namespace NzbDrone.Core.IndexerSearch diff --git a/NzbDrone.Core/Jobs/Implementations/UpdateInfoJob.cs b/NzbDrone.Core/Jobs/Implementations/UpdateInfoJob.cs index e5a3a9f59..d10960844 100644 --- a/NzbDrone.Core/Jobs/Implementations/UpdateInfoJob.cs +++ b/NzbDrone.Core/Jobs/Implementations/UpdateInfoJob.cs @@ -3,9 +3,10 @@ using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Configuration; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.DailySeries; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Jobs.Implementations diff --git a/NzbDrone.Core/Jobs/Implementations/UpdateSceneMappingsJob.cs b/NzbDrone.Core/Jobs/Implementations/UpdateSceneMappingsJob.cs index 83f72c0c1..8a96fc301 100644 --- a/NzbDrone.Core/Jobs/Implementations/UpdateSceneMappingsJob.cs +++ b/NzbDrone.Core/Jobs/Implementations/UpdateSceneMappingsJob.cs @@ -1,7 +1,8 @@ using System; using System.Linq; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.ReferenceData; namespace NzbDrone.Core.Jobs.Implementations { diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 162736cb7..e0cba9cec 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -189,6 +189,12 @@ + + + + + + @@ -315,9 +321,6 @@ - - - @@ -472,16 +475,10 @@ Code - - Code - Code - - Code - Code @@ -523,7 +520,6 @@ - diff --git a/NzbDrone.Core/ReferenceData/SceneMappingProxy.cs b/NzbDrone.Core/ReferenceData/SceneMappingProxy.cs deleted file mode 100644 index 5f4eefaa4..000000000 --- a/NzbDrone.Core/ReferenceData/SceneMappingProxy.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; -using NzbDrone.Common; -using NzbDrone.Core.Configuration; - -namespace NzbDrone.Core.ReferenceData -{ - public interface ISceneMappingProxy - { - List Fetch(); - } - - public class SceneMappingProxy : ISceneMappingProxy - { - private readonly HttpProvider _httpProvider; - private readonly IConfigService _configService; - - public SceneMappingProxy(HttpProvider httpProvider, IConfigService configService) - { - _httpProvider = httpProvider; - _configService = configService; - } - - public List Fetch() - { - var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active"); - return JsonConvert.DeserializeObject>(mappingsJson); - } - - - /* public virtual bool SubmitMapping(int id, string postTitle) - { - Logger.Trace("Parsing example post"); - var episodeParseResult = Parser.ParseTitle(postTitle); - var cleanTitle = episodeParseResult.CleanTitle; - var title = episodeParseResult.SeriesTitle.Replace('.', ' '); - 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(_configService.ServiceRootUrl + newMapping); - - if (JsonConvert.DeserializeObject(response).Equals("Ok")) - return true; - - return false; - }*/ - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index ae9543d61..d27b079da 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -5,11 +5,12 @@ using NLog; using NzbDrone.Common.EnsureThat; using NzbDrone.Common.Eventing; using NzbDrone.Core.Configuration; +using NzbDrone.Core.DataAugmentation; +using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.Datastore; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Model; using NzbDrone.Core.Qualities; -using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv.Events; namespace NzbDrone.Core.Tv diff --git a/NzbDrone.sln.DotSettings b/NzbDrone.sln.DotSettings index 17f08160c..b161673b3 100644 --- a/NzbDrone.sln.DotSettings +++ b/NzbDrone.sln.DotSettings @@ -4,6 +4,7 @@ DO_NOT_SHOW DO_NOT_SHOW ERROR + ERROR HINT <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb" /></Policy> diff --git a/NzbDrone/app.config b/NzbDrone/app.config index 36278d6a2..ca2c718c2 100644 --- a/NzbDrone/app.config +++ b/NzbDrone/app.config @@ -5,7 +5,7 @@ - +