New: Use release quality source if not in downloaded file and resolution matches

download-client-aggregate
Mark McDowall 5 years ago committed by Bogdan
parent a3c33fe8cc
commit 8d8c08c5f2

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
"Adele - 19 - 203 - That's It, I Quit, I'm Moving On.mp3"
}, @"C:\incoming".AsOsAgnostic());
Subject.Aggregate(release, true);
Subject.Aggregate(release, null, true);
VerifyData(release.LocalTracks[0], "Adele", "Daydreamer", 1, 1);
VerifyData(release.LocalTracks[1], "Adele", "Best for Last", 2, 1);
@ -198,7 +198,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
var files = GivenFilenames(testcase.Item1, testcase.Item2, testcase.Item3);
var release = GivenTracks(files, @"C:\incoming".AsOsAgnostic());
Subject.Aggregate(release, true);
Subject.Aggregate(release, null, true);
VerifyDataAuto(release.LocalTracks, testcase.Item1, testcase.Item3);
}

@ -151,8 +151,8 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
private void GivenAugmentationSuccess()
{
Mocker.GetMock<IAugmentingService>()
.Setup(s => s.Augment(It.IsAny<LocalTrack>(), It.IsAny<bool>()))
.Callback<LocalTrack, bool>((localTrack, otherFiles) =>
.Setup(s => s.Augment(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()))
.Callback<LocalTrack, DownloadClientItem, bool>((localTrack, downloadClientItem, otherFiles) =>
{
localTrack.Tracks = _localTrack.Tracks;
});
@ -323,7 +323,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
GivenSpecifications(_pass1);
Mocker.GetMock<IAugmentingService>()
.Setup(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<bool>()))
.Setup(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()))
.Throws<TestException>();
GivenAudioFiles(new[]
@ -336,7 +336,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
var decisions = Subject.GetImportDecisions(_fileInfos, _idOverrides, null, _idConfig);
Mocker.GetMock<IAugmentingService>()
.Verify(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<bool>()), Times.Exactly(_fileInfos.Count));
.Verify(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()), Times.Exactly(_fileInfos.Count));
ExceptionVerification.ExpectedErrors(3);
}
@ -363,7 +363,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
var decisions = Subject.GetImportDecisions(_fileInfos, _idOverrides, null, _idConfig);
Mocker.GetMock<IAugmentingService>()
.Verify(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<bool>()), Times.Exactly(_fileInfos.Count));
.Verify(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()), Times.Exactly(_fileInfos.Count));
decisions.Should().HaveCount(3);
decisions.First().Rejections.Should().NotBeEmpty();
@ -384,7 +384,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
var decisions = Subject.GetImportDecisions(_fileInfos, _idOverrides, null, _idConfig);
Mocker.GetMock<IAugmentingService>()
.Verify(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<bool>()), Times.Exactly(_fileInfos.Count));
.Verify(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()), Times.Exactly(_fileInfos.Count));
decisions.Should().HaveCount(3);
decisions.First().Rejections.Should().NotBeEmpty();
@ -394,7 +394,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport
public void should_return_a_decision_when_exception_is_caught()
{
Mocker.GetMock<IAugmentingService>()
.Setup(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<bool>()))
.Setup(c => c.Augment(It.IsAny<LocalTrack>(), It.IsAny<DownloadClientItem>(), It.IsAny<bool>()))
.Throws<TestException>();
GivenAudioFiles(new[]

@ -50,7 +50,7 @@ namespace NzbDrone.Core.Extras.Lyrics
try
{
_augmentingService.Augment(localTrack, false);
_augmentingService.Augment(localTrack, null, false);
}
catch (AugmentingFailedException)
{

@ -85,7 +85,7 @@ namespace NzbDrone.Core.Extras.Metadata
try
{
_augmentingService.Augment(localTrack, false);
_augmentingService.Augment(localTrack, null, false);
}
catch (AugmentingFailedException)
{

@ -54,7 +54,7 @@ namespace NzbDrone.Core.Extras.Others
try
{
_augmentingService.Augment(localTrack, false);
_augmentingService.Augment(localTrack, null, false);
}
catch (AugmentingFailedException)
{

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators;
using NzbDrone.Core.Parser.Model;
@ -11,7 +12,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation
{
public interface IAugmentingService
{
LocalTrack Augment(LocalTrack localTrack, bool otherFiles);
LocalTrack Augment(LocalTrack localTrack, DownloadClientItem downloadClientItem, bool otherFiles);
LocalAlbumRelease Augment(LocalAlbumRelease localAlbum);
}
@ -33,7 +34,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation
_logger = logger;
}
public LocalTrack Augment(LocalTrack localTrack, bool otherFiles)
public LocalTrack Augment(LocalTrack localTrack, DownloadClientItem downloadClientItem, bool otherFiles)
{
if (localTrack.DownloadClientAlbumInfo == null &&
localTrack.FolderAlbumInfo == null &&
@ -52,7 +53,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation
{
try
{
augmenter.Aggregate(localTrack, otherFiles);
augmenter.Aggregate(localTrack, downloadClientItem, otherFiles);
}
catch (Exception ex)
{
@ -71,7 +72,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation
{
try
{
augmenter.Aggregate(localAlbum, false);
augmenter.Aggregate(localAlbum, null, false);
}
catch (Exception ex)
{

@ -5,6 +5,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
@ -55,7 +56,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
_logger = logger;
}
public LocalAlbumRelease Aggregate(LocalAlbumRelease release, bool others)
public LocalAlbumRelease Aggregate(LocalAlbumRelease release, DownloadClientItem downloadClientItem, bool others)
{
var tracks = release.LocalTracks;
if (tracks.Any(x => x.FileTrackInfo.Title.IsNullOrWhiteSpace())

@ -1,10 +1,11 @@
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
{
public class AggregateQuality : IAggregate<LocalTrack>
{
public LocalTrack Aggregate(LocalTrack localTrack, bool otherFiles)
public LocalTrack Aggregate(LocalTrack localTrack, DownloadClientItem downloadClientItem, bool otherFiles)
{
var quality = localTrack.FileTrackInfo?.Quality;

@ -1,11 +1,12 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
{
public class AggregateReleaseGroup : IAggregate<LocalTrack>
{
public LocalTrack Aggregate(LocalTrack localTrack, bool otherFiles)
public LocalTrack Aggregate(LocalTrack localTrack, DownloadClientItem downloadClientItem, bool otherFiles)
{
var releaseGroup = localTrack.DownloadClientAlbumInfo?.ReleaseGroup;

@ -1,7 +1,9 @@
using NzbDrone.Core.Download;
namespace NzbDrone.Core.MediaFiles.TrackImport.Aggregation.Aggregators
{
public interface IAggregate<T>
{
T Aggregate(T item, bool otherFiles);
T Aggregate(T item, DownloadClientItem downloadClientItem, bool otherFiles);
}
}

@ -185,7 +185,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
}))
.ToList();
localTracks.ForEach(x => _augmentingService.Augment(x, true));
localTracks.ForEach(x => _augmentingService.Augment(x, null, true));
return localTracks;
}

@ -119,7 +119,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
try
{
// TODO fix otherfiles?
_augmentingService.Augment(localTrack, true);
_augmentingService.Augment(localTrack, downloadClientItem, true);
localTracks.Add(localTrack);
}
catch (AugmentingFailedException)

Loading…
Cancel
Save