mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
cleaned up scene mapping code.
This commit is contained in:
parent
c1fba9093d
commit
48880e4964
@ -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<SceneMappingProxy>
|
||||
{
|
||||
private const string SCENE_MAPPING_URL = "http://services.nzbdrone.com/SceneMapping/Active";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>().SetupGet(s => s.ServiceRootUrl)
|
||||
.Returns("http://services.nzbdrone.com");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void fetch_should_return_list_of_mappings()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.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<HttpProvider>()
|
||||
.Setup(s => s.DownloadString(SCENE_MAPPING_URL))
|
||||
.Throws(new WebException());
|
||||
Assert.Throws<WebException>(() => Subject.Fetch());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_on_bad_json()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString(SCENE_MAPPING_URL))
|
||||
.Returns("bad json");
|
||||
Assert.Throws<JsonReaderException>(() => Subject.Fetch());
|
||||
}
|
||||
}
|
||||
}
|
@ -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<SceneMappingService, SceneMapping>
|
||||
{
|
||||
|
||||
private List<SceneMapping> _fakeMappings;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_fakeMappings = Builder<SceneMapping>.CreateListOfSize(5).BuildListOfNew();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void UpdateMappings_purge_existing_mapping_and_add_new_ones()
|
||||
{
|
||||
Mocker.GetMock<ISceneMappingProxy>().Setup(c => c.Fetch()).Returns(_fakeMappings);
|
||||
|
||||
Subject.UpdateMappings();
|
||||
|
||||
AssertMappingUpdated();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void UpdateMappings_should_not_delete_if_fetch_fails()
|
||||
{
|
||||
|
||||
Mocker.GetMock<ISceneMappingProxy>().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<ISceneMappingProxy>().Setup(c => c.Fetch()).Returns(new List<SceneMapping>());
|
||||
|
||||
Subject.UpdateMappings();
|
||||
|
||||
AssertNoUpdate();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
private void AssertNoUpdate()
|
||||
{
|
||||
Mocker.GetMock<ISceneMappingProxy>().Verify(c => c.Fetch(), Times.Once());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.Purge(), Times.Never());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.InsertMany(_fakeMappings), Times.Never());
|
||||
}
|
||||
|
||||
private void AssertMappingUpdated()
|
||||
{
|
||||
Mocker.GetMock<ISceneMappingProxy>().Verify(c => c.Fetch(), Times.Once());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.Purge(), Times.Once());
|
||||
Mocker.GetMock<ISceneMappingRepository>().Verify(c => c.InsertMany(_fakeMappings), Times.Once());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -12,12 +12,12 @@ public static class NBuilderExtensions
|
||||
return builder.With(c => c.Id = 0).Build();
|
||||
}
|
||||
|
||||
public static List<T> BuildList<T>(this IOperable<T> builder) where T : ModelBase, new()
|
||||
public static List<T> BuildList<T>(this IListBuilder<T> builder) where T : ModelBase, new()
|
||||
{
|
||||
return builder.Build().ToList();
|
||||
}
|
||||
|
||||
public static List<T> BuildListOfNew<T>(this IOperable<T> builder) where T : ModelBase, new()
|
||||
public static List<T> BuildListOfNew<T>(this IListBuilder<T> builder) where T : ModelBase, new()
|
||||
{
|
||||
return BuildList<T>(builder.All().With(c => c.Id = 0));
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -3,12 +3,13 @@
|
||||
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
|
||||
|
@ -129,6 +129,8 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataAugmentationFixture\Scene\SceneMappingProxyFixture.cs" />
|
||||
<Compile Include="DataAugmentationFixture\Scene\SceneMappingServiceFixture.cs" />
|
||||
<Compile Include="Datastore\BasicRepositoryFixture.cs" />
|
||||
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
||||
<Compile Include="Datastore\MappingExtentionFixture.cs" />
|
||||
@ -239,7 +241,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Qualities\QualityProfileFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\SabProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\SceneMappingProviderTest.cs" />
|
||||
<Compile Include="TvTests\SeriesProviderTest.cs" />
|
||||
<Compile Include="XbmcVersionTests.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -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<IConfigService>().SetupGet(s => s.ServiceRootUrl)
|
||||
.Returns("http://services.nzbdrone.com");
|
||||
|
||||
}
|
||||
|
||||
private void WithValidJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString(SceneMappingUrl))
|
||||
.Returns(ReadAllText("Files", "SceneMappings.json"));
|
||||
}
|
||||
|
||||
private void WithErrorDownloadingJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString(SceneMappingUrl))
|
||||
.Throws(new WebException());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSceneName_exists()
|
||||
{
|
||||
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.CleanTitle = "laworder")
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SeasonNumber = -1)
|
||||
.BuildNew<SceneMapping>();
|
||||
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
|
||||
var sceneName = Mocker.Resolve<SceneMappingService>().GetSceneName(fakeMap.TvdbId);
|
||||
|
||||
|
||||
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSeriesId_exists()
|
||||
{
|
||||
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingService>().GetTvDbId(fakeMap.CleanTitle);
|
||||
|
||||
|
||||
Assert.AreEqual(fakeMap.TvdbId, seriesId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSceneName_null()
|
||||
{
|
||||
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingService>().GetSceneName(54321);
|
||||
|
||||
|
||||
Assert.AreEqual(null, sceneName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSeriesId_null()
|
||||
{
|
||||
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingService>().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<SceneMapping>.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<SceneMapping>.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<SceneMappingService>().GetSceneName(fakeMap.TvdbId);
|
||||
|
||||
|
||||
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSceneName_should_be_null_when_seasonNumber_does_not_match()
|
||||
{
|
||||
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingService>().GetSceneName(54321, 5).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateMappings_should_add_all_mappings_to_database()
|
||||
{
|
||||
WithValidJson();
|
||||
|
||||
|
||||
Mocker.Resolve<SceneMappingService>().UpdateMappings();
|
||||
|
||||
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateMappings_should_overwrite_existing_mappings()
|
||||
{
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingService>().UpdateMappings();
|
||||
|
||||
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateMappings_should_not_delete_if_csv_download_fails()
|
||||
{
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingService>().UpdateMappings();
|
||||
|
||||
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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
|
@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
namespace NzbDrone.Core.DataAugmentation.DailySeries
|
||||
{
|
||||
public class DailySeriesService
|
||||
{
|
@ -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
|
||||
{
|
@ -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<Int32> GetTvDbId(string cleanName);
|
||||
Nullable<int> GetTvDbId(string cleanName);
|
||||
string GetCleanName(int tvdbId);
|
||||
}
|
||||
|
||||
@ -32,12 +32,19 @@ public void UpdateMappings()
|
||||
{
|
||||
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 @@ public virtual string GetSceneName(int tvdbId, int seasonNumber = -1)
|
||||
{
|
||||
var mapping = _repository.FindByTvdbId(tvdbId);
|
||||
|
||||
if(mapping == null) return null;
|
||||
if (mapping == null) return null;
|
||||
|
||||
return mapping.SceneName;
|
||||
}
|
30
NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs
Normal file
30
NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs
Normal file
@ -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<SceneMapping> 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<SceneMapping> Fetch()
|
||||
{
|
||||
var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active");
|
||||
return JsonConvert.DeserializeObject<List<SceneMapping>>(mappingsJson);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<SceneMapping>
|
||||
{
|
@ -4,6 +4,8 @@
|
||||
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.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
|
||||
{
|
||||
|
@ -4,12 +4,13 @@
|
||||
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
|
||||
|
@ -3,12 +3,13 @@
|
||||
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
|
||||
|
@ -3,12 +3,13 @@
|
||||
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
|
||||
|
@ -3,12 +3,13 @@
|
||||
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
|
||||
|
@ -3,9 +3,10 @@
|
||||
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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -189,6 +189,12 @@
|
||||
<Compile Include="Configuration\IConfigService.cs" />
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="ContainerExtensions.cs" />
|
||||
<Compile Include="DataAugmentation\DailySeries\DailySeriesDataProxy.cs" />
|
||||
<Compile Include="DataAugmentation\DailySeries\DailySeriesService.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMapping.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMappingProvider.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMappingProxy.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMappingRepository.cs" />
|
||||
<Compile Include="Datastore\Converters\BooleanIntConverter.cs" />
|
||||
<Compile Include="Datastore\Converters\QualityIntConverter.cs" />
|
||||
<Compile Include="Datastore\Converters\Int32Converter.cs" />
|
||||
@ -315,9 +321,6 @@
|
||||
<Compile Include="Organizer\NameSpecification.cs" />
|
||||
<Compile Include="Qualities\QualitySizeRepository.cs" />
|
||||
<Compile Include="Qualities\QualityProfileRepository.cs" />
|
||||
<Compile Include="ReferenceData\DailySeriesDataProxy.cs" />
|
||||
<Compile Include="ReferenceData\SceneMappingProxy.cs" />
|
||||
<Compile Include="ReferenceData\SceneMappingRepository.cs" />
|
||||
<Compile Include="Tv\EpisodeService.cs" />
|
||||
<Compile Include="Tv\Events\EpisodeInfoUpdatedEvent.cs" />
|
||||
<Compile Include="Tv\Events\EpisodeInfoAddedEvent.cs" />
|
||||
@ -472,16 +475,10 @@
|
||||
<Compile Include="Qualities\QualitySizeService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ReferenceData\DailySeriesService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="RootFolders\UnmappedFolder.cs" />
|
||||
<Compile Include="RootFolders\RootFolderService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ReferenceData\SceneMappingProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\SearchProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@ -523,7 +520,6 @@
|
||||
<Compile Include="Qualities\QualitySize.cs" />
|
||||
<Compile Include="Qualities\QualityProfile.cs" />
|
||||
<Compile Include="RootFolders\RootFolder.cs" />
|
||||
<Compile Include="ReferenceData\SceneMapping.cs" />
|
||||
<Compile Include="Tv\Series.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tv\SeriesStatusType.cs" />
|
||||
|
@ -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<SceneMapping> 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<SceneMapping> Fetch()
|
||||
{
|
||||
var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active");
|
||||
return JsonConvert.DeserializeObject<List<SceneMapping>>(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<String>(response).Equals("Ok"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
@ -5,11 +5,12 @@
|
||||
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
|
||||
|
@ -4,6 +4,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfStatementToReturnStatement/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertNullableToShortForm/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=FunctionRecursiveOnAllPaths/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=NUnit_002ENonPublicMethodWithTestAttribute/@EntryIndexedValue">ERROR</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseObjectOrCollectionInitializer/@EntryIndexedValue">HINT</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FPARAMETER/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb" /></Policy></s:String>
|
||||
|
@ -5,7 +5,7 @@
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<probing privatePath="libs"/>
|
||||
<probing privatePath="libs" />
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user