diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs index 3552a5125..45f340b35 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QueueSpecificationFixture.cs @@ -74,7 +74,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Build(); Mocker.GetMock() - .Setup(x => x.ParseCustomFormat(It.IsAny())) + .Setup(x => x.ParseCustomFormat(It.IsAny(), It.IsAny())) .Returns(new List()); } @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests private void GivenQueueFormats(List formats) { Mocker.GetMock() - .Setup(x => x.ParseCustomFormat(It.IsAny())) + .Setup(x => x.ParseCustomFormat(It.IsAny(), It.IsAny())) .Returns(formats); } diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs index 2290472d5..a004a15d8 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/Specifications/UpgradeSpecificationFixture.cs @@ -269,7 +269,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Returns(new List()); Mocker.GetMock() - .Setup(s => s.ParseCustomFormat(It.IsAny())) + .Setup(s => s.ParseCustomFormat(It.IsAny(), It.IsAny())) .Returns(new List()); _localEpisode.Quality = new QualityModel(Quality.Bluray2160p); @@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Returns(new List()); Mocker.GetMock() - .Setup(s => s.ParseCustomFormat(It.IsAny())) + .Setup(s => s.ParseCustomFormat(It.IsAny(), It.IsAny())) .Returns(new List()); _localEpisode.Quality = new QualityModel(Quality.Bluray1080p); @@ -381,7 +381,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Returns(new List()); Mocker.GetMock() - .Setup(s => s.ParseCustomFormat(It.IsAny())) + .Setup(s => s.ParseCustomFormat(It.IsAny(), It.IsAny())) .Returns(new List()); _localEpisode.Quality = new QualityModel(Quality.Bluray1080p); @@ -414,7 +414,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications .Returns(new List()); Mocker.GetMock() - .Setup(s => s.ParseCustomFormat(It.IsAny())) + .Setup(s => s.ParseCustomFormat(It.IsAny(), It.IsAny())) .Returns(new List()); _localEpisode.Quality = new QualityModel(Quality.Bluray1080p); diff --git a/src/NzbDrone.Core/CustomFormats/CustomFormatCalculationService.cs b/src/NzbDrone.Core/CustomFormats/CustomFormatCalculationService.cs index 06c39cd66..697420132 100644 --- a/src/NzbDrone.Core/CustomFormats/CustomFormatCalculationService.cs +++ b/src/NzbDrone.Core/CustomFormats/CustomFormatCalculationService.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.Blocklisting; -using NzbDrone.Core.Datastore.Migration; using NzbDrone.Core.History; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Parser.Model; @@ -13,7 +12,7 @@ namespace NzbDrone.Core.CustomFormats { public interface ICustomFormatCalculationService { - List ParseCustomFormat(RemoteEpisode remoteEpisode); + List ParseCustomFormat(RemoteEpisode remoteEpisode, long size); List ParseCustomFormat(EpisodeFile episodeFile, Series series); List ParseCustomFormat(EpisodeFile episodeFile); List ParseCustomFormat(Blocklist blocklist, Series series); @@ -30,13 +29,13 @@ namespace NzbDrone.Core.CustomFormats _formatService = formatService; } - public List ParseCustomFormat(RemoteEpisode remoteEpisode) + public List ParseCustomFormat(RemoteEpisode remoteEpisode, long size) { var input = new CustomFormatInput { EpisodeInfo = remoteEpisode.ParsedEpisodeInfo, Series = remoteEpisode.Series, - Size = remoteEpisode.Release.Size, + Size = size, Languages = remoteEpisode.Languages }; diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 84dad6f3d..1a1e7fc49 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -113,7 +113,7 @@ namespace NzbDrone.Core.DecisionEngine { _aggregationService.Augment(remoteEpisode); - remoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(remoteEpisode); + remoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(remoteEpisode, remoteEpisode.Release.Size); remoteEpisode.CustomFormatScore = remoteEpisode?.Series?.QualityProfile?.Value.CalculateCustomFormatScore(remoteEpisode.CustomFormats) ?? 0; remoteEpisode.DownloadAllowed = remoteEpisode.Episodes.Any(); diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs index 67a0f32a2..a84ec8cb8 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/QueueSpecification.cs @@ -52,7 +52,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications continue; } - var queuedItemCustomFormats = _formatService.ParseCustomFormat(remoteEpisode); + var queuedItemCustomFormats = _formatService.ParseCustomFormat(remoteEpisode, (long)queueItem.Size); _logger.Debug("Checking if existing release in queue meets cutoff. Queued: {0}", remoteEpisode.ParsedEpisodeInfo.Quality); diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 9b7f91431..66c7ce7ef 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -336,7 +336,7 @@ namespace NzbDrone.Core.Download.Pending } _aggregationService.Augment(release.RemoteEpisode); - release.RemoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(release.RemoteEpisode); + release.RemoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(release.RemoteEpisode, release.Release.Size); result.Add(release); } diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index 75c7cf3a2..faf656863 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -153,7 +153,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads // Calculate custom formats if (trackedDownload.RemoteEpisode != null) { - trackedDownload.RemoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(trackedDownload.RemoteEpisode); + trackedDownload.RemoteEpisode.CustomFormats = _formatCalculator.ParseCustomFormat(trackedDownload.RemoteEpisode, downloadItem.TotalSize); } // Track it so it can be displayed in the queue even though we can't determine which series it is for