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