still very broken
This commit is contained in:
parent
2d4998d52d
commit
4504232956
|
@ -16,12 +16,14 @@ namespace NzbDrone.Api.Series
|
|||
public class SeriesModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly JobController _jobProvider;
|
||||
|
||||
public SeriesModule(SeriesProvider seriesProvider, JobController jobProvider)
|
||||
public SeriesModule(SeriesProvider seriesProvider,ISeriesRepository seriesRepository, JobController jobProvider)
|
||||
: base("/Series")
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
_jobProvider = jobProvider;
|
||||
Get["/"] = x => AllSeries();
|
||||
Get["/{id}"] = x => GetSeries((int)x.id);
|
||||
|
@ -33,7 +35,7 @@ namespace NzbDrone.Api.Series
|
|||
|
||||
private Response AllSeries()
|
||||
{
|
||||
var series = _seriesProvider.GetAllSeriesWithEpisodeCount().ToList();
|
||||
var series = _seriesRepository.All().ToList();
|
||||
var seriesModels = Mapper.Map<List<Core.Tv.Series>, List<SeriesResource>>(series);
|
||||
|
||||
return seriesModels.AsResponse();
|
||||
|
@ -41,7 +43,7 @@ namespace NzbDrone.Api.Series
|
|||
|
||||
private Response GetSeries(int id)
|
||||
{
|
||||
var series = _seriesProvider.GetSeries(id);
|
||||
var series = _seriesRepository.Get(id);
|
||||
var seriesModels = Mapper.Map<Core.Tv.Series, SeriesResource>(series);
|
||||
|
||||
return seriesModels.AsResponse();
|
||||
|
@ -66,7 +68,7 @@ namespace NzbDrone.Api.Series
|
|||
{
|
||||
var request = Request.Body.FromJson<SeriesResource>();
|
||||
|
||||
var series = _seriesProvider.GetSeries(request.Id);
|
||||
var series = _seriesRepository.Get(request.Id);
|
||||
|
||||
series.Monitored = request.Monitored;
|
||||
series.SeasonFolder = request.SeasonFolder;
|
||||
|
@ -83,12 +85,12 @@ namespace NzbDrone.Api.Series
|
|||
else
|
||||
series.CustomStartDate = null;
|
||||
|
||||
_seriesProvider.UpdateSeries(series);
|
||||
_seriesRepository.Update(series);
|
||||
|
||||
if (oldPath != series.Path)
|
||||
_jobProvider.QueueJob(typeof(DiskScanJob), new { SeriesId = series.SeriesId });
|
||||
|
||||
_seriesProvider.UpdateSeries(series);
|
||||
_seriesRepository.Update(series);
|
||||
|
||||
return request.AsResponse();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
[Test]
|
||||
public void should_be_able_to_add()
|
||||
{
|
||||
Subject.Add(sampleType);
|
||||
Subject.Insert(sampleType);
|
||||
Subject.All().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
[Test]
|
||||
public void should_be_able_to_delete_model()
|
||||
{
|
||||
Subject.Add(sampleType);
|
||||
Subject.Insert(sampleType);
|
||||
Subject.All().Should().HaveCount(1);
|
||||
|
||||
Subject.Delete(sampleType.OID);
|
||||
|
@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
[Test]
|
||||
public void should_be_able_to_find_by_id()
|
||||
{
|
||||
Subject.Add(sampleType);
|
||||
Subject.Insert(sampleType);
|
||||
Subject.Get(sampleType.OID)
|
||||
.ShouldHave()
|
||||
.AllProperties()
|
||||
|
|
|
@ -62,8 +62,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(singleEpisodeList);
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultMulti)).Returns(doubleEpisodeList);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(c => c.FindSeries(parseResultMulti.CleanTitle)).Returns(fakeSeries);
|
||||
Mocker.GetMock<SeriesProvider>().Setup(c => c.FindSeries(parseResultSingle.CleanTitle)).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(c => c.Get(parseResultMulti.CleanTitle)).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(c => c.Get(parseResultSingle.CleanTitle)).Returns(fakeSeries);
|
||||
}
|
||||
|
||||
private void WithFirstEpisodeIgnored()
|
||||
|
@ -95,8 +95,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[Test]
|
||||
public void not_in_db_should_be_skipped()
|
||||
{
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.FindSeries(It.IsAny<String>()))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.Get(It.IsAny<String>()))
|
||||
.Returns<Series>(null);
|
||||
|
||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -53,9 +48,9 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
WithSuccessfulDownload();
|
||||
|
||||
var series = Builder<Series>.CreateListOfSize(5)
|
||||
.Build();
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.GetAllSeries())
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.All())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, null);
|
||||
|
@ -70,9 +65,9 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
var series = Builder<Series>.CreateListOfSize(5)
|
||||
.TheFirst(2)
|
||||
.With(s => s.BannerUrl = null)
|
||||
.Build();
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.GetAllSeries())
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.All())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, null);
|
||||
|
@ -87,7 +82,7 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
var series = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.GetSeries(series.SeriesId))
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(series.SeriesId))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.Resolve<BannerDownloadJob>().Start(_notification, new { SeriesId = series.SeriesId });
|
||||
|
|
|
@ -14,6 +14,7 @@ using NzbDrone.Core.Repository;
|
|||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
|
@ -28,9 +29,10 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
.With(s => s.SeriesId = 12)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetSeries(series.SeriesId))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.Get(series.SeriesId));
|
||||
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
.Setup(p => p.Scan(series))
|
||||
|
@ -51,10 +53,10 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.SeriesId = 12)
|
||||
.TheNext(1).With(s => s.SeriesId = 15)
|
||||
.Build();
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetAllSeries())
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.All())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
|
@ -77,10 +79,10 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.SeriesId = 12)
|
||||
.TheNext(1).With(s => s.SeriesId = 15)
|
||||
.Build();
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetAllSeries())
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.All())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
|
@ -104,10 +106,10 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.SeriesId = 12)
|
||||
.TheNext(1).With(s => s.SeriesId = 15)
|
||||
.Build();
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetAllSeries())
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.All())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
|
|
|
@ -34,8 +34,8 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetAllSeries())
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.All())
|
||||
.Returns(series);
|
||||
|
||||
|
||||
|
@ -61,11 +61,11 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[1].SeriesId)))
|
||||
.Callback(() => series[1].LastInfoSync = DateTime.Now);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]);
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(series[0].SeriesId)).Returns(series[0]);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.GetSeries(series[1].SeriesId)).Returns(series[1]);
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(series[1].SeriesId)).Returns(series[1]);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
|
||||
|
@ -99,8 +99,8 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetAllSeries())
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.All())
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<UpdateInfoJob>()
|
||||
|
@ -118,8 +118,8 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
Mocker.GetMock<BannerDownloadJob>()
|
||||
.Setup(j => j.Start(notification, It.Is<object>(d => d.GetPropertyValue<int>("SeriesId") == series[0].SeriesId)));
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.GetSeries(series[0].SeriesId)).Returns(series[0]);
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(series[0].SeriesId)).Returns(series[0]);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.GetSeriesFiles(It.IsAny<int>())).Returns(new List<EpisodeFile>());
|
||||
|
|
|
@ -41,13 +41,13 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
Subject.Init();
|
||||
|
||||
Storage.All().Should().HaveCount(1);
|
||||
Storage.All()[0].Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes);
|
||||
Storage.All()[0].Name.Should().Be(_fakeJob.Name);
|
||||
Storage.All()[0].TypeName.Should().Be(_fakeJob.GetType().ToString());
|
||||
Storage.All()[0].LastExecution.Should().HaveYear(DateTime.Now.Year);
|
||||
Storage.All()[0].LastExecution.Should().HaveMonth(DateTime.Now.Month);
|
||||
Storage.All()[0].LastExecution.Should().HaveDay(DateTime.Today.Day);
|
||||
Storage.All()[0].Enable.Should().BeTrue();
|
||||
Storage.All().ToList()[0].Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes);
|
||||
Storage.All().ToList()[0].Name.Should().Be(_fakeJob.Name);
|
||||
Storage.All().ToList()[0].TypeName.Should().Be(_fakeJob.GetType().ToString());
|
||||
Storage.All().ToList()[0].LastExecution.Should().HaveYear(DateTime.Now.Year);
|
||||
Storage.All().ToList()[0].LastExecution.Should().HaveMonth(DateTime.Now.Month);
|
||||
Storage.All().ToList()[0].LastExecution.Should().HaveDay(DateTime.Today.Day);
|
||||
Storage.All().ToList()[0].Enable.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -108,14 +108,14 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
.With(c => c.LastExecution = DateTime.Now.AddDays(-7).Date)
|
||||
.Build();
|
||||
|
||||
Storage.Add(oldJob);
|
||||
Storage.Insert(oldJob);
|
||||
|
||||
var newJob = new FakeJob();
|
||||
|
||||
IEnumerable<IJob> fakeJobs = new List<IJob> { newJob };
|
||||
Mocker.SetConstant(fakeJobs);
|
||||
|
||||
Subject.Init();
|
||||
Subject.Init();
|
||||
|
||||
|
||||
var registeredJobs = Storage.All();
|
||||
|
@ -142,20 +142,20 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
Storage.All().First().Enable.Should().BeFalse();
|
||||
}
|
||||
|
||||
/* [Test]
|
||||
public void disabled_jobs_arent_run_by_scheduler()
|
||||
{
|
||||
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { disabledJob };
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
/* [Test]
|
||||
public void disabled_jobs_arent_run_by_scheduler()
|
||||
{
|
||||
IEnumerable<IJob> BaseFakeJobs = new List<IJob> { disabledJob };
|
||||
Mocker.SetConstant(BaseFakeJobs);
|
||||
|
||||
var jobProvider = Mocker.Resolve<JobController>();
|
||||
jobProvider.QueueScheduled();
|
||||
var jobProvider = Mocker.Resolve<JobController>();
|
||||
jobProvider.QueueScheduled();
|
||||
|
||||
WaitForQueue();
|
||||
WaitForQueue();
|
||||
|
||||
|
||||
disabledJob.ExecutionCount.Should().Be(0);
|
||||
}*/
|
||||
disabledJob.ExecutionCount.Should().Be(0);
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace NzbDrone.Core.Test.JobTests
|
|||
.With(e => e.SeasonNumber = 5)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.GetSeries(_series.SeriesId))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(_series.SeriesId))
|
||||
.Returns(_series);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
|
||||
//Assert
|
||||
Mocker.GetMock<MediaFileProvider>().Verify(v => v.GetFileByPath(filename), Times.Once());
|
||||
Mocker.GetMock<SeriesProvider>().Verify(v => v.GetSeries(It.IsAny<int>()), Times.Never());
|
||||
Mocker.GetMock<ISeriesRepository>().Verify(v => v.Get(It.IsAny<int>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetFileByPath(filename))
|
||||
.Returns(episodeFile);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.GetSeries(It.IsAny<int>()))
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<int>()))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
|
|
|
@ -46,8 +46,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
.With(f => f.Path = fi.FullName)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(e => e.GetSeries(fakeSeries.SeriesId))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(e => e.Get(fakeSeries.SeriesId))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
|
@ -96,8 +96,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
.With(f => f.Proper = false)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(e => e.GetSeries(fakeSeries.SeriesId))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(e => e.Get(fakeSeries.SeriesId))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
|
@ -159,8 +159,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
.With(f => f.Proper = false)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(e => e.GetSeries(fakeSeries.SeriesId))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(e => e.Get(fakeSeries.SeriesId))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
||||
{
|
||||
|
@ -27,9 +18,9 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|||
public void series_should_update_the_last_scan_date()
|
||||
{
|
||||
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.UpdateSeries(It.Is<Series>(s => s.LastDiskSync != null))).Verifiable();
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Update(It.Is<Series>(s => s.LastDiskSync != null))).Verifiable();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.GetEpisodeBySeries(It.IsAny<long>()))
|
||||
|
|
|
@ -47,8 +47,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
|
||||
private void WithValidSeries()
|
||||
{
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries(It.IsAny<string>()))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<string>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
@ -99,7 +99,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
droppedFolder.Create();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
||||
//Assert
|
||||
|
@ -115,7 +115,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
|
||||
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\_unpack_The Office - S01E01 - Episode Title");
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns<Series>(null).Verifiable();
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns<Series>(null).Verifiable();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
@ -167,7 +167,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
var taggedFolder = @"C:\Test\Unsorted TV\_UnknownSeries_The Office - S01E01 - Episode Title";
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns<Series>(null);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
|
||||
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
@ -193,7 +193,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
.Build();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(new List<EpisodeFile>());
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
|
||||
|
@ -228,7 +228,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
.Build().ToList();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
|
||||
|
@ -254,7 +254,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
WithOldWrite();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
||||
//Assert
|
||||
|
@ -273,7 +273,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
|
||||
var taggedFolder = TempFolder + @"\_UnknownSeries_The Office - S01E01 - Episode Title";
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
@ -295,7 +295,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
|
||||
WithImportedFiles(droppedFolder.FullName);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.CleanUpDropFolder(droppedFolder.FullName));
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(new EpisodeFile());
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes());
|
||||
|
@ -322,7 +322,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
var fakeEpisodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<string>())).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<string>())).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true);
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
|
||||
|
||||
|
@ -345,8 +345,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
.With(s => s.Path = @"C:\Test\TV\30 Rock")
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries("rock"))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
@ -380,8 +380,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
|
||||
WithImportedFiles(downloadName.FullName);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries("rock"))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
|
|
@ -57,12 +57,12 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
.Setup(c => c.GetDirectories(It.IsAny<String>()))
|
||||
.Returns(subFolders);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.SeriesPathExists(subFolders[1]))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries(It.IsAny<String>()))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<String>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
|
@ -104,8 +104,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
.Setup(c => c.GetVideoFiles(It.IsAny<String>(), false))
|
||||
.Returns(files);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries(It.IsAny<String>()))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<String>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
|
|
|
@ -47,8 +47,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
|
||||
private void WithValidSeries()
|
||||
{
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries(It.IsAny<string>()))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<string>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
@ -96,11 +96,11 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
var file = Path.Combine(TempFolder, "test.avi");
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(file);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<SeriesProvider>().Verify(s => s.FindSeries(It.IsAny<String>()), Times.Once());
|
||||
Mocker.GetMock<ISeriesRepository>().Verify(s => s.Get(It.IsAny<String>()), Times.Once());
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
var file = Path.Combine(TempFolder, "test.avi");
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(file);
|
||||
|
||||
//Assert
|
||||
|
@ -149,8 +149,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
.With(s => s.Path = @"C:\Test\TV\30 Rock")
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries("rock"))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
@ -182,8 +182,8 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
|||
|
||||
var downloadName = @"C:\Test\Drop\30.Rock.S01E01.Pilot.mkv";
|
||||
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(c => c.FindSeries("rock"))
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
|
|
@ -58,20 +58,20 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
|||
|
||||
private void WithMatchingSeries()
|
||||
{
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(_matchingSeries);
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<string>())).Returns(_matchingSeries);
|
||||
}
|
||||
|
||||
private void WithMisMatchedSeries()
|
||||
{
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(_mismatchedSeries);
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<string>())).Returns(_mismatchedSeries);
|
||||
}
|
||||
|
||||
private void WithNullSeries()
|
||||
{
|
||||
Mocker.GetMock<SeriesProvider>()
|
||||
.Setup(s => s.FindSeries(It.IsAny<string>())).Returns(_nullSeries);
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<string>())).Returns(_nullSeries);
|
||||
}
|
||||
|
||||
private void WithSuccessfulDownload()
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
|
|||
|
||||
public TestSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider,
|
||||
IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider)
|
||||
: base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.RootFolderTests
|
|||
|
||||
Subject.Add(root);
|
||||
|
||||
Mocker.GetMock<IBasicRepository<RootFolder>>().Verify(c => c.Add(root), Times.Once());
|
||||
Mocker.GetMock<IBasicRepository<RootFolder>>().Verify(c => c.Insert(root), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -828,7 +828,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
|||
seriesProvider.AddSeries("Test Series","c:\\test\\", tvDbSeriesId, 1, null);
|
||||
|
||||
var episodeProvider = Mocker.Resolve<EpisodeProvider>();
|
||||
episodeProvider.RefreshEpisodeInfo(seriesProvider.GetSeries(tvDbSeriesId));
|
||||
episodeProvider.RefreshEpisodeInfo(seriesProvider.ge(tvDbSeriesId));
|
||||
|
||||
//assert
|
||||
var episodes = episodeProvider.GetEpisodeBySeries(tvDbSeriesId);
|
||||
|
@ -1422,7 +1422,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
|||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("officeus")).Returns(fakeSeries);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId).ToList(), postDownloadStatus);
|
||||
|
@ -1454,7 +1454,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
|||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
Mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("officeus")).Returns(fakeSeries);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(new List<int> { 300 }, postDownloadStatus);
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
seriesProvider.AddSeries(title, path, tvDbId, qualityProfileId, null);
|
||||
|
||||
//Assert
|
||||
var series = seriesProvider.GetAllSeries();
|
||||
var series = seriesProvider.All();
|
||||
series.Should().HaveCount(1);
|
||||
Assert.AreEqual(path, series.First().Path);
|
||||
Assert.AreEqual(tvDbId, series.First().SeriesId);
|
||||
|
@ -82,7 +82,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
var series = seriesProvider.FindSeries("My Title");
|
||||
var series = seriesProvider.Get("My Title");
|
||||
|
||||
//Assert
|
||||
Assert.IsNull(series);
|
||||
|
@ -96,7 +96,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
var series = seriesProvider.GetSeries(2);
|
||||
var series = seriesProvider.Get(2);
|
||||
|
||||
|
||||
//Assert
|
||||
|
@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetSeries(1);
|
||||
var series = Mocker.Resolve<SeriesProvider>().Get(1);
|
||||
|
||||
//Assert
|
||||
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId, s => s.NextAiring).EqualTo(fakeSeries);
|
||||
|
@ -158,7 +158,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
Mocker.Resolve<QualityProvider>();
|
||||
Mocker.GetMock<SceneMappingProvider>().Setup(s => s.GetSeriesId("laworder")).Returns(1);
|
||||
|
||||
var series = Mocker.Resolve<SeriesProvider>().FindSeries("laworder");
|
||||
var series = Mocker.Resolve<SeriesProvider>().Get("laworder");
|
||||
|
||||
//Assert
|
||||
series.ShouldHave().AllPropertiesBut(s => s.QualityProfile, s => s.SeriesId);
|
||||
|
@ -180,7 +180,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
|
||||
//Assert
|
||||
seriesProvider.FindSeries("WrongTitle").Should().BeNull();
|
||||
seriesProvider.Get("WrongTitle").Should().BeNull();
|
||||
}
|
||||
|
||||
[TestCase("The Test", "Test")]
|
||||
|
@ -204,7 +204,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var series = Mocker.Resolve<SeriesProvider>().FindSeries(searchTitle);
|
||||
var series = Mocker.Resolve<SeriesProvider>().Get(searchTitle);
|
||||
|
||||
//Assert
|
||||
series.Should().NotBeNull();
|
||||
|
@ -405,7 +405,7 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
|
||||
//Act
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var series = Mocker.Resolve<SeriesProvider>().GetSeries(1);
|
||||
var series = Mocker.Resolve<SeriesProvider>().Get(1);
|
||||
|
||||
//Assert
|
||||
series.QualityProfile.Should().NotBeNull();
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace NzbDrone.Core.Datastore
|
|||
{
|
||||
public interface IBasicRepository<TModel>
|
||||
{
|
||||
List<TModel> All();
|
||||
IEnumerable<TModel> All();
|
||||
TModel Get(int id);
|
||||
TModel Add(TModel model);
|
||||
TModel Insert(TModel model);
|
||||
TModel Update(TModel model);
|
||||
TModel Upsert(TModel model);
|
||||
void Delete(int id);
|
||||
|
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Datastore
|
|||
|
||||
protected IEnumerable<TModel> Queryable { get { return ObjectDatabase.AsQueryable<TModel>(); } }
|
||||
|
||||
public List<TModel> All()
|
||||
public IEnumerable<TModel> All()
|
||||
{
|
||||
return Queryable.ToList();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace NzbDrone.Core.Datastore
|
|||
return Queryable.Single(c => c.OID == id);
|
||||
}
|
||||
|
||||
public TModel Add(TModel model)
|
||||
public TModel Insert(TModel model)
|
||||
{
|
||||
return ObjectDatabase.Insert(model);
|
||||
}
|
||||
|
|
|
@ -10,12 +10,14 @@ namespace NzbDrone.Core.DecisionEngine
|
|||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public MonitoredEpisodeSpecification(SeriesProvider seriesProvider, EpisodeProvider episodeProvider)
|
||||
public MonitoredEpisodeSpecification(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public MonitoredEpisodeSpecification()
|
||||
|
@ -25,7 +27,7 @@ namespace NzbDrone.Core.DecisionEngine
|
|||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
var series = _seriesProvider.FindSeries(subject.CleanTitle);
|
||||
var series = _seriesRepository.Get(subject.CleanTitle);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace NzbDrone.Core.Jobs
|
|||
|
||||
if (options != null)
|
||||
{
|
||||
Series series = _seriesProvider.GetSeries(options.SeriesId);
|
||||
Series series = _seriesProvider.Get(options.SeriesId);
|
||||
|
||||
if (series != null && !String.IsNullOrEmpty(series.BannerUrl))
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ namespace NzbDrone.Core.Jobs
|
|||
return;
|
||||
}
|
||||
|
||||
var seriesInDb = _seriesProvider.GetAllSeries();
|
||||
var seriesInDb = _seriesProvider.All();
|
||||
|
||||
foreach (var series in seriesInDb.Where(s => !String.IsNullOrEmpty(s.BannerUrl)))
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace NzbDrone.Core.Jobs
|
|||
{
|
||||
Logger.Trace("Deleting Series [{0}]", seriesId);
|
||||
|
||||
var series = _seriesProvider.GetSeries(seriesId);
|
||||
var series = _seriesProvider.Get(seriesId);
|
||||
var title = series.Title;
|
||||
|
||||
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
|
||||
|
|
|
@ -46,14 +46,14 @@ namespace NzbDrone.Core.Jobs
|
|||
if (options == null || options.SeriesId == 0)
|
||||
{
|
||||
if (_configProvider.IgnoreArticlesWhenSortingSeries)
|
||||
seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
seriesToScan = _seriesProvider.All().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
|
||||
else
|
||||
seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList();
|
||||
seriesToScan = _seriesProvider.All().OrderBy(o => o.Title).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
seriesToScan = new List<Series>() { _seriesProvider.GetSeries(options.SeriesId) };
|
||||
seriesToScan = new List<Series>() { _seriesProvider.Get(options.SeriesId) };
|
||||
}
|
||||
|
||||
foreach (var series in seriesToScan)
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Jobs
|
|||
|
||||
private void ScanSeries(ProgressNotification notification)
|
||||
{
|
||||
var syncList = _seriesProvider.GetAllSeries().Where(s => s.LastInfoSync == null && !_attemptedSeries.Contains(s.SeriesId)).ToList();
|
||||
var syncList = _seriesProvider.All().Where(s => s.LastInfoSync == null && !_attemptedSeries.Contains(s.SeriesId)).ToList();
|
||||
if (syncList.Count == 0)
|
||||
{
|
||||
return;
|
||||
|
@ -77,7 +77,7 @@ namespace NzbDrone.Core.Jobs
|
|||
_updateInfoJob.Start(notification, new { SeriesId = currentSeries.SeriesId });
|
||||
_diskScanJob.Start(notification, new { SeriesId = currentSeries.SeriesId });
|
||||
|
||||
var updatedSeries = _seriesProvider.GetSeries(currentSeries.SeriesId);
|
||||
var updatedSeries = _seriesProvider.Get(currentSeries.SeriesId);
|
||||
AutoIgnoreSeasons(updatedSeries.SeriesId);
|
||||
|
||||
//Download the banner for the new series
|
||||
|
|
|
@ -40,10 +40,10 @@ namespace NzbDrone.Core.Jobs
|
|||
List<Series> seriesToRefresh;
|
||||
|
||||
if (options == null || options.SeriesId <= 0)
|
||||
seriesToRefresh = _seriesProvider.GetAllSeries().ToList();
|
||||
seriesToRefresh = _seriesProvider.All().ToList();
|
||||
|
||||
else
|
||||
seriesToRefresh = new List<Series> { _seriesProvider.GetSeries(options.SeriesId) };
|
||||
seriesToRefresh = new List<Series> { _seriesProvider.Get(options.SeriesId) };
|
||||
|
||||
foreach(var series in seriesToRefresh)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,6 @@ using NLog;
|
|||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
|
@ -16,18 +15,20 @@ namespace NzbDrone.Core.Jobs
|
|||
private readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RenameSeasonJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider,
|
||||
MetadataProvider metadataProvider)
|
||||
MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public string Name
|
||||
|
@ -48,7 +49,7 @@ namespace NzbDrone.Core.Jobs
|
|||
if (options.SeasonNumber < 0)
|
||||
throw new ArgumentException("options.SeasonNumber");
|
||||
|
||||
var series = _seriesProvider.GetSeries(options.SeriesId);
|
||||
var series = _seriesRepository.Get(options.SeriesId);
|
||||
|
||||
notification.CurrentMessage = String.Format("Renaming episodes for {0} Season {1}", series.Title, options.SeasonNumber);
|
||||
|
||||
|
|
|
@ -16,18 +16,20 @@ namespace NzbDrone.Core.Jobs
|
|||
private readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RenameSeriesJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider,
|
||||
MetadataProvider metadataProvider)
|
||||
MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public string Name
|
||||
|
@ -46,12 +48,12 @@ namespace NzbDrone.Core.Jobs
|
|||
|
||||
if (options == null || options.SeriesId <= 0)
|
||||
{
|
||||
seriesToRename = _seriesProvider.GetAllSeries().ToList();
|
||||
seriesToRename = _seriesRepository.All().ToList();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
seriesToRename = new List<Series>{ _seriesProvider.GetSeries(options.SeriesId) };
|
||||
seriesToRename = new List<Series>{ _seriesRepository.Get(options.SeriesId) };
|
||||
}
|
||||
|
||||
foreach(var series in seriesToRename)
|
||||
|
|
|
@ -17,15 +17,17 @@ namespace NzbDrone.Core.Jobs
|
|||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ReferenceDataProvider _referenceDataProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider)
|
||||
ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_referenceDataProvider = referenceDataProvider;
|
||||
_configProvider = configProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public UpdateInfoJob()
|
||||
|
@ -49,14 +51,14 @@ namespace NzbDrone.Core.Jobs
|
|||
if (options == null || options.SeriesId == 0)
|
||||
{
|
||||
if (_configProvider.IgnoreArticlesWhenSortingSeries)
|
||||
seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
seriesToUpdate = _seriesRepository.All().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
|
||||
else
|
||||
seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList();
|
||||
seriesToUpdate = _seriesRepository.All().OrderBy(o => o.Title).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
seriesToUpdate = new List<Series> { _seriesProvider.GetSeries(options.SeriesId) };
|
||||
seriesToUpdate = new List<Series> { _seriesRepository.Get(options.SeriesId) };
|
||||
}
|
||||
|
||||
//Update any Daily Series in the DB with the IsDaily flag
|
||||
|
|
|
@ -302,6 +302,7 @@
|
|||
<Compile Include="Model\JobQueueItem.cs" />
|
||||
<Compile Include="Model\LanguageType.cs" />
|
||||
<Compile Include="Model\MisnamedEpisodeModel.cs" />
|
||||
<Compile Include="Tv\SeriesRepository.cs" />
|
||||
<Compile Include="Tv\QualityModel.cs" />
|
||||
<Compile Include="Model\Sabnzbd\SabAddResponse.cs" />
|
||||
<Compile Include="Model\Sabnzbd\SabHistoryItem.cs" />
|
||||
|
|
|
@ -25,12 +25,13 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly ConfigProvider _configProvider;
|
||||
private readonly RecycleBinProvider _recycleBinProvider;
|
||||
private readonly MediaInfoProvider _mediaInfoProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
public DiskScanProvider(DiskProvider diskProvider, EpisodeProvider episodeProvider,
|
||||
SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, DownloadProvider downloadProvider,
|
||||
SignalRProvider signalRProvider, ConfigProvider configProvider,
|
||||
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider)
|
||||
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
|
@ -42,6 +43,7 @@ namespace NzbDrone.Core.Providers
|
|||
_configProvider = configProvider;
|
||||
_recycleBinProvider = recycleBinProvider;
|
||||
_mediaInfoProvider = mediaInfoProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public DiskScanProvider()
|
||||
|
@ -97,7 +99,7 @@ namespace NzbDrone.Core.Providers
|
|||
//Todo: Move the episode linking to here, instead of import (or rename import)
|
||||
|
||||
series.LastDiskSync = DateTime.Now;
|
||||
_seriesProvider.UpdateSeries(series);
|
||||
_seriesRepository.Update(series);
|
||||
|
||||
return importedFiles;
|
||||
}
|
||||
|
@ -190,7 +192,7 @@ namespace NzbDrone.Core.Providers
|
|||
if (episodeFile == null)
|
||||
throw new ArgumentNullException("episodeFile");
|
||||
|
||||
var series = _seriesProvider.GetSeries(episodeFile.SeriesId);
|
||||
var series = _seriesRepository.Get(episodeFile.SeriesId);
|
||||
var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId);
|
||||
string newFileName = _mediaFileProvider.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
|
||||
var newFile = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||
|
|
|
@ -18,14 +18,16 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
public PostDownloadProvider(DiskProvider diskProvider, DiskScanProvider diskScanProvider,
|
||||
SeriesProvider seriesProvider, MetadataProvider metadataProvider)
|
||||
SeriesProvider seriesProvider, MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public PostDownloadProvider()
|
||||
|
@ -38,7 +40,7 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
try
|
||||
{
|
||||
if (!_seriesProvider.SeriesPathExists(subfolder))
|
||||
if (!_seriesRepository.SeriesPathExists(subfolder))
|
||||
{
|
||||
ProcessDownload(new DirectoryInfo(subfolder));
|
||||
}
|
||||
|
@ -77,7 +79,7 @@ namespace NzbDrone.Core.Providers
|
|||
}
|
||||
|
||||
string seriesName = Parser.ParseSeriesName(RemoveStatusFromFolderName(subfolderInfo.Name));
|
||||
var series = _seriesProvider.FindSeries(seriesName);
|
||||
var series = _seriesRepository.Get(seriesName);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
|
@ -147,7 +149,7 @@ namespace NzbDrone.Core.Providers
|
|||
}
|
||||
|
||||
var seriesName = Parser.ParseSeriesName(Path.GetFileNameWithoutExtension(videoFile));
|
||||
var series = _seriesProvider.FindSeries(seriesName);
|
||||
var series = _seriesRepository.Get(seriesName);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
|
|
|
@ -15,14 +15,16 @@ namespace NzbDrone.Core.Providers.Search
|
|||
{
|
||||
public class DailyEpisodeSearch : SearchBase
|
||||
{
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DailyEpisodeSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider)
|
||||
: base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public DailyEpisodeSearch()
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace NzbDrone.Core.Providers.Search
|
|||
|
||||
public EpisodeSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider)
|
||||
: base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider,seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace NzbDrone.Core.Providers.Search
|
|||
|
||||
public PartialSeasonSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider)
|
||||
: base(seriesProvider, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace NzbDrone.Core.Providers.Search
|
|||
public abstract class SearchBase
|
||||
{
|
||||
protected readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
protected readonly EpisodeProvider _episodeProvider;
|
||||
protected readonly DownloadProvider _downloadProvider;
|
||||
protected readonly IndexerProvider _indexerProvider;
|
||||
|
@ -25,12 +26,13 @@ namespace NzbDrone.Core.Providers.Search
|
|||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
protected SearchBase(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider,
|
||||
protected SearchBase(SeriesProvider seriesProvider,ISeriesRepository seriesRepository, EpisodeProvider episodeProvider, DownloadProvider downloadProvider,
|
||||
IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
_episodeProvider = episodeProvider;
|
||||
_downloadProvider = downloadProvider;
|
||||
_indexerProvider = indexerProvider;
|
||||
|
@ -105,7 +107,7 @@ namespace NzbDrone.Core.Providers.Search
|
|||
items.Add(item);
|
||||
|
||||
logger.Trace("Analysing report " + episodeParseResult);
|
||||
episodeParseResult.Series = _seriesProvider.FindSeries(episodeParseResult.CleanTitle);
|
||||
episodeParseResult.Series = _seriesRepository.Get(episodeParseResult.CleanTitle);
|
||||
|
||||
if(episodeParseResult.Series == null || episodeParseResult.Series.SeriesId != series.SeriesId)
|
||||
{
|
||||
|
|
|
@ -16,16 +16,18 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly DownloadProvider _downloadProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public SearchHistoryProvider(IDatabase database, SeriesProvider seriesProvider,
|
||||
DownloadProvider downloadProvider, EpisodeProvider episodeProvider)
|
||||
DownloadProvider downloadProvider, EpisodeProvider episodeProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_database = database;
|
||||
_seriesProvider = seriesProvider;
|
||||
_downloadProvider = downloadProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public SearchHistoryProvider()
|
||||
|
@ -105,7 +107,7 @@ namespace NzbDrone.Core.Providers
|
|||
var item = _database.Single<SearchHistoryItem>(itemId);
|
||||
logger.Info("Starting Force Download of: {0}", item.ReportTitle);
|
||||
var searchResult = _database.Single<SearchHistory>(item.SearchHistoryId);
|
||||
var series = _seriesProvider.GetSeries(searchResult.SeriesId);
|
||||
var series = _seriesRepository.Get(searchResult.SeriesId);
|
||||
|
||||
var parseResult = Parser.ParseTitle(item.ReportTitle);
|
||||
parseResult.NzbUrl = item.NzbUrl;
|
||||
|
|
|
@ -19,15 +19,17 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly PartialSeasonSearch _partialSeasonSearch;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public SearchProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
PartialSeasonSearch partialSeasonSearch)
|
||||
PartialSeasonSearch partialSeasonSearch,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_partialSeasonSearch = partialSeasonSearch;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public SearchProvider()
|
||||
|
@ -36,7 +38,7 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
public virtual List<int> SeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber)
|
||||
{
|
||||
var series = _seriesProvider.GetSeries(seriesId);
|
||||
var series = _seriesRepository.Get(seriesId);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
|
@ -65,7 +67,7 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
public virtual List<int> PartialSeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber)
|
||||
{
|
||||
var series = _seriesProvider.GetSeries(seriesId);
|
||||
var series = _seriesRepository.Get(seriesId);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
|
|
|
@ -13,15 +13,17 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly XemCommunicationProvider _xemCommunicationProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public XemProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
XemCommunicationProvider xemCommunicationProvider)
|
||||
XemCommunicationProvider xemCommunicationProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_xemCommunicationProvider = xemCommunicationProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public XemProvider()
|
||||
|
@ -34,7 +36,7 @@ namespace NzbDrone.Core.Providers
|
|||
try
|
||||
{
|
||||
var ids = _xemCommunicationProvider.GetXemSeriesIds();
|
||||
var series = _seriesProvider.GetAllSeries();
|
||||
var series = _seriesRepository.All();
|
||||
var wantedSeries = series.Where(s => ids.Contains(s.SeriesId)).ToList();
|
||||
|
||||
foreach(var ser in wantedSeries)
|
||||
|
@ -62,7 +64,7 @@ namespace NzbDrone.Core.Providers
|
|||
return;
|
||||
}
|
||||
|
||||
var series = _seriesProvider.GetSeries(seriesId);
|
||||
var series = _seriesRepository.Get(seriesId);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
|
@ -112,7 +114,7 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
_logger.Trace("Setting UseSceneMapping for {0}", series.Title);
|
||||
series.UseSceneNumbering = true;
|
||||
_seriesProvider.UpdateSeries(series);
|
||||
_seriesRepository.Update(series);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -24,18 +24,20 @@ namespace NzbDrone.Core.RootFolders
|
|||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IBasicRepository<RootFolder> _rootFolderRepository;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
|
||||
public RootFolderService(IBasicRepository<RootFolder> rootFolderRepository, SeriesProvider seriesProvider, DiskProvider diskProvider)
|
||||
public RootFolderService(IBasicRepository<RootFolder> rootFolderRepository, SeriesProvider seriesProvider, DiskProvider diskProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_rootFolderRepository = rootFolderRepository;
|
||||
_diskProvider = diskProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
_seriesProvider = seriesProvider;
|
||||
}
|
||||
|
||||
public virtual List<RootFolder> All()
|
||||
{
|
||||
var rootFolders = _rootFolderRepository.All();
|
||||
var rootFolders = _rootFolderRepository.All().ToList();
|
||||
|
||||
rootFolders.ForEach(folder =>
|
||||
{
|
||||
|
@ -60,7 +62,7 @@ namespace NzbDrone.Core.RootFolders
|
|||
if (All().Exists(r => DiskProvider.PathEquals(r.Path, rootFolder.Path)))
|
||||
throw new InvalidOperationException("Root directory already exist.");
|
||||
|
||||
_rootFolderRepository.Add(rootFolder);
|
||||
_rootFolderRepository.Insert(rootFolder);
|
||||
|
||||
rootFolder.FreeSpace = _diskProvider.FreeDiskSpace(rootFolder.Path);
|
||||
rootFolder.UnmappedFolders = GetUnmappedFolders(rootFolder.Path);
|
||||
|
@ -88,7 +90,7 @@ namespace NzbDrone.Core.RootFolders
|
|||
|
||||
foreach (string seriesFolder in _diskProvider.GetDirectories(path))
|
||||
{
|
||||
if (!_seriesProvider.SeriesPathExists(seriesFolder))
|
||||
if (!_seriesRepository.SeriesPathExists(seriesFolder))
|
||||
{
|
||||
var di = new DirectoryInfo(seriesFolder.Normalize());
|
||||
results.Add(new UnmappedFolder{ Name = di.Name, Path = di.FullName });
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public class Series
|
||||
public class Series : ModelBase
|
||||
{
|
||||
public virtual int SeriesId { get; set; }
|
||||
|
||||
|
|
|
@ -15,10 +15,9 @@ namespace NzbDrone.Core.Tv
|
|||
{
|
||||
public class SeriesProvider
|
||||
{
|
||||
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly TvDbProvider _tvDbProvider;
|
||||
private readonly IDatabase _database;
|
||||
private readonly SceneMappingProvider _sceneNameMappingProvider;
|
||||
private readonly BannerProvider _bannerProvider;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
|
@ -28,12 +27,12 @@ namespace NzbDrone.Core.Tv
|
|||
|
||||
private static readonly Regex TimeRegex = new Regex(@"^(?<time>\d+:?\d*)\W*(?<meridiem>am|pm)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider,
|
||||
public SeriesProvider(ISeriesRepository seriesRepository, ConfigProvider configProviderProvider,
|
||||
TvDbProvider tvDbProviderProvider, SceneMappingProvider sceneNameMappingProvider,
|
||||
BannerProvider bannerProvider, MetadataProvider metadataProvider,
|
||||
TvRageMappingProvider tvRageMappingProvider)
|
||||
{
|
||||
_database = database;
|
||||
_seriesRepository = seriesRepository;
|
||||
_configProvider = configProviderProvider;
|
||||
_tvDbProvider = tvDbProviderProvider;
|
||||
_sceneNameMappingProvider = sceneNameMappingProvider;
|
||||
|
@ -42,62 +41,16 @@ namespace NzbDrone.Core.Tv
|
|||
_tvRageMappingProvider = tvRageMappingProvider;
|
||||
}
|
||||
|
||||
public SeriesProvider()
|
||||
|
||||
public bool IsMonitored(int id)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual IList<Series> GetAllSeries()
|
||||
{
|
||||
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
|
||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId");
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
public virtual IList<Series> GetAllSeriesWithEpisodeCount()
|
||||
{
|
||||
var series = _database
|
||||
.Fetch<Series, QualityProfile>(@"SELECT Series.SeriesId, Series.Title, Series.CleanTitle, Series.Status, Series.Overview, Series.AirsDayOfWeek, Series.AirTimes,
|
||||
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, Series.BacklogSetting, Series.Network,
|
||||
Series.UtcOffset, Series.CustomStartDate, SUM(CASE WHEN Ignored = 0 AND Airdate <= @0 THEN 1 ELSE 0 END) AS EpisodeCount,
|
||||
SUM(CASE WHEN Episodes.Ignored = 0 AND Episodes.EpisodeFileId > 0 AND Episodes.AirDate <= @0 THEN 1 ELSE 0 END) as EpisodeFileCount,
|
||||
MAX(Episodes.SeasonNumber) as SeasonCount, MIN(CASE WHEN AirDate < @0 OR Ignored = 1 THEN NULL ELSE AirDate END) as NextAiring,
|
||||
QualityProfiles.QualityProfileId, QualityProfiles.Name, QualityProfiles.Cutoff, QualityProfiles.SonicAllowed
|
||||
FROM Series
|
||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
||||
LEFT JOIN Episodes ON Series.SeriesId = Episodes.SeriesId
|
||||
WHERE Series.LastInfoSync IS NOT NULL
|
||||
GROUP BY Series.SeriesId, Series.Title, Series.CleanTitle, Series.Status, Series.Overview, Series.AirsDayOfWeek, Series.AirTimes,
|
||||
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, Series.BacklogSetting, Series.Network,
|
||||
Series.UtcOffset, Series.CustomStartDate,
|
||||
QualityProfiles.QualityProfileId, QualityProfiles.Name, QualityProfiles.Cutoff, QualityProfiles.SonicAllowed",DateTime.Today);
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
public virtual Series GetSeries(int seriesId)
|
||||
{
|
||||
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
|
||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
||||
WHERE seriesId= @0", seriesId).Single();
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a series is being actively watched.
|
||||
/// </summary>
|
||||
/// <param name = "id">The TVDB ID of the series</param>
|
||||
/// <returns>Whether or not the show is monitored</returns>
|
||||
public virtual bool IsMonitored(long id)
|
||||
{
|
||||
return GetAllSeries().Any(c => c.SeriesId == id && c.Monitored);
|
||||
return _seriesRepository.Get(id).Monitored;
|
||||
}
|
||||
|
||||
public virtual Series UpdateSeriesInfo(int seriesId)
|
||||
{
|
||||
var tvDbSeries = _tvDbProvider.GetSeries(seriesId, false, true);
|
||||
var series = GetSeries(seriesId);
|
||||
var series = _seriesRepository.Get(seriesId);
|
||||
|
||||
series.SeriesId = tvDbSeries.Id;
|
||||
series.Title = tvDbSeries.SeriesName;
|
||||
|
@ -119,26 +72,26 @@ namespace NzbDrone.Core.Tv
|
|||
|
||||
try
|
||||
{
|
||||
if(series.TvRageId == 0)
|
||||
if (series.TvRageId == 0)
|
||||
series = _tvRageMappingProvider.FindMatchingTvRageSeries(series);
|
||||
}
|
||||
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException("Error getting TvRage information for series: " + series.Title, ex);
|
||||
}
|
||||
|
||||
UpdateSeries(series);
|
||||
_seriesRepository.Update(series);
|
||||
_metadataProvider.CreateForSeries(series, tvDbSeries);
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
public virtual void AddSeries(string title, string path, int tvDbSeriesId, int qualityProfileId, DateTime? airedAfter)
|
||||
public void AddSeries(string title, string path, int tvDbSeriesId, int qualityProfileId, DateTime? airedAfter)
|
||||
{
|
||||
logger.Info("Adding Series [{0}] Path: [{1}]", tvDbSeriesId, path);
|
||||
|
||||
if (tvDbSeriesId <=0)
|
||||
if (tvDbSeriesId <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("tvDbSeriesId", tvDbSeriesId.ToString());
|
||||
}
|
||||
|
@ -158,96 +111,15 @@ namespace NzbDrone.Core.Tv
|
|||
if (airedAfter.HasValue)
|
||||
repoSeries.CustomStartDate = airedAfter;
|
||||
|
||||
_database.Insert(repoSeries);
|
||||
_seriesRepository.Insert(repoSeries);
|
||||
}
|
||||
|
||||
public virtual Series FindSeries(string title)
|
||||
{
|
||||
try
|
||||
{
|
||||
var normalizeTitle = Parser.NormalizeTitle(title);
|
||||
|
||||
var seriesId = _sceneNameMappingProvider.GetSeriesId(normalizeTitle);
|
||||
if (seriesId != null)
|
||||
{
|
||||
return GetSeries(seriesId.Value);
|
||||
}
|
||||
|
||||
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
|
||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
||||
WHERE CleanTitle = @0", normalizeTitle).SingleOrDefault();
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
//This will catch InvalidOperationExceptions(Sequence contains no element)
|
||||
//that may be thrown for GetSeries due to the series being in SceneMapping, but not in the users Database
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UpdateSeries(Series series)
|
||||
{
|
||||
_database.Update(series);
|
||||
}
|
||||
|
||||
public virtual void DeleteSeries(int seriesId)
|
||||
{
|
||||
var series = GetSeries(seriesId);
|
||||
logger.Warn("Deleting Series [{0}]", series.Title);
|
||||
|
||||
using (var tran = _database.GetTransaction())
|
||||
{
|
||||
//Delete History, Files, Episodes, Seasons then the Series
|
||||
|
||||
logger.Debug("Deleting History Items from DB for Series: {0}", series.Title);
|
||||
_database.Delete<History>("WHERE SeriesId=@0", seriesId);
|
||||
|
||||
logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.Title);
|
||||
_database.Delete<EpisodeFile>("WHERE SeriesId=@0", seriesId);
|
||||
|
||||
logger.Debug("Deleting Seasons from DB for Series: {0}", series.Title);
|
||||
_database.Delete<Season>("WHERE SeriesId=@0", seriesId);
|
||||
|
||||
logger.Debug("Deleting Episodes from DB for Series: {0}", series.Title);
|
||||
_database.Delete<Episode>("WHERE SeriesId=@0", seriesId);
|
||||
|
||||
logger.Debug("Deleting Series from DB {0}", series.Title);
|
||||
_database.Delete<Series>("WHERE SeriesId=@0", seriesId);
|
||||
|
||||
logger.Info("Successfully deleted Series [{0}]", series.Title);
|
||||
|
||||
tran.Complete();
|
||||
}
|
||||
|
||||
logger.Trace("Beginning deletion of banner for SeriesID: ", seriesId);
|
||||
_bannerProvider.Delete(seriesId);
|
||||
}
|
||||
|
||||
public virtual bool SeriesPathExists(string path)
|
||||
{
|
||||
return GetAllSeries().Any(s => DiskProvider.PathEquals(s.Path, path));
|
||||
}
|
||||
|
||||
public virtual List<Series> SearchForSeries(string title)
|
||||
{
|
||||
var query = String.Format("%{0}%", title);
|
||||
|
||||
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
|
||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
||||
WHERE Title LIKE @0", query);
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
public virtual void UpdateFromSeriesEditor(IList<Series> editedSeries)
|
||||
{
|
||||
var allSeries = GetAllSeries();
|
||||
var allSeries = _seriesRepository.All();
|
||||
|
||||
foreach(var series in allSeries)
|
||||
foreach (var series in allSeries)
|
||||
{
|
||||
//Only update parameters that can be changed in MassEdit
|
||||
var edited = editedSeries.Single(s => s.SeriesId == series.SeriesId);
|
||||
|
@ -257,9 +129,10 @@ namespace NzbDrone.Core.Tv
|
|||
series.BacklogSetting = edited.BacklogSetting;
|
||||
series.Path = edited.Path;
|
||||
series.CustomStartDate = edited.CustomStartDate;
|
||||
|
||||
_seriesRepository.Update(series);
|
||||
}
|
||||
|
||||
_database.UpdateMany(allSeries);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public interface ISeriesRepository : IBasicRepository<Series>
|
||||
{
|
||||
bool SeriesPathExists(string path);
|
||||
List<Series> Search(string title);
|
||||
Series Get(string cleanTitle);
|
||||
}
|
||||
|
||||
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
|
||||
{
|
||||
public SeriesRepository(IObjectDatabase objectDatabase)
|
||||
: base(objectDatabase)
|
||||
{
|
||||
}
|
||||
|
||||
public bool SeriesPathExists(string path)
|
||||
{
|
||||
return Queryable.Any(s => DiskProvider.PathEquals(s.Path, path));
|
||||
}
|
||||
|
||||
public List<Series> Search(string title)
|
||||
{
|
||||
return Queryable.Where(s => s.Title.Contains(title)).ToList();
|
||||
}
|
||||
|
||||
public Series Get(string cleanTitle)
|
||||
{
|
||||
return Queryable.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue