Merge branch 'markus101'
Conflicts: NzbDrone.Core/Datastore/Migrations/MigrationExport.cs
This commit is contained in:
commit
2a32770b69
|
@ -247,7 +247,7 @@ namespace NzbDrone.Core.Test
|
||||||
mocker.GetMock<InventoryProvider>()
|
mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(c => c.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Series != null && d.Episodes.Count != 0))).Returns(false);
|
.Setup(c => c.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Series != null && d.Episodes.Count != 0))).Returns(false);
|
||||||
|
|
||||||
mocker.GetMock<SceneNameMappingProvider>()
|
mocker.GetMock<SceneMappingProvider>()
|
||||||
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -298,7 +298,7 @@ namespace NzbDrone.Core.Test
|
||||||
mocker.GetMock<InventoryProvider>()
|
mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(c => c.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Series != null && d.Episodes.Count != 0))).Returns(false);
|
.Setup(c => c.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Series != null && d.Episodes.Count != 0))).Returns(false);
|
||||||
|
|
||||||
mocker.GetMock<SceneNameMappingProvider>()
|
mocker.GetMock<SceneMappingProvider>()
|
||||||
.Setup(s => s.GetSceneName(71256)).Returns("The Daily Show");
|
.Setup(s => s.GetSceneName(71256)).Returns("The Daily Show");
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -355,7 +355,7 @@ namespace NzbDrone.Core.Test
|
||||||
mocker.GetMock<InventoryProvider>()
|
mocker.GetMock<InventoryProvider>()
|
||||||
.Setup(c => c.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Series != null && d.Episodes.Count != 0))).Returns(false);;
|
.Setup(c => c.IsQualityNeeded(It.Is<EpisodeParseResult>(d => d.Series != null && d.Episodes.Count != 0))).Returns(false);;
|
||||||
|
|
||||||
mocker.GetMock<SceneNameMappingProvider>()
|
mocker.GetMock<SceneMappingProvider>()
|
||||||
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
.Setup(s => s.GetSceneName(It.IsAny<int>())).Returns("");
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
|
|
@ -17,7 +17,7 @@ using NzbDrone.Core.Providers.Jobs;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Repository.Quality;
|
using NzbDrone.Core.Repository.Quality;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using SubSonic.Repository;
|
using PetaPoco;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test
|
namespace NzbDrone.Core.Test
|
||||||
{
|
{
|
||||||
|
@ -102,9 +102,9 @@ namespace NzbDrone.Core.Test
|
||||||
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
||||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
var repo = mocker.GetMock<IRepository>();
|
var database = mocker.GetMock<IDatabase>();
|
||||||
repo.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||||
repo.Setup(r => r.Add<EpisodeFile>(It.IsAny<EpisodeFile>())).Returns(1);
|
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Episode Title", series);
|
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Episode Title", series);
|
||||||
|
@ -142,9 +142,9 @@ namespace NzbDrone.Core.Test
|
||||||
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
||||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
var repo = mocker.GetMock<IRepository>();
|
var database = mocker.GetMock<IDatabase>();
|
||||||
repo.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||||
repo.Setup(r => r.Add<EpisodeFile>(It.IsAny<EpisodeFile>())).Returns(1);
|
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Episode Title", series);
|
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Episode Title", series);
|
||||||
|
@ -247,9 +247,9 @@ namespace NzbDrone.Core.Test
|
||||||
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
||||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
var repo = mocker.GetMock<IRepository>();
|
var database = mocker.GetMock<IDatabase>();
|
||||||
repo.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||||
repo.Setup(r => r.Add<EpisodeFile>(It.IsAny<EpisodeFile>())).Returns(1);
|
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05x06 - Episode Title", series);
|
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05x06 - Episode Title", series);
|
||||||
|
@ -292,9 +292,9 @@ namespace NzbDrone.Core.Test
|
||||||
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
||||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
var repo = mocker.GetMock<IRepository>();
|
var database = mocker.GetMock<IDatabase>();
|
||||||
repo.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||||
repo.Setup(r => r.Add<EpisodeFile>(It.IsAny<EpisodeFile>())).Returns(1);
|
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05x06 - Episode Title", series);
|
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05x06 - Episode Title", series);
|
||||||
|
@ -395,9 +395,9 @@ namespace NzbDrone.Core.Test
|
||||||
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
||||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
var repo = mocker.GetMock<IRepository>();
|
var database = mocker.GetMock<IDatabase>();
|
||||||
repo.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||||
repo.Setup(r => r.Add<EpisodeFile>(It.IsAny<EpisodeFile>())).Returns(1);
|
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Fourty Samples", series);
|
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Fourty Samples", series);
|
||||||
|
@ -435,9 +435,9 @@ namespace NzbDrone.Core.Test
|
||||||
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
configProvider.SetupGet(c => c.NumberStyle).Returns(2);
|
||||||
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
configProvider.SetupGet(c => c.ReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
var repo = mocker.GetMock<IRepository>();
|
var database = mocker.GetMock<IDatabase>();
|
||||||
repo.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
database.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>(), It.IsAny<object>())).Returns(false).Verifiable();
|
||||||
repo.Setup(r => r.Add<EpisodeFile>(It.IsAny<EpisodeFile>())).Returns(1);
|
database.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(1);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Episode Title", series);
|
var result = mocker.Resolve<MediaFileProvider>().ImportNewFiles(@"C:\Test\30 Rock - 1x05 - Episode Title", series);
|
||||||
|
|
|
@ -128,7 +128,7 @@
|
||||||
<Compile Include="QualityProfileTest.cs" />
|
<Compile Include="QualityProfileTest.cs" />
|
||||||
<Compile Include="RepoTest.cs" />
|
<Compile Include="RepoTest.cs" />
|
||||||
<Compile Include="SabProviderTest.cs" />
|
<Compile Include="SabProviderTest.cs" />
|
||||||
<Compile Include="SceneNameHelperTest.cs" />
|
<Compile Include="SceneMappingTest.cs" />
|
||||||
<Compile Include="SeriesProviderTest.cs" />
|
<Compile Include="SeriesProviderTest.cs" />
|
||||||
<Compile Include="TvDbProviderTest.cs" />
|
<Compile Include="TvDbProviderTest.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -19,25 +19,26 @@ namespace NzbDrone.Core.Test
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
public class SceneNameHelperTest : TestBase
|
public class SceneMappingTest : TestBase
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void GetSceneName_exists()
|
public void GetSceneName_exists()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||||
|
.With(f => f.CleanTitle = "laworder")
|
||||||
.With(f => f.SeriesId = 12345)
|
.With(f => f.SeriesId = 12345)
|
||||||
.With(f => f.SceneName = "Law and Order")
|
.With(f => f.SceneName = "Law and Order")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
mocker.GetMock<IRepository>()
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
||||||
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()))
|
mocker.SetConstant(emptyDatabase);
|
||||||
.Returns(fakeMap);
|
emptyDatabase.Insert(fakeMap);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var sceneName = mocker.Resolve<SceneNameMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
||||||
|
@ -47,7 +48,7 @@ namespace NzbDrone.Core.Test
|
||||||
public void GetSeriesId_exists()
|
public void GetSeriesId_exists()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||||
.With(f => f.SeriesId = 12345)
|
.With(f => f.SeriesId = 12345)
|
||||||
.With(f => f.SceneName = "Law and Order")
|
.With(f => f.SceneName = "Law and Order")
|
||||||
.With(f => f.SceneName = "laworder")
|
.With(f => f.SceneName = "laworder")
|
||||||
|
@ -55,12 +56,12 @@ namespace NzbDrone.Core.Test
|
||||||
|
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
mocker.GetMock<IRepository>()
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
||||||
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()))
|
mocker.SetConstant(emptyDatabase);
|
||||||
.Returns(fakeMap);
|
emptyDatabase.Insert(fakeMap);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var seriesId = mocker.Resolve<SceneNameMappingProvider>().GetSeriesId(fakeMap.SceneCleanName);
|
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual(fakeMap.SeriesId, seriesId);
|
Assert.AreEqual(fakeMap.SeriesId, seriesId);
|
||||||
|
@ -70,18 +71,20 @@ namespace NzbDrone.Core.Test
|
||||||
public void GetSceneName_null()
|
public void GetSceneName_null()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||||
.With(f => f.SeriesId = 12345)
|
.With(f => f.SeriesId = 12345)
|
||||||
.With(f => f.SceneName = "Law and Order")
|
.With(f => f.SceneName = "Law and Order")
|
||||||
|
.With(f => f.SceneName = "laworder")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
mocker.GetMock<IRepository>()
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
||||||
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()));
|
mocker.SetConstant(emptyDatabase);
|
||||||
|
emptyDatabase.Insert(fakeMap);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var sceneName = mocker.Resolve<SceneNameMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
var sceneName = mocker.Resolve<SceneMappingProvider>().GetSceneName(54321);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual(null, sceneName);
|
Assert.AreEqual(null, sceneName);
|
||||||
|
@ -91,19 +94,20 @@ namespace NzbDrone.Core.Test
|
||||||
public void GetSeriesId_null()
|
public void GetSeriesId_null()
|
||||||
{
|
{
|
||||||
//Setup
|
//Setup
|
||||||
var fakeMap = Builder<SceneNameMapping>.CreateNew()
|
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||||
.With(f => f.SeriesId = 12345)
|
.With(f => f.SeriesId = 12345)
|
||||||
.With(f => f.SceneName = "Law and Order")
|
.With(f => f.SceneName = "Law and Order")
|
||||||
.With(f => f.SceneName = "laworder")
|
.With(f => f.CleanTitle = "laworder")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
mocker.GetMock<IRepository>()
|
var emptyDatabase = MockLib.GetEmptyDatabase();
|
||||||
.Setup(f => f.Single<SceneNameMapping>(It.IsAny<Expression<Func<SceneNameMapping, bool>>>()));
|
mocker.SetConstant(emptyDatabase);
|
||||||
|
emptyDatabase.Insert(fakeMap);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
var seriesId = mocker.Resolve<SceneNameMappingProvider>().GetSeriesId(fakeMap.SceneCleanName);
|
var seriesId = mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder");
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual(null, seriesId);
|
Assert.AreEqual(null, seriesId);
|
|
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
{
|
{
|
||||||
repository.Single<QualityProfile>(1);
|
repository.Single<QualityProfile>(1);
|
||||||
repository.Single<IndexerSetting>(1);
|
repository.Single<IndexerSetting>(1);
|
||||||
repository.Single<SceneNameMapping>(1);
|
repository.Single<SceneMapping>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@
|
||||||
<Compile Include="Providers\Jobs\IJob.cs" />
|
<Compile Include="Providers\Jobs\IJob.cs" />
|
||||||
<Compile Include="Providers\Jobs\RssSyncJob.cs" />
|
<Compile Include="Providers\Jobs\RssSyncJob.cs" />
|
||||||
<Compile Include="Providers\Jobs\UpdateInfoJob.cs" />
|
<Compile Include="Providers\Jobs\UpdateInfoJob.cs" />
|
||||||
<Compile Include="Providers\SceneNameMappingProvider.cs" />
|
<Compile Include="Providers\SceneMappingProvider.cs" />
|
||||||
<Compile Include="Providers\StatsProvider.cs" />
|
<Compile Include="Providers\StatsProvider.cs" />
|
||||||
<Compile Include="Repository\ExternalNotificationSetting.cs" />
|
<Compile Include="Repository\ExternalNotificationSetting.cs" />
|
||||||
<Compile Include="Repository\JobSetting.cs" />
|
<Compile Include="Repository\JobSetting.cs" />
|
||||||
|
@ -250,7 +250,7 @@
|
||||||
<Compile Include="Repository\Quality\QualityProfile.cs" />
|
<Compile Include="Repository\Quality\QualityProfile.cs" />
|
||||||
<Compile Include="Repository\RootDir.cs" />
|
<Compile Include="Repository\RootDir.cs" />
|
||||||
<Compile Include="Repository\Quality\QualityTypes.cs" />
|
<Compile Include="Repository\Quality\QualityTypes.cs" />
|
||||||
<Compile Include="Repository\SceneNameMapping.cs" />
|
<Compile Include="Repository\SceneMapping.cs" />
|
||||||
<Compile Include="Repository\Series.cs" />
|
<Compile Include="Repository\Series.cs" />
|
||||||
<Compile Include="CentralDispatch.cs" />
|
<Compile Include="CentralDispatch.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
|
@ -17,13 +17,13 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
private readonly DownloadProvider _downloadProvider;
|
private readonly DownloadProvider _downloadProvider;
|
||||||
private readonly IndexerProvider _indexerProvider;
|
private readonly IndexerProvider _indexerProvider;
|
||||||
private readonly EpisodeProvider _episodeProvider;
|
private readonly EpisodeProvider _episodeProvider;
|
||||||
private readonly SceneNameMappingProvider _sceneNameMappingProvider;
|
private readonly SceneMappingProvider _sceneNameMappingProvider;
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public EpisodeSearchJob(InventoryProvider inventoryProvider, DownloadProvider downloadProvider,
|
public EpisodeSearchJob(InventoryProvider inventoryProvider, DownloadProvider downloadProvider,
|
||||||
IndexerProvider indexerProvider, EpisodeProvider episodeProvider,
|
IndexerProvider indexerProvider, EpisodeProvider episodeProvider,
|
||||||
SceneNameMappingProvider sceneNameMappingProvider)
|
SceneMappingProvider sceneNameMappingProvider)
|
||||||
{
|
{
|
||||||
_inventoryProvider = inventoryProvider;
|
_inventoryProvider = inventoryProvider;
|
||||||
_downloadProvider = downloadProvider;
|
_downloadProvider = downloadProvider;
|
||||||
|
|
|
@ -7,9 +7,9 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
{
|
{
|
||||||
public class UpdateSceneMappingsJob : IJob
|
public class UpdateSceneMappingsJob : IJob
|
||||||
{
|
{
|
||||||
private readonly SceneNameMappingProvider _sceneNameMappingProvider;
|
private readonly SceneMappingProvider _sceneNameMappingProvider;
|
||||||
|
|
||||||
public UpdateSceneMappingsJob(SceneNameMappingProvider sceneNameMappingProvider)
|
public UpdateSceneMappingsJob(SceneMappingProvider sceneNameMappingProvider)
|
||||||
{
|
{
|
||||||
_sceneNameMappingProvider = sceneNameMappingProvider;
|
_sceneNameMappingProvider = sceneNameMappingProvider;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,23 +7,24 @@ using System.Text;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
|
using PetaPoco;
|
||||||
using SubSonic.Repository;
|
using SubSonic.Repository;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers
|
namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
public class SceneNameMappingProvider
|
public class SceneMappingProvider
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IRepository _repository;
|
private readonly IDatabase _database;
|
||||||
private readonly HttpProvider _httpProvider;
|
private readonly HttpProvider _httpProvider;
|
||||||
|
|
||||||
public SceneNameMappingProvider(IRepository repository, HttpProvider httpProvider)
|
public SceneMappingProvider(IDatabase database, HttpProvider httpProvider)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_database = database;
|
||||||
_httpProvider = httpProvider;
|
_httpProvider = httpProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SceneNameMappingProvider()
|
public SceneMappingProvider()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,8 +33,8 @@ namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mapping = _httpProvider.DownloadString("http://vps.nzbdrone.com/SceneNameMappings.csv");
|
var mapping = _httpProvider.DownloadString("http://vps.nzbdrone.com/SceneMappings.csv");
|
||||||
var newMaps = new List<SceneNameMapping>();
|
var newMaps = new List<SceneMapping>();
|
||||||
|
|
||||||
using (var reader = new StringReader(mapping))
|
using (var reader = new StringReader(mapping))
|
||||||
{
|
{
|
||||||
|
@ -44,8 +45,8 @@ namespace NzbDrone.Core.Providers
|
||||||
var seriesId = 0;
|
var seriesId = 0;
|
||||||
Int32.TryParse(split[1], out seriesId);
|
Int32.TryParse(split[1], out seriesId);
|
||||||
|
|
||||||
var map = new SceneNameMapping();
|
var map = new SceneMapping();
|
||||||
map.SceneCleanName = split[0];
|
map.CleanTitle = split[0];
|
||||||
map.SeriesId = seriesId;
|
map.SeriesId = seriesId;
|
||||||
map.SceneName = split[2];
|
map.SceneName = split[2];
|
||||||
|
|
||||||
|
@ -54,10 +55,10 @@ namespace NzbDrone.Core.Providers
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Debug("Deleting all existing Scene Mappings.");
|
Logger.Debug("Deleting all existing Scene Mappings.");
|
||||||
_repository.DeleteMany<SceneNameMapping>(GetAll());
|
_database.Delete<SceneMapping>(String.Empty);
|
||||||
|
|
||||||
Logger.Debug("Adding Scene Mappings");
|
Logger.Debug("Adding Scene Mappings");
|
||||||
_repository.AddMany(newMaps);
|
_database.InsertMany(newMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -68,14 +69,14 @@ namespace NzbDrone.Core.Providers
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual List<SceneNameMapping> GetAll()
|
public virtual List<SceneMapping> GetAll()
|
||||||
{
|
{
|
||||||
return _repository.All<SceneNameMapping>().ToList();
|
return _database.Fetch<SceneMapping>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string GetSceneName(int seriesId)
|
public virtual string GetSceneName(int seriesId)
|
||||||
{
|
{
|
||||||
var item = _repository.Single<SceneNameMapping>(s => s.SeriesId == seriesId);
|
var item = _database.SingleOrDefault<SceneMapping>("WHERE SeriesId = @0", seriesId);
|
||||||
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -85,7 +86,7 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual Nullable<Int32> GetSeriesId(string cleanName)
|
public virtual Nullable<Int32> GetSeriesId(string cleanName)
|
||||||
{
|
{
|
||||||
var item = _repository.Single<SceneNameMapping>(s => s.SceneCleanName == cleanName);
|
var item = _database.SingleOrDefault<SceneMapping>("WHERE CleanTitle = @0", cleanName);
|
||||||
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return null;
|
return null;
|
|
@ -18,11 +18,11 @@ namespace NzbDrone.Core.Providers
|
||||||
private readonly TvDbProvider _tvDbProvider;
|
private readonly TvDbProvider _tvDbProvider;
|
||||||
private readonly IDatabase _database;
|
private readonly IDatabase _database;
|
||||||
private readonly QualityProvider _qualityProvider;
|
private readonly QualityProvider _qualityProvider;
|
||||||
private readonly SceneNameMappingProvider _sceneNameMappingProvider;
|
private readonly SceneMappingProvider _sceneNameMappingProvider;
|
||||||
private static readonly Regex TimeRegex = new Regex(@"^(?<time>\d+:?\d*)\W*(?<meridiem>am|pm)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
private static readonly Regex TimeRegex = new Regex(@"^(?<time>\d+:?\d*)\W*(?<meridiem>am|pm)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
|
||||||
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider, QualityProvider qualityProvider,
|
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider, QualityProvider qualityProvider,
|
||||||
TvDbProvider tvDbProviderProvider, SceneNameMappingProvider sceneNameMappingProvider)
|
TvDbProvider tvDbProviderProvider, SceneMappingProvider sceneNameMappingProvider)
|
||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
_configProvider = configProviderProvider;
|
_configProvider = configProviderProvider;
|
||||||
|
|
|
@ -2,14 +2,17 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using PetaPoco;
|
||||||
using SubSonic.SqlGeneration.Schema;
|
using SubSonic.SqlGeneration.Schema;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Repository
|
namespace NzbDrone.Core.Repository
|
||||||
{
|
{
|
||||||
public class SceneNameMapping
|
[TableName("SceneMappings")]
|
||||||
|
[PrimaryKey("CleanTitle", autoIncrement = false)]
|
||||||
|
public class SceneMapping
|
||||||
{
|
{
|
||||||
[SubSonicPrimaryKey]
|
[SubSonicPrimaryKey]
|
||||||
public virtual string SceneCleanName { get; set; }
|
public virtual string CleanTitle { get; set; }
|
||||||
|
|
||||||
public virtual int SeriesId { get; set; }
|
public virtual int SeriesId { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue