mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
fixed more tests.
This commit is contained in:
parent
48880e4964
commit
048162a0ef
@ -11,9 +11,9 @@ namespace NzbDrone.Api.Calendar
|
||||
{
|
||||
public class CalendarModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly IEpisodeService _episodeService;
|
||||
|
||||
public CalendarModule(EpisodeService episodeService)
|
||||
public CalendarModule(IEpisodeService episodeService)
|
||||
: base("/calendar")
|
||||
{
|
||||
_episodeService = episodeService;
|
||||
|
@ -9,9 +9,9 @@ namespace NzbDrone.Api.Episodes
|
||||
{
|
||||
public class EpisodeModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly IEpisodeService _episodeService;
|
||||
|
||||
public EpisodeModule(EpisodeService episodeService)
|
||||
public EpisodeModule(IEpisodeService episodeService)
|
||||
: base("/episodes")
|
||||
{
|
||||
_episodeService = episodeService;
|
||||
|
@ -10,9 +10,9 @@ namespace NzbDrone.Api.Missing
|
||||
{
|
||||
public class MissingModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly IEpisodeService _episodeService;
|
||||
|
||||
public MissingModule(EpisodeService episodeService)
|
||||
public MissingModule(IEpisodeService episodeService)
|
||||
: base("/missing")
|
||||
{
|
||||
_episodeService = episodeService;
|
||||
|
@ -117,7 +117,7 @@ public SeriesValidator()
|
||||
{
|
||||
RuleSet("POST", () =>
|
||||
{
|
||||
RuleFor(s => ((ModelBase)s).Id).GreaterThan(0);
|
||||
RuleFor(s => s.Id).GreaterThan(0);
|
||||
RuleFor(s => s.Path).NotEmpty().Must(_diskProvider.FolderExists);
|
||||
RuleFor(s => s.QualityProfileId).GreaterThan(0);
|
||||
});
|
||||
|
@ -56,8 +56,8 @@ private byte[] Header(PacketType packetType, int numberOfPackets, int currentPac
|
||||
}
|
||||
else
|
||||
{
|
||||
header[6] = (byte)(((ushort)PacketType.Blob & 0xff00) >> 8);
|
||||
header[7] = (byte)((ushort)PacketType.Blob & 0x00ff);
|
||||
header[6] = ((ushort)PacketType.Blob & 0xff00) >> 8;
|
||||
header[7] = (ushort)PacketType.Blob & 0x00ff;
|
||||
}
|
||||
|
||||
header[8] = (byte)((currentPacket & 0xff000000) >> 24);
|
||||
|
2
NzbDrone.Console/app.config
Normal file
2
NzbDrone.Console/app.config
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration />
|
@ -35,8 +35,8 @@ public void Setup()
|
||||
Mocker.Resolve<QualityUpgradableSpecification>();
|
||||
_upgradeDisk = Mocker.Resolve<UpgradeDiskSpecification>();
|
||||
|
||||
firstFile = new EpisodeFile { Quality = Quality.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
|
||||
secondFile = new EpisodeFile { Quality = Quality.Bluray1080p, Proper = true, DateAdded = DateTime.Now };
|
||||
firstFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, true), DateAdded = DateTime.Now };
|
||||
secondFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, true), DateAdded = DateTime.Now };
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = null } };
|
||||
var doubleEpisodeList = new List<Episode> { new Episode { EpisodeFile = firstFile }, new Episode { EpisodeFile = secondFile }, new Episode { EpisodeFile = null } };
|
||||
@ -66,12 +66,12 @@ public void Setup()
|
||||
|
||||
private void WithFirstFileUpgradable()
|
||||
{
|
||||
firstFile.Quality = Quality.SDTV;
|
||||
firstFile.Quality = new QualityModel(Quality.SDTV);
|
||||
}
|
||||
|
||||
private void WithSecondFileUpgradable()
|
||||
{
|
||||
secondFile.Quality = Quality.SDTV;
|
||||
secondFile.Quality = new QualityModel(Quality.SDTV);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -120,8 +120,7 @@ public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_qualities_are_the_same()
|
||||
{
|
||||
firstFile.Quality = Quality.WEBDL1080p;
|
||||
firstFile.Proper = false;
|
||||
firstFile.Quality = new QualityModel(Quality.WEBDL1080p);
|
||||
parseResultSingle.Quality = new QualityModel(Quality.WEBDL1080p, false);
|
||||
_upgradeDisk.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -13,7 +9,7 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class BlackholeProviderFixture : CoreTest
|
@ -1,19 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTests
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
||||
{
|
||||
public class DownloadNzbFixture : CoreTest
|
||||
{
|
@ -1,19 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTests
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetProviderTests
|
||||
{
|
||||
public class QueueFixture : CoreTest
|
||||
{
|
@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@ -13,7 +9,7 @@
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PneumaticProviderFixture : CoreTest
|
@ -1,24 +1,19 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
@ -1,24 +1,15 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
87
NzbDrone.Core.Test/Download/DownloadServiceFixture.cs
Normal file
87
NzbDrone.Core.Test/Download/DownloadServiceFixture.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadServiceFixture : CoreTest<DownloadService>
|
||||
{
|
||||
private EpisodeParseResult _parseResult;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IProvideDownloadClient>()
|
||||
.Setup(c => c.GetDownloadClient()).Returns(Mocker.GetMock<IDownloadClient>().Object);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.Id = 12)
|
||||
.TheNext(1).With(s => s.Id = 99)
|
||||
.All().With(s => s.SeriesId = 5)
|
||||
.Build().ToList();
|
||||
|
||||
_parseResult = Builder<EpisodeParseResult>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.DVD, false))
|
||||
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
||||
.With(c => c.EpisodeNumbers = new List<int> { 2 })
|
||||
.With(c => c.Episodes = episodes)
|
||||
.Build();
|
||||
}
|
||||
|
||||
private void WithSuccessfulAdd()
|
||||
{
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<bool>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedAdd()
|
||||
{
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<bool>()))
|
||||
.Returns(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_publish_on_grab_event()
|
||||
{
|
||||
WithSuccessfulAdd();
|
||||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
VerifyEventPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_grab_using_client()
|
||||
{
|
||||
WithSuccessfulAdd();
|
||||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), true), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_not_publish_on_failed_grab_event()
|
||||
{
|
||||
WithFailedAdd();
|
||||
|
||||
Subject.DownloadReport(_parseResult);
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -18,10 +18,10 @@ public class TestSearch : IndexerSearchBase
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public TestSearch(IEpisodeService episodeService, IDownloadProvider downloadProvider,
|
||||
public TestSearch(IEpisodeService episodeService, IDownloadService downloadService,
|
||||
IIndexerService indexerService, ISceneMappingService sceneMappingService,
|
||||
IDownloadDirector downloadDirector, ISeriesRepository seriesRepository)
|
||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
: base(seriesRepository, episodeService, downloadService, indexerService, sceneMappingService,
|
||||
downloadDirector)
|
||||
{
|
||||
}
|
||||
|
@ -85,8 +85,7 @@ public void should_use_EpisodeFiles_quality()
|
||||
var file = Builder<EpisodeFile>.CreateNew()
|
||||
.With(f => f.SeriesId = fakeSeries.Id)
|
||||
.With(f => f.Path = currentFilename)
|
||||
.With(f => f.Quality = Quality.WEBDL720p)
|
||||
.With(f => f.Proper = false)
|
||||
.With(f => f.Quality = new QualityModel(Quality.WEBDL720p))
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
@ -137,8 +136,7 @@ public void should_log_error_and_return_null_when_source_file_does_not_exists()
|
||||
var file = Builder<EpisodeFile>.CreateNew()
|
||||
.With(f => f.SeriesId = fakeSeries.Id)
|
||||
.With(f => f.Path = currentFilename)
|
||||
.With(f => f.Quality = Quality.WEBDL720p)
|
||||
.With(f => f.Proper = false)
|
||||
.With(f => f.Quality = new QualityModel(Quality.WEBDL720p))
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
|
@ -4,7 +4,9 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFileTests
|
||||
{
|
||||
@ -17,9 +19,10 @@ public void get_files_by_series()
|
||||
var files = Builder<EpisodeFile>.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(c => c.Id = 0)
|
||||
.With(c => c.Quality =new QualityModel(Quality.Bluray720p))
|
||||
.Random(4)
|
||||
.With(s => s.SeriesId = 12)
|
||||
.Build();
|
||||
.BuildListOfNew();
|
||||
|
||||
|
||||
Db.InsertMany(files);
|
||||
|
@ -135,6 +135,13 @@
|
||||
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
||||
<Compile Include="Datastore\MappingExtentionFixture.cs" />
|
||||
<Compile Include="Datastore\ObjectDatabaseFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\BlackholeProviderFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\NzbgetProviderTests\DownloadNzbFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\NzbgetProviderTests\QueueFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\PneumaticProviderFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\SabProviderTests\QueueFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\SabProviderTests\SabProviderFixture.cs" />
|
||||
<Compile Include="Download\DownloadServiceFixture.cs" />
|
||||
<Compile Include="Framework\CoreTest.cs" />
|
||||
<Compile Include="Framework\DbTest.cs" />
|
||||
<Compile Include="Framework\NBuilderExtensions.cs" />
|
||||
@ -158,9 +165,6 @@
|
||||
<Compile Include="MediaFileTests\MediaFileRepositoryFixture.cs" />
|
||||
<Compile Include="MediaFileTests\EpisodeFileMoverFixture.cs" />
|
||||
<Compile Include="MetadataSourceTests\TracktProxyFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\DownloadNzbFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\QueueFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTests\ContainsRecentEpisode.cs" />
|
||||
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
|
||||
<Compile Include="HelperTests\XElementHelperTests\ConvertToDayOfWeekFixture.cs" />
|
||||
<Compile Include="Qualities\QualityFixture.cs" />
|
||||
@ -176,8 +180,6 @@
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\CleanUpDropFolderFixture.cs" />
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\ScanFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\PneumaticProviderFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\GetEpisodeBySceneNumberFixture.cs" />
|
||||
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDropDirectoryFixture.cs" />
|
||||
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessVideoFileFixture.cs" />
|
||||
<Compile Include="ProviderTests\RecycleBinProviderTests\CleanupFixture.cs" />
|
||||
@ -192,9 +194,7 @@
|
||||
<Compile Include="DecisionEngineTests\UpgradeDiskSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\QualityUpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\QualityUpgradableSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\BlackholeProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\NotificationProviderTests\NotificationProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\QueueFixture.cs" />
|
||||
<Compile Include="Indexers\NewznabServiceTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\FreeDiskSpaceTest.cs" />
|
||||
<Compile Include="ProviderTests\ProwlProviderTest.cs" />
|
||||
@ -223,7 +223,6 @@
|
||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||
<Compile Include="OrganizerTests\GetNewFilenameFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTests\DownloadProviderFixture.cs" />
|
||||
<Compile Include="EpisodeStatusTest.cs" />
|
||||
<Compile Include="JobTests\DiskScanJobTest.cs" />
|
||||
<Compile Include="IndexerTests\IndexerFixture.cs" />
|
||||
@ -240,7 +239,6 @@
|
||||
<Compile Include="ParserTests\ParserFixture.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Qualities\QualityProfileFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\SabProviderFixture.cs" />
|
||||
<Compile Include="TvTests\SeriesProviderTest.cs" />
|
||||
<Compile Include="XbmcVersionTests.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -63,7 +63,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Dash()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("South Park - S15E06 - City Sushi [HDTV-720p]", result);
|
||||
@ -90,7 +90,7 @@ public void GetNewFilename_Episode_Quality_1x05_Dash()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("15x06 - City Sushi [HDTV-720p]", result);
|
||||
@ -117,7 +117,7 @@ public void GetNewFilename_Series_Quality_01x05_Space()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("South Park 05x06 [HDTV-720p]", result);
|
||||
@ -145,7 +145,7 @@ public void GetNewFilename_Series_s01e05_Space()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("South Park s05e06", result);
|
||||
@ -172,7 +172,7 @@ public void GetNewFilename_Series_Episode_s01e05_Periods()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("South.Park.s05e06.City.Sushi", result);
|
||||
@ -199,7 +199,7 @@ public void GetNewFilename_Series_Episode_s01e05_Dash_Periods_Quality()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("South.Park.-.s05e06.-.City.Sushi.[HDTV-720p]", result);
|
||||
@ -227,7 +227,7 @@ public void GetNewFilename_S01E05_Dash()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("S15E06", result);
|
||||
@ -261,7 +261,7 @@ public void GetNewFilename_multi_Series_Episode_Quality_S01E05_Scene_Dash()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("The Mentalist - S03E23-E24 - Strawberries and Cream [HDTV-720p]", result);
|
||||
@ -295,7 +295,7 @@ public void GetNewFilename_multi_Episode_Quality_1x05_Repeat_Dash()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("3x23x24 - Strawberries and Cream [HDTV-720p]", result);
|
||||
@ -329,7 +329,7 @@ public void GetNewFilename_multi_Episode_Quality_01x05_Repeat_Space()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("3x23x24 Strawberries and Cream [HDTV-720p]", result);
|
||||
@ -363,7 +363,7 @@ public void GetNewFilename_multi_Series_Episode_s01e05_Duplicate_Period()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("The.Mentalist.s03e23.s03e24.Strawberries.and.Cream", result);
|
||||
@ -397,7 +397,7 @@ public void GetNewFilename_multi_Series_S01E05_Extend_Dash_Period()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("The.Mentalist.-.S03E23-24", result);
|
||||
@ -431,7 +431,7 @@ public void GetNewFilename_multi_1x05_Repeat_Dash_Period()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episodeOne, episodeTwo }, new Series { Title = "The Mentalist" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("3x23x24", result);
|
||||
@ -456,7 +456,7 @@ public void GetNewFilename_should_append_proper_when_proper_and_append_quality_i
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = true });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p, true) });
|
||||
|
||||
|
||||
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p] [Proper]");
|
||||
@ -481,7 +481,7 @@ public void GetNewFilename_should_not_append_proper_when_not_proper_and_append_q
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
result.Should().Be("South Park - S15E06 - City Sushi [HDTV-720p]");
|
||||
@ -506,7 +506,7 @@ public void GetNewFilename_should_not_append_proper_when_proper_and_append_quali
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = true });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p, true) });
|
||||
|
||||
|
||||
result.Should().Be("South Park - S15E06 - City Sushi");
|
||||
@ -538,7 +538,7 @@ public void GetNewFilename_should_order_multiple_episode_files_in_numerical_orde
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
||||
@ -565,7 +565,7 @@ public void GetNewFilename_Series_Episode_Quality_S01E05_Period()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("South Park.S15E06.City Sushi [HDTV-720p]", result);
|
||||
@ -592,7 +592,7 @@ public void GetNewFilename_Episode_Quality_1x05_Period()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode }, _series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
Assert.AreEqual("15x06.City Sushi [HDTV-720p]", result);
|
||||
@ -686,7 +686,7 @@ public void should_only_have_one_episodeTitle_when_episode_titles_are_the_same()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
result.Should().Be("30 Rock - S06E06-E07 - Hey, Baby, What's Wrong!");
|
||||
@ -718,7 +718,7 @@ public void should_have_two_episodeTitles_when_episode_titles_are_not_the_same()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode2, episode }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
result.Should().Be("30 Rock - S06E06-E07 - Hello + World");
|
||||
@ -756,7 +756,7 @@ public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
||||
.Build();
|
||||
|
||||
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
string result = Subject.BuildFilename(new List<Episode> { episode, episode2, episode3 }, new Series { Title = "30 Rock" }, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
|
||||
|
||||
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
|
||||
@ -787,7 +787,7 @@ public void should_use_airDate_if_series_isDaily()
|
||||
.Build();
|
||||
|
||||
var result = Subject
|
||||
.BuildFilename(episodes, series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
.BuildFilename(episodes, series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart [HDTV-720p]");
|
||||
}
|
||||
|
||||
@ -816,7 +816,7 @@ public void should_use_airDate_if_series_isDaily_no_episode_title()
|
||||
.Build();
|
||||
|
||||
var result = Subject
|
||||
.BuildFilename(episodes, series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
.BuildFilename(episodes, series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13");
|
||||
}
|
||||
|
||||
@ -845,7 +845,7 @@ public void should_set_airdate_to_unknown_if_not_available()
|
||||
.Build();
|
||||
|
||||
var result = Subject
|
||||
.BuildFilename(episodes, series, new EpisodeFile { Quality = Quality.HDTV720p, Proper = false });
|
||||
.BuildFilename(episodes, series, new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p) });
|
||||
result.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ public void import_new_file_with_better_same_quality_should_succeed(Quality curr
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(g => g.Quality = (Quality)currentFileQuality)
|
||||
.And(g => g.Proper = currentFileProper).Build()
|
||||
.With(g => g.Quality = new QualityModel(currentFileQuality, currentFileProper))
|
||||
.Build()
|
||||
).Build();
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ public void import_new_file_episode_has_same_or_better_quality_should_skip(strin
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.EpisodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(e => e.Quality = Quality.Bluray720p).Build()
|
||||
.With(e => e.Quality = new QualityModel(Quality.Bluray720p)).Build()
|
||||
)
|
||||
.Build();
|
||||
|
||||
@ -214,7 +214,7 @@ public void import_new_file_episode_has_better_quality_than_existing(string file
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.EpisodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(e => e.Quality = Quality.SDTV).Build()
|
||||
.With(e => e.Quality = new QualityModel(Quality.SDTV)).Build()
|
||||
)
|
||||
.Build();
|
||||
|
||||
@ -247,7 +247,7 @@ public void import_new_multi_part_file_episode_has_equal_or_better_quality_than_
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(f => f.Quality = Quality.SDTV)
|
||||
.With(f => f.Quality = new QualityModel(Quality.SDTV))
|
||||
.Build())
|
||||
.Build().ToList();
|
||||
|
||||
@ -278,7 +278,7 @@ public void skip_import_new_multi_part_file_episode_existing_has_better_quality(
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(f => f.Quality = Quality.Bluray720p)
|
||||
.With(f => f.Quality = new QualityModel(Quality.Bluray720p))
|
||||
.Build())
|
||||
.Build().ToList();
|
||||
|
||||
@ -310,7 +310,7 @@ public void import_new_multi_part_file_episode_replace_two_files()
|
||||
|
||||
var fakeEpisodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.Quality = Quality.SDTV)
|
||||
.With(e => e.Quality = new QualityModel(Quality.SDTV))
|
||||
.Build();
|
||||
|
||||
var fakeEpisode1 = Builder<Episode>.CreateNew()
|
||||
|
@ -1,92 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContainsRecentEpisode : CoreTest
|
||||
{
|
||||
private Episode _recentEpisode;
|
||||
private Episode _oldEpisode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_recentEpisode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.AirDate = DateTime.Today)
|
||||
.Build();
|
||||
|
||||
_oldEpisode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-365))
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_episode_aired_recently()
|
||||
{
|
||||
var epr = Builder<EpisodeParseResult>
|
||||
.CreateNew()
|
||||
.With(p => p.Episodes = new List<Episode>
|
||||
{
|
||||
_recentEpisode
|
||||
})
|
||||
.Build();
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_one_episode_aired_recently()
|
||||
{
|
||||
var epr = Builder<EpisodeParseResult>
|
||||
.CreateNew()
|
||||
.With(p => p.Episodes = new List<Episode>
|
||||
{
|
||||
_recentEpisode,
|
||||
_oldEpisode
|
||||
})
|
||||
.Build();
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_episode_did_not_air_recently()
|
||||
{
|
||||
var epr = Builder<EpisodeParseResult>
|
||||
.CreateNew()
|
||||
.With(p => p.Episodes = new List<Episode>
|
||||
{
|
||||
_oldEpisode
|
||||
})
|
||||
.Build();
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_no_episode_aired_recently()
|
||||
{
|
||||
var epr = Builder<EpisodeParseResult>
|
||||
.CreateNew()
|
||||
.With(p => p.Episodes = new List<Episode>
|
||||
{
|
||||
_oldEpisode,
|
||||
_oldEpisode
|
||||
})
|
||||
.Build();
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().ContainsRecentEpisode(epr).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadProviderFixture : CoreTest<DownloadProvider>
|
||||
{
|
||||
|
||||
|
||||
private void SetDownloadClient(DownloadClientType clientType)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(c => c.DownloadClient)
|
||||
.Returns(clientType);
|
||||
}
|
||||
|
||||
private EpisodeParseResult SetupParseResult()
|
||||
{
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.Id = 12)
|
||||
.TheNext(1).With(s => s.Id = 99)
|
||||
.All().With(s => s.SeriesId = 5)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(episodes);
|
||||
|
||||
return Builder<EpisodeParseResult>.CreateNew()
|
||||
.With(c => c.Quality = new QualityModel(Quality.DVD, false))
|
||||
.With(c => c.Series = Builder<Series>.CreateNew().Build())
|
||||
.With(c => c.EpisodeNumbers = new List<int> { 2 })
|
||||
.With(c => c.Episodes = episodes)
|
||||
.Build();
|
||||
}
|
||||
|
||||
private void WithSuccessfullAdd()
|
||||
{
|
||||
Mocker.GetMock<SabProvider>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<bool>()))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<BlackholeProvider>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<bool>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
private void WithFailedAdd()
|
||||
{
|
||||
Mocker.GetMock<SabProvider>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), false))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<BlackholeProvider>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), false))
|
||||
.Returns(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_publish_on_grab_event()
|
||||
{
|
||||
WithSuccessfullAdd();
|
||||
SetDownloadClient(DownloadClientType.Sabnzbd);
|
||||
|
||||
var parseResult = SetupParseResult();
|
||||
|
||||
|
||||
Subject.DownloadReport(parseResult);
|
||||
|
||||
|
||||
|
||||
Mocker.GetMock<SabProvider>()
|
||||
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), true), Times.Once());
|
||||
|
||||
Mocker.GetMock<BlackholeProvider>()
|
||||
.Verify(s => s.DownloadNzb(It.IsAny<String>(), It.IsAny<String>(), true), Times.Never());
|
||||
|
||||
|
||||
VerifyEventPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
[TestCase(DownloadClientType.Sabnzbd)]
|
||||
[TestCase(DownloadClientType.Blackhole)]
|
||||
public void Download_report_should_not_publish_grabbed_event(DownloadClientType clientType)
|
||||
{
|
||||
WithFailedAdd();
|
||||
SetDownloadClient(clientType);
|
||||
|
||||
var parseResult = SetupParseResult();
|
||||
|
||||
Subject.DownloadReport(parseResult);
|
||||
|
||||
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_sab_as_active_client()
|
||||
{
|
||||
SetDownloadClient(DownloadClientType.Sabnzbd);
|
||||
Subject.GetActiveDownloadClient().Should().BeAssignableTo<SabProvider>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_blackhole_as_active_client()
|
||||
{
|
||||
SetDownloadClient(DownloadClientType.Blackhole);
|
||||
Subject.GetActiveDownloadClient().Should().BeAssignableTo<BlackholeProvider>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
|
||||
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class GetEpisodeBySceneNumberFixture : DbTest
|
||||
{
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
||||
|
||||
_series = Builder<Series>
|
||||
.CreateNew()
|
||||
.Build();
|
||||
|
||||
Db.Insert(_series);
|
||||
}
|
||||
|
||||
public void WithNullSceneNumbering()
|
||||
{
|
||||
_episode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.SeriesId = _series.Id)
|
||||
.Build();
|
||||
|
||||
Db.Insert(_episode);
|
||||
}
|
||||
|
||||
public void WithSceneNumbering()
|
||||
{
|
||||
_episode = Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.SeriesId = _series.Id)
|
||||
.Build();
|
||||
|
||||
Db.Insert(_episode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_no_episodes_in_db()
|
||||
{
|
||||
Mocker.Resolve<EpisodeService>().GetEpisodeBySceneNumbering(_series.Id, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_no_matching_episode_is_found()
|
||||
{
|
||||
WithNullSceneNumbering();
|
||||
Mocker.Resolve<EpisodeService>().GetEpisodeBySceneNumbering(_series.Id, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_episode_if_matching_episode_is_found()
|
||||
{
|
||||
WithSceneNumbering();
|
||||
|
||||
var result = Mocker.Resolve<EpisodeService>()
|
||||
.GetEpisodeBySceneNumbering(_series.Id, _episode.SceneSeasonNumber, _episode.SceneEpisodeNumber);
|
||||
|
||||
result.Id.Should().Be(_episode.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -68,8 +68,7 @@ protected override void MainDbUpgrade()
|
||||
Create.TableForModel("EpisodeFiles")
|
||||
.WithColumn("SeriesId").AsInt32()
|
||||
.WithColumn("Path").AsString().Unique()
|
||||
.WithColumn("Quality").AsInt32()
|
||||
.WithColumn("Proper").AsBoolean()
|
||||
.WithColumn("Quality").AsString()
|
||||
.WithColumn("Size").AsInt64()
|
||||
.WithColumn("DateAdded").AsDateTime()
|
||||
.WithColumn("SeasonNumber").AsInt32()
|
||||
|
@ -6,13 +6,11 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||
{
|
||||
public class NotInQueueSpecification : IFetchableSpecification
|
||||
{
|
||||
private readonly DownloadProvider _downloadProvider;
|
||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||
|
||||
|
||||
public NotInQueueSpecification(DownloadProvider downloadProvider)
|
||||
public NotInQueueSpecification(IProvideDownloadClient downloadClientProvider)
|
||||
{
|
||||
_downloadProvider = downloadProvider;
|
||||
|
||||
_downloadClientProvider = downloadClientProvider;
|
||||
}
|
||||
|
||||
public string RejectionReason
|
||||
@ -25,7 +23,7 @@ public string RejectionReason
|
||||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
return !_downloadProvider.GetActiveDownloadClient().IsInQueue(subject);
|
||||
return !_downloadClientProvider.GetDownloadClient().IsInQueue(subject);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
foreach (var file in subject.Episodes.Select(c => c.EpisodeFile).Where(c => c != null))
|
||||
{
|
||||
_logger.Trace("Comparing file quality with report. Existing file is {0} proper:{1}", file.Quality, file.Proper);
|
||||
if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.QualityProfile, new QualityModel { Quality = file.Quality, Proper = file.Proper }, subject.Quality))
|
||||
_logger.Trace("Comparing file quality with report. Existing file is {0}", file.Quality);
|
||||
if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.QualityProfile, file.Quality, subject.Quality))
|
||||
return false;
|
||||
|
||||
if (subject.Quality.Proper && file.DateAdded < DateTime.Today.AddDays(-7))
|
||||
|
54
NzbDrone.Core/Download/DownloadClientProvider.cs
Normal file
54
NzbDrone.Core/Download/DownloadClientProvider.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public interface IProvideDownloadClient
|
||||
{
|
||||
IDownloadClient GetDownloadClient();
|
||||
}
|
||||
|
||||
public class DownloadClientProvider : IProvideDownloadClient
|
||||
{
|
||||
|
||||
private readonly SabProvider _sabProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly BlackholeProvider _blackholeProvider;
|
||||
private readonly PneumaticProvider _pneumaticProvider;
|
||||
private readonly NzbgetProvider _nzbgetProvider;
|
||||
|
||||
|
||||
public DownloadClientProvider(SabProvider sabProvider, IConfigService configService,
|
||||
BlackholeProvider blackholeProvider,
|
||||
PneumaticProvider pneumaticProvider,
|
||||
NzbgetProvider nzbgetProvider)
|
||||
{
|
||||
_sabProvider = sabProvider;
|
||||
_configService = configService;
|
||||
_blackholeProvider = blackholeProvider;
|
||||
_pneumaticProvider = pneumaticProvider;
|
||||
_nzbgetProvider = nzbgetProvider;
|
||||
}
|
||||
|
||||
public IDownloadClient GetDownloadClient()
|
||||
{
|
||||
switch (_configService.DownloadClient)
|
||||
{
|
||||
case DownloadClientType.Blackhole:
|
||||
return _blackholeProvider;
|
||||
|
||||
case DownloadClientType.Pneumatic:
|
||||
return _pneumaticProvider;
|
||||
|
||||
case DownloadClientType.Nzbget:
|
||||
return _nzbgetProvider;
|
||||
|
||||
default:
|
||||
return _sabProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Eventing;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public interface IDownloadProvider
|
||||
{
|
||||
bool DownloadReport(EpisodeParseResult parseResult);
|
||||
IDownloadClient GetActiveDownloadClient();
|
||||
bool ContainsRecentEpisode(EpisodeParseResult parseResult);
|
||||
}
|
||||
|
||||
public class DownloadProvider : IDownloadProvider
|
||||
{
|
||||
private readonly SabProvider _sabProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly BlackholeProvider _blackholeProvider;
|
||||
private readonly PneumaticProvider _pneumaticProvider;
|
||||
private readonly NzbgetProvider _nzbgetProvider;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Logger _logger;
|
||||
|
||||
|
||||
public DownloadProvider(SabProvider sabProvider, IConfigService configService,
|
||||
BlackholeProvider blackholeProvider,
|
||||
PneumaticProvider pneumaticProvider,
|
||||
NzbgetProvider nzbgetProvider,
|
||||
IEventAggregator eventAggregator, Logger logger)
|
||||
{
|
||||
_sabProvider = sabProvider;
|
||||
_configService = configService;
|
||||
_blackholeProvider = blackholeProvider;
|
||||
_pneumaticProvider = pneumaticProvider;
|
||||
_nzbgetProvider = nzbgetProvider;
|
||||
_eventAggregator = eventAggregator;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public virtual bool DownloadReport(EpisodeParseResult parseResult)
|
||||
{
|
||||
var downloadTitle = parseResult.OriginalString;
|
||||
if (!_configService.DownloadClientUseSceneName)
|
||||
{
|
||||
downloadTitle = parseResult.GetDownloadTitle();
|
||||
}
|
||||
|
||||
var provider = GetActiveDownloadClient();
|
||||
var recentEpisode = ContainsRecentEpisode(parseResult);
|
||||
|
||||
bool success = provider.DownloadNzb(parseResult.NzbUrl, downloadTitle, recentEpisode);
|
||||
|
||||
if (success)
|
||||
{
|
||||
_logger.Trace("Download added to Queue: {0}", downloadTitle);
|
||||
_eventAggregator.Publish(new EpisodeGrabbedEvent(parseResult));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public virtual IDownloadClient GetActiveDownloadClient()
|
||||
{
|
||||
switch (_configService.DownloadClient)
|
||||
{
|
||||
case DownloadClientType.Blackhole:
|
||||
return _blackholeProvider;
|
||||
|
||||
case DownloadClientType.Pneumatic:
|
||||
return _pneumaticProvider;
|
||||
|
||||
case DownloadClientType.Nzbget:
|
||||
return _nzbgetProvider;
|
||||
|
||||
default:
|
||||
return _sabProvider;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool ContainsRecentEpisode(EpisodeParseResult parseResult)
|
||||
{
|
||||
return parseResult.Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-7));
|
||||
}
|
||||
}
|
||||
}
|
60
NzbDrone.Core/Download/DownloadService.cs
Normal file
60
NzbDrone.Core/Download/DownloadService.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Eventing;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public interface IDownloadService
|
||||
{
|
||||
bool DownloadReport(EpisodeParseResult parseResult);
|
||||
}
|
||||
|
||||
public class DownloadService : IDownloadService
|
||||
{
|
||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Logger _logger;
|
||||
|
||||
|
||||
public DownloadService(IProvideDownloadClient downloadClientProvider, IConfigService configService,
|
||||
IEventAggregator eventAggregator, Logger logger)
|
||||
{
|
||||
_downloadClientProvider = downloadClientProvider;
|
||||
_configService = configService;
|
||||
_eventAggregator = eventAggregator;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public bool DownloadReport(EpisodeParseResult parseResult)
|
||||
{
|
||||
var downloadTitle = parseResult.OriginalString;
|
||||
if (!_configService.DownloadClientUseSceneName)
|
||||
{
|
||||
downloadTitle = parseResult.GetDownloadTitle();
|
||||
}
|
||||
|
||||
var provider = _downloadClientProvider.GetDownloadClient();
|
||||
var recentEpisode = ContainsRecentEpisode(parseResult);
|
||||
|
||||
bool success = provider.DownloadNzb(parseResult.NzbUrl, downloadTitle, recentEpisode);
|
||||
|
||||
if (success)
|
||||
{
|
||||
_logger.Trace("Download added to Queue: {0}", downloadTitle);
|
||||
_eventAggregator.Publish(new EpisodeGrabbedEvent(parseResult));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private static bool ContainsRecentEpisode(EpisodeParseResult parseResult)
|
||||
{
|
||||
return parseResult.Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-7));
|
||||
}
|
||||
}
|
||||
}
|
@ -19,10 +19,10 @@ public class DailyEpisodeSearch : IndexerSearchBase
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DailyEpisodeSearch(IEpisodeService episodeService, IDownloadProvider downloadProvider, IIndexerService indexerService,
|
||||
public DailyEpisodeSearch(IEpisodeService episodeService, IDownloadService downloadService, IIndexerService indexerService,
|
||||
ISceneMappingService sceneMappingService, IDownloadDirector downloadDirector,
|
||||
ISeriesRepository seriesRepository)
|
||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
: base(seriesRepository, episodeService, downloadService, indexerService, sceneMappingService,
|
||||
downloadDirector)
|
||||
{
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ public class EpisodeSearch : IndexerSearchBase
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public EpisodeSearch(IEpisodeService episodeService, IDownloadProvider downloadProvider, IIndexerService indexerService,
|
||||
public EpisodeSearch(IEpisodeService episodeService, IDownloadService downloadService, IIndexerService indexerService,
|
||||
ISceneMappingService sceneMappingService, IDownloadDirector downloadDirector,
|
||||
ISeriesRepository seriesRepository)
|
||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
: base(seriesRepository, episodeService, downloadService, indexerService, sceneMappingService,
|
||||
downloadDirector)
|
||||
{
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public abstract class IndexerSearchBase
|
||||
{
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly IEpisodeService _episodeService;
|
||||
private readonly IDownloadProvider _downloadProvider;
|
||||
private readonly IDownloadService _downloadService;
|
||||
private readonly ISceneMappingService _sceneMappingService;
|
||||
private readonly IDownloadDirector DownloadDirector;
|
||||
|
||||
@ -26,13 +26,13 @@ public abstract class IndexerSearchBase
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
protected IndexerSearchBase(ISeriesRepository seriesRepository, IEpisodeService episodeService, IDownloadProvider downloadProvider,
|
||||
protected IndexerSearchBase(ISeriesRepository seriesRepository, IEpisodeService episodeService, IDownloadService downloadService,
|
||||
IIndexerService indexerService, ISceneMappingService sceneMappingService,
|
||||
IDownloadDirector downloadDirector)
|
||||
{
|
||||
_seriesRepository = seriesRepository;
|
||||
_episodeService = episodeService;
|
||||
_downloadProvider = downloadProvider;
|
||||
_downloadService = downloadService;
|
||||
_indexerService = indexerService;
|
||||
_sceneMappingService = sceneMappingService;
|
||||
DownloadDirector = downloadDirector;
|
||||
@ -117,7 +117,7 @@ public virtual Boolean DownloadReport(EpisodeParseResult episodeParseResult)
|
||||
logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult);
|
||||
try
|
||||
{
|
||||
if (_downloadProvider.DownloadReport(episodeParseResult))
|
||||
if (_downloadService.DownloadReport(episodeParseResult))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ public class PartialSeasonSearch : IndexerSearchBase
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PartialSeasonSearch(IEpisodeService episodeService, IDownloadProvider downloadProvider, IIndexerService indexerService,
|
||||
public PartialSeasonSearch(IEpisodeService episodeService, IDownloadService downloadService, IIndexerService indexerService,
|
||||
ISceneMappingService sceneMappingService, IDownloadDirector downloadDirector,
|
||||
ISeriesRepository seriesRepository)
|
||||
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
: base(seriesRepository, episodeService, downloadService, indexerService, sceneMappingService,
|
||||
downloadDirector)
|
||||
{
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_qualityUpgradableSpecification.IsUpgradable(episode.Series.QualityProfile, episode.EpisodeFile.QualityModel))
|
||||
if (!_qualityUpgradableSpecification.IsUpgradable(episode.Series.QualityProfile, episode.EpisodeFile.Quality))
|
||||
{
|
||||
logger.Info("Search for {0} was aborted, file in disk meets or exceeds Profile's Cutoff", episode);
|
||||
notification.CurrentMessage = String.Format("Skipping search for {0}, the file you have is already at cutoff", episode);
|
||||
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Jobs.Implementations
|
||||
{
|
||||
public class RssSyncJob : IJob
|
||||
{
|
||||
private readonly DownloadProvider _downloadProvider;
|
||||
private readonly DownloadService _downloadService;
|
||||
private readonly IIndexerService _indexerService;
|
||||
private readonly IDownloadDirector DownloadDirector;
|
||||
private readonly IConfigService _configService;
|
||||
@ -21,9 +21,9 @@ public class RssSyncJob : IJob
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RssSyncJob(DownloadProvider downloadProvider, IIndexerService indexerService, IDownloadDirector downloadDirector, IConfigService configService)
|
||||
public RssSyncJob(DownloadService downloadService, IIndexerService indexerService, IDownloadDirector downloadDirector, IConfigService configService)
|
||||
{
|
||||
_downloadProvider = downloadProvider;
|
||||
_downloadService = downloadService;
|
||||
_indexerService = indexerService;
|
||||
DownloadDirector = downloadDirector;
|
||||
_configService = configService;
|
||||
@ -71,7 +71,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
{
|
||||
if (DownloadDirector.GetDownloadDecision(episodeParseResult).Approved)
|
||||
{
|
||||
_downloadProvider.DownloadReport(episodeParseResult);
|
||||
_downloadService.DownloadReport(episodeParseResult);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles
|
||||
@ -19,32 +17,17 @@ public EpisodeFile(EpisodeFile source)
|
||||
SeriesId = source.SeriesId;
|
||||
SeasonNumber = source.SeasonNumber;
|
||||
Path = source.Path;
|
||||
Quality = source.Quality;
|
||||
Proper = source.Proper;
|
||||
Size = source.Size;
|
||||
}
|
||||
|
||||
public int SeriesId { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public string Path { get; set; }
|
||||
public Quality Quality { get; set; }
|
||||
public bool Proper { get; set; }
|
||||
public long Size { get; set; }
|
||||
public DateTime DateAdded { get; set; }
|
||||
public string SceneName { get; set; }
|
||||
public string ReleaseGroup { get; set; }
|
||||
|
||||
public QualityModel QualityModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return new QualityModel(Quality, Proper);
|
||||
}
|
||||
set
|
||||
{
|
||||
Quality = value.Quality;
|
||||
Proper = value.Proper;
|
||||
}
|
||||
}
|
||||
public QualityModel Quality { get; set; }
|
||||
}
|
||||
}
|
@ -80,7 +80,7 @@ public EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDownload = f
|
||||
|
||||
var parseResult = Parser.ParsePath(episodeFile.Path);
|
||||
parseResult.Series = series;
|
||||
parseResult.Quality = new QualityModel { Quality = episodeFile.Quality, Proper = episodeFile.Proper };
|
||||
parseResult.Quality = episodeFile.Quality;
|
||||
parseResult.Episodes = episodes;
|
||||
|
||||
|
||||
|
@ -230,6 +230,7 @@
|
||||
<Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" />
|
||||
<Compile Include="DecisionEngine\Specifications\UpgradeHistorySpecification.cs" />
|
||||
<Compile Include="Download\Clients\Sabnzbd\SabAutoConfigureService.cs" />
|
||||
<Compile Include="Download\DownloadClientProvider.cs" />
|
||||
<Compile Include="Download\EpisodeDownloadedEvent.cs" />
|
||||
<Compile Include="Download\EpisodeGrabbedEvent.cs" />
|
||||
<Compile Include="Download\SeriesRenamedEvent.cs" />
|
||||
@ -402,7 +403,7 @@
|
||||
<Compile Include="Download\Clients\Sabnzbd\SabProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Download\DownloadProvider.cs">
|
||||
<Compile Include="Download\DownloadService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Tv\EpisodeRepository.cs">
|
||||
|
@ -118,7 +118,7 @@ public string BuildFilename(IList<Episode> episodes, Series series, EpisodeFile
|
||||
{
|
||||
result += String.Format(" [{0}]", episodeFile.Quality);
|
||||
|
||||
if (episodeFile.Proper)
|
||||
if (episodeFile.Quality.Proper)
|
||||
result += " [Proper]";
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
}
|
||||
|
||||
//Make sure this file is an upgrade for ALL episodes already on disk
|
||||
if (episodes.All(e => e.EpisodeFile == null || e.EpisodeFile.QualityModel <= parseResult.Quality))
|
||||
if (episodes.All(e => e.EpisodeFile == null || e.EpisodeFile.Quality <= parseResult.Quality))
|
||||
{
|
||||
Logger.Debug("Deleting the existing file(s) on disk to upgrade to: {0}", filePath);
|
||||
//Do the delete for files where there is already an episode on disk
|
||||
@ -152,8 +152,7 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
episodeFile.SeriesId = series.Id;
|
||||
episodeFile.Path = filePath.NormalizePath();
|
||||
episodeFile.Size = size;
|
||||
episodeFile.Quality = parseResult.Quality.Quality;
|
||||
episodeFile.Proper = parseResult.Quality.Proper;
|
||||
episodeFile.Quality = parseResult.Quality;
|
||||
episodeFile.SeasonNumber = parseResult.SeasonNumber;
|
||||
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath());
|
||||
episodeFile.ReleaseGroup = parseResult.ReleaseGroup;
|
||||
|
@ -42,7 +42,7 @@ public virtual bool SendNotification(string caption, string message, IconType ic
|
||||
payload[offset++] = (byte)iconType;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
payload[offset++] = (byte)0;
|
||||
payload[offset++] = 0;
|
||||
|
||||
Array.Copy(icon, 0, payload, caption.Length + message.Length + 7, icon.Length);
|
||||
|
||||
|
@ -4,19 +4,16 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common.Eventing;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public interface IEpisodeService
|
||||
{
|
||||
void AddEpisode(Episode episode);
|
||||
Episode GetEpisode(int id);
|
||||
Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber);
|
||||
Episode GetEpisode(int seriesId, DateTime date);
|
||||
@ -33,7 +30,6 @@ public interface IEpisodeService
|
||||
bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber, int episodeNumber);
|
||||
void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus);
|
||||
void UpdateEpisodes(List<Episode> episodes);
|
||||
Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
||||
List<Episode> EpisodesBetweenDates(DateTime start, DateTime end);
|
||||
}
|
||||
|
||||
@ -63,11 +59,6 @@ public EpisodeService(IProvideEpisodeInfo episodeInfoProxy, ISeasonRepository se
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void AddEpisode(Episode episode)
|
||||
{
|
||||
episode.Ignored = _seasonRepository.IsIgnored(episode.SeriesId, episode.SeasonNumber);
|
||||
_episodeRepository.Insert(episode);
|
||||
}
|
||||
|
||||
public Episode GetEpisode(int id)
|
||||
{
|
||||
@ -107,7 +98,7 @@ public List<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
|
||||
return new List<Episode>();
|
||||
}
|
||||
|
||||
var episodeInfo = GetEpisode(((ModelBase)parseResult.Series).Id, parseResult.AirDate.Value);
|
||||
var episodeInfo = GetEpisode(parseResult.Series.Id, parseResult.AirDate.Value);
|
||||
|
||||
if (episodeInfo != null)
|
||||
{
|
||||
@ -129,14 +120,14 @@ public List<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
|
||||
Episode episodeInfo = null;
|
||||
|
||||
if (parseResult.SceneSource && parseResult.Series.UseSceneNumbering)
|
||||
episodeInfo = GetEpisodeBySceneNumbering(((ModelBase)parseResult.Series).Id, parseResult.SeasonNumber, episodeNumber);
|
||||
episodeInfo = _episodeRepository.GetEpisodeBySceneNumbering(parseResult.Series.Id, parseResult.SeasonNumber, episodeNumber);
|
||||
|
||||
if (episodeInfo == null)
|
||||
{
|
||||
episodeInfo = GetEpisode(((ModelBase)parseResult.Series).Id, parseResult.SeasonNumber, episodeNumber);
|
||||
episodeInfo = GetEpisode(parseResult.Series.Id, parseResult.SeasonNumber, episodeNumber);
|
||||
if (episodeInfo == null && parseResult.AirDate != null)
|
||||
{
|
||||
episodeInfo = GetEpisode(((ModelBase)parseResult.Series).Id, parseResult.AirDate.Value);
|
||||
episodeInfo = GetEpisode(parseResult.Series.Id, parseResult.AirDate.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,11 +353,6 @@ public void UpdateEpisodes(List<Episode> episodes)
|
||||
_episodeRepository.UpdateMany(episodes);
|
||||
}
|
||||
|
||||
public Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
return _episodeRepository.GetEpisodeBySceneNumbering(seriesId, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
public List<Episode> EpisodesBetweenDates(DateTime start, DateTime end)
|
||||
{
|
||||
return _episodeRepository.EpisodesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime());
|
||||
|
@ -11,12 +11,13 @@ public class QualityModel : IComparable<QualityModel>, IEmbeddedDocument
|
||||
|
||||
public Boolean Proper { get; set; }
|
||||
|
||||
public QualityModel():this(Quality.Unknown, false)
|
||||
public QualityModel()
|
||||
: this(Quality.Unknown)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public QualityModel(Quality quality, Boolean proper)
|
||||
public QualityModel(Quality quality, Boolean proper = false)
|
||||
{
|
||||
Quality = quality;
|
||||
Proper = proper;
|
||||
|
@ -120,7 +120,7 @@ public void UpdateFromSeriesEditor(IList<Series> editedSeries)
|
||||
foreach (var series in allSeries)
|
||||
{
|
||||
//Only update parameters that can be changed in MassEdit
|
||||
var edited = editedSeries.Single(s => ((ModelBase)s).Id == series.Id);
|
||||
var edited = editedSeries.Single(s => s.Id == series.Id);
|
||||
series.QualityProfileId = edited.QualityProfileId;
|
||||
series.Monitored = edited.Monitored;
|
||||
series.SeasonFolder = edited.SeasonFolder;
|
||||
|
Loading…
Reference in New Issue
Block a user