mirror of
https://github.com/Readarr/Readarr
synced 2026-04-11 15:33:23 +02:00
More Fun in Core with Naming
This commit is contained in:
parent
b0e966418e
commit
307989aab7
122 changed files with 1084 additions and 1198 deletions
|
|
@ -25,7 +25,7 @@ public class AlreadyImportedSpecificationFixture : CoreTest<AlreadyImportedSpeci
|
|||
private Author _artist;
|
||||
private QualityModel _mp3;
|
||||
private QualityModel _flac;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
private List<History.History> _history;
|
||||
private BookFile _firstFile;
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ public void Setup()
|
|||
_mp3 = new QualityModel(Quality.MP3_320, new Revision(version: 1));
|
||||
_flac = new QualityModel(Quality.FLAC, new Revision(version: 1));
|
||||
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = _artist,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = _mp3 },
|
||||
|
|
@ -97,7 +97,7 @@ public void should_be_accepted_if_CDH_is_disabled()
|
|||
{
|
||||
GivenCdhDisabled();
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -107,13 +107,13 @@ public void should_be_accepted_if_album_does_not_have_a_file()
|
|||
.Setup(c => c.GetFilesByBook(It.IsAny<int>()))
|
||||
.Returns(new List<BookFile> { });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_album_does_not_have_grabbed_event()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -121,7 +121,7 @@ public void should_be_accepted_if_album_does_not_have_imported_event()
|
|||
{
|
||||
GivenHistoryItem(Guid.NewGuid().ToString().ToUpper(), TITLE, _mp3, HistoryEventType.Grabbed);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -132,7 +132,7 @@ public void should_be_accepted_if_grabbed_and_imported_quality_is_the_same()
|
|||
GivenHistoryItem(downloadId, TITLE, _mp3, HistoryEventType.Grabbed);
|
||||
GivenHistoryItem(downloadId, TITLE, _mp3, HistoryEventType.DownloadImported);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -143,12 +143,12 @@ public void should_be_rejected_if_grabbed_download_id_matches_release_torrent_ha
|
|||
GivenHistoryItem(downloadId, TITLE, _mp3, HistoryEventType.Grabbed);
|
||||
GivenHistoryItem(downloadId, TITLE, _flac, HistoryEventType.DownloadImported);
|
||||
|
||||
_remoteAlbum.Release = Builder<TorrentInfo>.CreateNew()
|
||||
_remoteBook.Release = Builder<TorrentInfo>.CreateNew()
|
||||
.With(t => t.DownloadProtocol = DownloadProtocol.Torrent)
|
||||
.With(t => t.InfoHash = downloadId)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -159,12 +159,12 @@ public void should_be_accepted_if_release_torrent_hash_is_null()
|
|||
GivenHistoryItem(downloadId, TITLE, _mp3, HistoryEventType.Grabbed);
|
||||
GivenHistoryItem(downloadId, TITLE, _flac, HistoryEventType.DownloadImported);
|
||||
|
||||
_remoteAlbum.Release = Builder<TorrentInfo>.CreateNew()
|
||||
_remoteBook.Release = Builder<TorrentInfo>.CreateNew()
|
||||
.With(t => t.DownloadProtocol = DownloadProtocol.Torrent)
|
||||
.With(t => t.InfoHash = null)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -173,12 +173,12 @@ public void should_be_accepted_if_release_torrent_hash_is_null_and_downloadId_is
|
|||
GivenHistoryItem(null, TITLE, _mp3, HistoryEventType.Grabbed);
|
||||
GivenHistoryItem(null, TITLE, _flac, HistoryEventType.DownloadImported);
|
||||
|
||||
_remoteAlbum.Release = Builder<TorrentInfo>.CreateNew()
|
||||
_remoteBook.Release = Builder<TorrentInfo>.CreateNew()
|
||||
.With(t => t.DownloadProtocol = DownloadProtocol.Torrent)
|
||||
.With(t => t.InfoHash = null)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -189,12 +189,12 @@ public void should_be_rejected_if_release_title_matches_grabbed_event_source_tit
|
|||
GivenHistoryItem(downloadId, TITLE, _mp3, HistoryEventType.Grabbed);
|
||||
GivenHistoryItem(downloadId, TITLE, _flac, HistoryEventType.DownloadImported);
|
||||
|
||||
_remoteAlbum.Release = Builder<TorrentInfo>.CreateNew()
|
||||
_remoteBook.Release = Builder<TorrentInfo>.CreateNew()
|
||||
.With(t => t.DownloadProtocol = DownloadProtocol.Torrent)
|
||||
.With(t => t.InfoHash = downloadId)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class BlockedIndexerSpecificationFixture : CoreTest<BlockedIndexerSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Release = new ReleaseInfo { IndexerId = 1 }
|
||||
};
|
||||
|
|
@ -39,7 +39,7 @@ private void WithBlockedIndexer()
|
|||
[Test]
|
||||
public void should_return_true_if_no_blocked_indexer()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -47,7 +47,7 @@ public void should_return_false_if_blocked_indexer()
|
|||
{
|
||||
WithBlockedIndexer();
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
Subject.Type.Should().Be(RejectionType.Temporary);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[TestFixture]
|
||||
public class DiscographySpecificationFixture : CoreTest<DiscographySpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var artist = Builder<Author>.CreateNew().With(s => s.Id = 1234).Build();
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
ParsedBookInfo = new ParsedBookInfo
|
||||
{
|
||||
|
|
@ -46,29 +46,29 @@ public void Setup()
|
|||
[Test]
|
||||
public void should_return_true_if_is_not_a_discography()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Discography = false;
|
||||
_remoteAlbum.Books.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2);
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
_remoteBook.ParsedBookInfo.Discography = false;
|
||||
_remoteBook.Books.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_all_albums_have_released()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_one_album_has_not_released()
|
||||
{
|
||||
_remoteAlbum.Books.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2);
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
_remoteBook.Books.Last().ReleaseDate = DateTime.UtcNow.AddDays(+2);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_an_album_does_not_have_an_release_date()
|
||||
{
|
||||
_remoteAlbum.Books.Last().ReleaseDate = null;
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
_remoteBook.Books.Last().ReleaseDate = null;
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
public class DownloadDecisionMakerFixture : CoreTest<DownloadDecisionMaker>
|
||||
{
|
||||
private List<ReleaseInfo> _reports;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
private Mock<IDecisionEngineSpecification> _pass1;
|
||||
private Mock<IDecisionEngineSpecification> _pass2;
|
||||
|
|
@ -57,7 +57,7 @@ public void Setup()
|
|||
_failDelayed1.SetupGet(c => c.Priority).Returns(SpecificationPriority.Disk);
|
||||
|
||||
_reports = new List<ReleaseInfo> { new ReleaseInfo { Title = "Coldplay-A Head Full Of Dreams-CD-FLAC-2015-PERFECT" } };
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = new Author(),
|
||||
Books = new List<Book> { new Book() }
|
||||
|
|
@ -65,7 +65,7 @@ public void Setup()
|
|||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(c => c.Map(It.IsAny<ParsedBookInfo>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns(_remoteAlbum);
|
||||
.Returns(_remoteBook);
|
||||
}
|
||||
|
||||
private void GivenSpecifications(params Mock<IDecisionEngineSpecification>[] mocks)
|
||||
|
|
@ -80,12 +80,12 @@ public void should_call_all_specifications()
|
|||
|
||||
Subject.GetRssDecision(_reports).ToList();
|
||||
|
||||
_fail1.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once());
|
||||
_fail2.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once());
|
||||
_fail3.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once());
|
||||
_pass1.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once());
|
||||
_pass2.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once());
|
||||
_pass3.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once());
|
||||
_fail1.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Once());
|
||||
_fail2.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Once());
|
||||
_fail3.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Once());
|
||||
_pass1.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Once());
|
||||
_pass2.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Once());
|
||||
_pass3.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -94,7 +94,7 @@ public void should_call_delayed_specifications_if_non_delayed_passed()
|
|||
GivenSpecifications(_pass1, _failDelayed1);
|
||||
|
||||
Subject.GetRssDecision(_reports).ToList();
|
||||
_failDelayed1.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Once());
|
||||
_failDelayed1.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -104,7 +104,7 @@ public void should_not_call_delayed_specifications_if_non_delayed_failed()
|
|||
|
||||
Subject.GetRssDecision(_reports).ToList();
|
||||
|
||||
_failDelayed1.Verify(c => c.IsSatisfiedBy(_remoteAlbum, null), Times.Never());
|
||||
_failDelayed1.Verify(c => c.IsSatisfiedBy(_remoteBook, null), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -185,7 +185,7 @@ public void should_not_attempt_to_make_decision_if_artist_is_unknown()
|
|||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
_remoteAlbum.Author = null;
|
||||
_remoteBook.Author = null;
|
||||
|
||||
Subject.GetRssDecision(_reports);
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ public void should_return_unknown_artist_rejection_if_artist_is_unknown()
|
|||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
_remoteAlbum.Author = null;
|
||||
_remoteBook.Author = null;
|
||||
|
||||
var result = Subject.GetRssDecision(_reports);
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ public void should_only_include_reports_for_requested_albums()
|
|||
|
||||
Mocker.SetConstant<IEnumerable<IDecisionEngineSpecification>>(new List<IDecisionEngineSpecification>
|
||||
{
|
||||
Mocker.Resolve<NzbDrone.Core.DecisionEngine.Specifications.Search.AlbumRequestedSpecification>()
|
||||
Mocker.Resolve<NzbDrone.Core.DecisionEngine.Specifications.Search.BookRequestedSpecification>()
|
||||
});
|
||||
|
||||
var decisions = Subject.GetSearchDecision(reports, criteria);
|
||||
|
|
@ -275,7 +275,7 @@ public void should_not_allow_download_if_artist_is_unknown()
|
|||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
_remoteAlbum.Author = null;
|
||||
_remoteBook.Author = null;
|
||||
|
||||
var result = Subject.GetRssDecision(_reports);
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ public void should_not_allow_download_if_no_albums_found()
|
|||
{
|
||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||
|
||||
_remoteAlbum.Books = new List<Book>();
|
||||
_remoteBook.Books = new List<Book>();
|
||||
|
||||
var result = Subject.GetRssDecision(_reports);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class EarlyReleaseSpecificationFixture : TestBase<EarlyReleaseSpecificati
|
|||
private Author _artist;
|
||||
private Book _album1;
|
||||
private Book _album2;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
private IndexerDefinition _indexerDefinition;
|
||||
|
||||
[SetUp]
|
||||
|
|
@ -30,7 +30,7 @@ public void Setup()
|
|||
_album1 = Builder<Book>.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build();
|
||||
_album2 = Builder<Book>.CreateNew().With(s => s.ReleaseDate = DateTime.Today).Build();
|
||||
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = _artist,
|
||||
Books = new List<Book> { _album1 },
|
||||
|
|
@ -54,23 +54,23 @@ public void Setup()
|
|||
|
||||
private void GivenPublishDateFromToday(int days)
|
||||
{
|
||||
_remoteAlbum.Release.PublishDate = DateTime.Today.AddDays(days);
|
||||
_remoteBook.Release.PublishDate = DateTime.Today.AddDays(days);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_indexer_not_specified()
|
||||
{
|
||||
_remoteAlbum.Release.IndexerId = 0;
|
||||
_remoteBook.Release.IndexerId = 0;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_release_contains_multiple_albums()
|
||||
{
|
||||
_remoteAlbum.Books.Add(_album2);
|
||||
_remoteBook.Books.Add(_album2);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -80,7 +80,7 @@ public void should_return_true_if_indexer_no_longer_exists()
|
|||
.Setup(v => v.Get(It.IsAny<int>()))
|
||||
.Callback<int>(i => { throw new ModelNotFoundException(typeof(IndexerDefinition), i); });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase(-2)]
|
||||
|
|
@ -89,7 +89,7 @@ public void should_return_true_if_publish_date_above_or_equal_to_limit(int days)
|
|||
{
|
||||
GivenPublishDateFromToday(days);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase(-10)]
|
||||
|
|
@ -98,7 +98,7 @@ public void should_return_false_if_publish_date_belove_limit(int days)
|
|||
{
|
||||
GivenPublishDateFromToday(days);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[TestCase(-10)]
|
||||
|
|
@ -109,7 +109,7 @@ public void should_return_true_if_limit_null(int days)
|
|||
|
||||
_indexerDefinition.Settings = new TorrentRssIndexerSettings { EarlyReleaseLimit = null };
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
public class MaximumSizeSpecificationFixture : CoreTest<MaximumSizeSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = new RemoteBook() { Release = new ReleaseInfo() };
|
||||
_remoteBook = new RemoteBook() { Release = new ReleaseInfo() };
|
||||
}
|
||||
|
||||
private void WithMaximumSize(int size)
|
||||
|
|
@ -24,7 +24,7 @@ private void WithMaximumSize(int size)
|
|||
|
||||
private void WithSize(int size)
|
||||
{
|
||||
_remoteAlbum.Release.Size = size * 1024 * 1024;
|
||||
_remoteBook.Release.Size = size * 1024 * 1024;
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -33,7 +33,7 @@ public void should_return_true_when_maximum_size_is_set_to_zero()
|
|||
WithMaximumSize(0);
|
||||
WithSize(1000);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -42,7 +42,7 @@ public void should_return_true_when_size_is_smaller_than_maximum_size()
|
|||
WithMaximumSize(2000);
|
||||
WithSize(1999);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -51,7 +51,7 @@ public void should_return_true_when_size_is_equals_to_maximum_size()
|
|||
WithMaximumSize(2000);
|
||||
WithSize(2000);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -60,7 +60,7 @@ public void should_return_false_when_size_is_bigger_than_maximum_size()
|
|||
WithMaximumSize(2000);
|
||||
WithSize(2001);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -69,7 +69,7 @@ public void should_return_true_when_size_is_zero()
|
|||
WithMaximumSize(2000);
|
||||
WithSize(0);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class MinimumAgeSpecificationFixture : CoreTest<MinimumAgeSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet }
|
||||
};
|
||||
|
|
@ -31,7 +31,7 @@ private void WithMinimumAge(int minutes)
|
|||
|
||||
private void WithAge(int minutes)
|
||||
{
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow.AddMinutes(-minutes);
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow.AddMinutes(-minutes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -40,7 +40,7 @@ public void should_return_true_when_minimum_age_is_set_to_zero()
|
|||
WithMinimumAge(0);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -49,7 +49,7 @@ public void should_return_true_when_age_is_greater_than_minimum_age()
|
|||
WithMinimumAge(30);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -58,7 +58,7 @@ public void should_return_false_when_age_is_less_than_minimum_age()
|
|||
WithMinimumAge(30);
|
||||
WithAge(10);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
{
|
||||
[TestFixture]
|
||||
|
||||
public class MonitoredAlbumSpecificationFixture : CoreTest<MonitoredAlbumSpecification>
|
||||
public class MonitoredAlbumSpecificationFixture : CoreTest<MonitoredBookSpecification>
|
||||
{
|
||||
private MonitoredAlbumSpecification _monitoredAlbumSpecification;
|
||||
private MonitoredBookSpecification _monitoredAlbumSpecification;
|
||||
|
||||
private RemoteBook _parseResultMulti;
|
||||
private RemoteBook _parseResultSingle;
|
||||
|
|
@ -25,7 +25,7 @@ public class MonitoredAlbumSpecificationFixture : CoreTest<MonitoredAlbumSpecifi
|
|||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_monitoredAlbumSpecification = Mocker.Resolve<MonitoredAlbumSpecification>();
|
||||
_monitoredAlbumSpecification = Mocker.Resolve<MonitoredBookSpecification>();
|
||||
|
||||
_fakeArtist = Builder<Author>.CreateNew()
|
||||
.With(c => c.Monitored = true)
|
||||
|
|
|
|||
|
|
@ -36,27 +36,27 @@ private Book GivenAlbum(int id)
|
|||
|
||||
private RemoteBook GivenRemoteAlbum(List<Book> albums, QualityModel quality, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet)
|
||||
{
|
||||
var remoteAlbum = new RemoteBook();
|
||||
remoteAlbum.ParsedBookInfo = new ParsedBookInfo();
|
||||
remoteAlbum.ParsedBookInfo.Quality = quality;
|
||||
var remoteBook = new RemoteBook();
|
||||
remoteBook.ParsedBookInfo = new ParsedBookInfo();
|
||||
remoteBook.ParsedBookInfo.Quality = quality;
|
||||
|
||||
remoteAlbum.Books = new List<Book>();
|
||||
remoteAlbum.Books.AddRange(albums);
|
||||
remoteBook.Books = new List<Book>();
|
||||
remoteBook.Books.AddRange(albums);
|
||||
|
||||
remoteAlbum.Release = new ReleaseInfo();
|
||||
remoteAlbum.Release.PublishDate = DateTime.Now.AddDays(-age);
|
||||
remoteAlbum.Release.Size = size;
|
||||
remoteAlbum.Release.DownloadProtocol = downloadProtocol;
|
||||
remoteBook.Release = new ReleaseInfo();
|
||||
remoteBook.Release.PublishDate = DateTime.Now.AddDays(-age);
|
||||
remoteBook.Release.Size = size;
|
||||
remoteBook.Release.DownloadProtocol = downloadProtocol;
|
||||
|
||||
remoteAlbum.Author = Builder<Author>.CreateNew()
|
||||
remoteBook.Author = Builder<Author>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile
|
||||
{
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
}).Build();
|
||||
|
||||
remoteAlbum.DownloadAllowed = true;
|
||||
remoteBook.DownloadAllowed = true;
|
||||
|
||||
return remoteAlbum;
|
||||
return remoteBook;
|
||||
}
|
||||
|
||||
private void GivenPreferredDownloadProtocol(DownloadProtocol downloadProtocol)
|
||||
|
|
@ -72,12 +72,12 @@ private void GivenPreferredDownloadProtocol(DownloadProtocol downloadProtocol)
|
|||
[Test]
|
||||
public void should_put_propers_before_non_propers()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 1)));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 2)));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320, new Revision(version: 2)));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(2);
|
||||
|
|
@ -86,12 +86,12 @@ public void should_put_propers_before_non_propers()
|
|||
[Test]
|
||||
public void should_put_higher_quality_before_lower()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Quality.Should().Be(Quality.MP3_320);
|
||||
|
|
@ -100,46 +100,46 @@ public void should_put_higher_quality_before_lower()
|
|||
[Test]
|
||||
public void should_order_by_age_then_largest_rounded_to_200mb()
|
||||
{
|
||||
var remoteAlbumSd = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 100.Megabytes(), age: 1);
|
||||
var remoteAlbumHdSmallOld = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 1200.Megabytes(), age: 1000);
|
||||
var remoteAlbumSmallYoung = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 1250.Megabytes(), age: 10);
|
||||
var remoteAlbumHdLargeYoung = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 3000.Megabytes(), age: 1);
|
||||
var remoteBookSd = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 100.Megabytes(), age: 1);
|
||||
var remoteBookHdSmallOld = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 1200.Megabytes(), age: 1000);
|
||||
var remoteBookSmallYoung = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 1250.Megabytes(), age: 10);
|
||||
var remoteBookHdLargeYoung = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 3000.Megabytes(), age: 1);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbumSd));
|
||||
decisions.Add(new DownloadDecision(remoteAlbumHdSmallOld));
|
||||
decisions.Add(new DownloadDecision(remoteAlbumSmallYoung));
|
||||
decisions.Add(new DownloadDecision(remoteAlbumHdLargeYoung));
|
||||
decisions.Add(new DownloadDecision(remoteBookSd));
|
||||
decisions.Add(new DownloadDecision(remoteBookHdSmallOld));
|
||||
decisions.Add(new DownloadDecision(remoteBookSmallYoung));
|
||||
decisions.Add(new DownloadDecision(remoteBookHdLargeYoung));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteAlbumHdLargeYoung);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteBookHdLargeYoung);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_order_by_youngest()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), age: 10);
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), age: 5);
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), age: 10);
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), age: 5);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteAlbum2);
|
||||
qualifiedReports.First().RemoteBook.Should().Be(remoteBook2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_throw_if_no_albums_are_found()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), size: 500.Megabytes());
|
||||
|
||||
remoteAlbum1.Books = new List<Book>();
|
||||
remoteBook1.Books = new List<Book>();
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
Subject.PrioritizeDecisions(decisions);
|
||||
}
|
||||
|
|
@ -149,12 +149,12 @@ public void should_put_usenet_above_torrent_when_usenet_is_preferred()
|
|||
{
|
||||
GivenPreferredDownloadProtocol(DownloadProtocol.Usenet);
|
||||
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Release.DownloadProtocol.Should().Be(DownloadProtocol.Usenet);
|
||||
|
|
@ -165,12 +165,12 @@ public void should_put_torrent_above_usenet_when_torrent_is_preferred()
|
|||
{
|
||||
GivenPreferredDownloadProtocol(DownloadProtocol.Torrent);
|
||||
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Torrent);
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320), downloadProtocol: DownloadProtocol.Usenet);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Release.DownloadProtocol.Should().Be(DownloadProtocol.Torrent);
|
||||
|
|
@ -179,14 +179,14 @@ public void should_put_torrent_above_usenet_when_torrent_is_preferred()
|
|||
[Test]
|
||||
public void should_prefer_discography_pack_above_single_album()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.FLAC));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
|
||||
remoteAlbum1.ParsedBookInfo.Discography = true;
|
||||
remoteBook1.ParsedBookInfo.Discography = true;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Discography.Should().BeTrue();
|
||||
|
|
@ -195,14 +195,14 @@ public void should_prefer_discography_pack_above_single_album()
|
|||
[Test]
|
||||
public void should_prefer_quality_over_discography_pack()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
|
||||
remoteAlbum1.ParsedBookInfo.Discography = true;
|
||||
remoteBook1.ParsedBookInfo.Discography = true;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Discography.Should().BeFalse();
|
||||
|
|
@ -211,22 +211,22 @@ public void should_prefer_quality_over_discography_pack()
|
|||
[Test]
|
||||
public void should_prefer_single_album_over_multi_album()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1), GivenAlbum(2) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Books.Count.Should().Be(remoteAlbum2.Books.Count);
|
||||
qualifiedReports.First().RemoteBook.Books.Count.Should().Be(remoteBook2.Books.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_releases_with_more_seeders()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var torrentInfo1 = new TorrentInfo();
|
||||
torrentInfo1.PublishDate = DateTime.Now;
|
||||
|
|
@ -237,12 +237,12 @@ public void should_prefer_releases_with_more_seeders()
|
|||
var torrentInfo2 = torrentInfo1.JsonClone();
|
||||
torrentInfo2.Seeders = 100;
|
||||
|
||||
remoteAlbum1.Release = torrentInfo1;
|
||||
remoteAlbum2.Release = torrentInfo2;
|
||||
remoteBook1.Release = torrentInfo1;
|
||||
remoteBook2.Release = torrentInfo2;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Seeders.Should().Be(torrentInfo2.Seeders);
|
||||
|
|
@ -251,8 +251,8 @@ public void should_prefer_releases_with_more_seeders()
|
|||
[Test]
|
||||
public void should_prefer_releases_with_more_peers_given_equal_number_of_seeds()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var torrentInfo1 = new TorrentInfo();
|
||||
torrentInfo1.PublishDate = DateTime.Now;
|
||||
|
|
@ -264,12 +264,12 @@ public void should_prefer_releases_with_more_peers_given_equal_number_of_seeds()
|
|||
var torrentInfo2 = torrentInfo1.JsonClone();
|
||||
torrentInfo2.Peers = 100;
|
||||
|
||||
remoteAlbum1.Release = torrentInfo1;
|
||||
remoteAlbum2.Release = torrentInfo2;
|
||||
remoteBook1.Release = torrentInfo1;
|
||||
remoteBook2.Release = torrentInfo2;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Peers.Should().Be(torrentInfo2.Peers);
|
||||
|
|
@ -278,8 +278,8 @@ public void should_prefer_releases_with_more_peers_given_equal_number_of_seeds()
|
|||
[Test]
|
||||
public void should_prefer_releases_with_more_peers_no_seeds()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var torrentInfo1 = new TorrentInfo();
|
||||
torrentInfo1.PublishDate = DateTime.Now;
|
||||
|
|
@ -292,12 +292,12 @@ public void should_prefer_releases_with_more_peers_no_seeds()
|
|||
torrentInfo2.Seeders = 0;
|
||||
torrentInfo2.Peers = 100;
|
||||
|
||||
remoteAlbum1.Release = torrentInfo1;
|
||||
remoteAlbum2.Release = torrentInfo2;
|
||||
remoteBook1.Release = torrentInfo1;
|
||||
remoteBook2.Release = torrentInfo2;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Peers.Should().Be(torrentInfo2.Peers);
|
||||
|
|
@ -306,8 +306,8 @@ public void should_prefer_releases_with_more_peers_no_seeds()
|
|||
[Test]
|
||||
public void should_prefer_first_release_if_peers_and_size_are_too_similar()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var torrentInfo1 = new TorrentInfo();
|
||||
torrentInfo1.PublishDate = DateTime.Now;
|
||||
|
|
@ -321,12 +321,12 @@ public void should_prefer_first_release_if_peers_and_size_are_too_similar()
|
|||
torrentInfo2.Peers = 10;
|
||||
torrentInfo1.Size = 250.Megabytes();
|
||||
|
||||
remoteAlbum1.Release = torrentInfo1;
|
||||
remoteAlbum2.Release = torrentInfo2;
|
||||
remoteBook1.Release = torrentInfo1;
|
||||
remoteBook2.Release = torrentInfo2;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Should().Be(torrentInfo1);
|
||||
|
|
@ -335,28 +335,28 @@ public void should_prefer_first_release_if_peers_and_size_are_too_similar()
|
|||
[Test]
|
||||
public void should_prefer_first_release_if_age_and_size_are_too_similar()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
remoteAlbum1.Release.PublishDate = DateTime.UtcNow.AddDays(-100);
|
||||
remoteAlbum1.Release.Size = 200.Megabytes();
|
||||
remoteBook1.Release.PublishDate = DateTime.UtcNow.AddDays(-100);
|
||||
remoteBook1.Release.Size = 200.Megabytes();
|
||||
|
||||
remoteAlbum2.Release.PublishDate = DateTime.UtcNow.AddDays(-150);
|
||||
remoteAlbum2.Release.Size = 250.Megabytes();
|
||||
remoteBook2.Release.PublishDate = DateTime.UtcNow.AddDays(-150);
|
||||
remoteBook2.Release.Size = 250.Megabytes();
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.Release.Should().Be(remoteAlbum1.Release);
|
||||
qualifiedReports.First().RemoteBook.Release.Should().Be(remoteBook1.Release);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_quality_over_the_number_of_peers()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.AZW3));
|
||||
|
||||
var torrentInfo1 = new TorrentInfo();
|
||||
torrentInfo1.PublishDate = DateTime.Now;
|
||||
|
|
@ -370,12 +370,12 @@ public void should_prefer_quality_over_the_number_of_peers()
|
|||
torrentInfo2.Peers = 10;
|
||||
torrentInfo1.Size = 250.Megabytes();
|
||||
|
||||
remoteAlbum1.Release = torrentInfo1;
|
||||
remoteAlbum2.Release = torrentInfo2;
|
||||
remoteBook1.Release = torrentInfo1;
|
||||
remoteBook2.Release = torrentInfo2;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
((TorrentInfo)qualifiedReports.First().RemoteBook.Release).Should().Be(torrentInfo1);
|
||||
|
|
@ -384,12 +384,12 @@ public void should_prefer_quality_over_the_number_of_peers()
|
|||
[Test]
|
||||
public void should_put_higher_quality_before_lower_always()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Quality.Should().Be(Quality.MP3_320);
|
||||
|
|
@ -398,15 +398,15 @@ public void should_put_higher_quality_before_lower_always()
|
|||
[Test]
|
||||
public void should_prefer_higher_score_over_lower_score()
|
||||
{
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC));
|
||||
|
||||
remoteAlbum1.PreferredWordScore = 10;
|
||||
remoteAlbum2.PreferredWordScore = 0;
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.PreferredWordScore.Should().Be(10);
|
||||
|
|
@ -419,15 +419,15 @@ public void should_prefer_proper_over_score_when_download_propers_is_prefer_and_
|
|||
.Setup(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.PreferAndUpgrade);
|
||||
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
|
||||
remoteAlbum1.PreferredWordScore = 10;
|
||||
remoteAlbum2.PreferredWordScore = 0;
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(2);
|
||||
|
|
@ -440,15 +440,15 @@ public void should_prefer_proper_over_score_when_download_propers_is_do_not_upgr
|
|||
.Setup(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.DoNotUpgrade);
|
||||
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
|
||||
remoteAlbum1.PreferredWordScore = 10;
|
||||
remoteAlbum2.PreferredWordScore = 0;
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Revision.Version.Should().Be(2);
|
||||
|
|
@ -461,15 +461,15 @@ public void should_prefer_score_over_proper_when_download_propers_is_do_not_pref
|
|||
.Setup(s => s.DownloadPropersAndRepacks)
|
||||
.Returns(ProperDownloadTypes.DoNotPrefer);
|
||||
|
||||
var remoteAlbum1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteAlbum2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
var remoteBook1 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(1)));
|
||||
var remoteBook2 = GivenRemoteAlbum(new List<Book> { GivenAlbum(1) }, new QualityModel(Quality.FLAC, new Revision(2)));
|
||||
|
||||
remoteAlbum1.PreferredWordScore = 10;
|
||||
remoteAlbum2.PreferredWordScore = 0;
|
||||
remoteBook1.PreferredWordScore = 10;
|
||||
remoteBook2.PreferredWordScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteBook.ParsedBookInfo.Quality.Quality.Should().Be(Quality.FLAC);
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[TestFixture]
|
||||
public class ProtocolSpecificationFixture : CoreTest<ProtocolSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
private DelayProfile _delayProfile;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = new RemoteBook();
|
||||
_remoteAlbum.Release = new ReleaseInfo();
|
||||
_remoteAlbum.Author = new Author();
|
||||
_remoteBook = new RemoteBook();
|
||||
_remoteBook.Release = new ReleaseInfo();
|
||||
_remoteBook.Author = new Author();
|
||||
|
||||
_delayProfile = new DelayProfile();
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public void Setup()
|
|||
|
||||
private void GivenProtocol(DownloadProtocol downloadProtocol)
|
||||
{
|
||||
_remoteAlbum.Release.DownloadProtocol = downloadProtocol;
|
||||
_remoteBook.Release.DownloadProtocol = downloadProtocol;
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -42,7 +42,7 @@ public void should_be_true_if_usenet_and_usenet_is_enabled()
|
|||
GivenProtocol(DownloadProtocol.Usenet);
|
||||
_delayProfile.EnableUsenet = true;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(true);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().Be(true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -51,7 +51,7 @@ public void should_be_true_if_torrent_and_torrent_is_enabled()
|
|||
GivenProtocol(DownloadProtocol.Torrent);
|
||||
_delayProfile.EnableTorrent = true;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(true);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().Be(true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -60,7 +60,7 @@ public void should_be_false_if_usenet_and_usenet_is_disabled()
|
|||
GivenProtocol(DownloadProtocol.Usenet);
|
||||
_delayProfile.EnableUsenet = false;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(false);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().Be(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -69,7 +69,7 @@ public void should_be_false_if_torrent_and_torrent_is_disabled()
|
|||
GivenProtocol(DownloadProtocol.Torrent);
|
||||
_delayProfile.EnableTorrent = false;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(false);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().Be(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class QualityAllowedByProfileSpecificationFixture : CoreTest<QualityAllowedByProfileSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
public static object[] AllowedTestCases =
|
||||
{
|
||||
|
|
@ -36,7 +36,7 @@ public void Setup()
|
|||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.MP3_320.Id })
|
||||
.Build();
|
||||
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = fakeArtist,
|
||||
ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2)) },
|
||||
|
|
@ -47,20 +47,20 @@ public void Setup()
|
|||
[TestCaseSource(nameof(AllowedTestCases))]
|
||||
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality.Quality = qualityType;
|
||||
_remoteAlbum.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320);
|
||||
_remoteBook.ParsedBookInfo.Quality.Quality = qualityType;
|
||||
_remoteBook.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(nameof(DeniedTestCases))]
|
||||
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality.Quality = qualityType;
|
||||
_remoteAlbum.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320);
|
||||
_remoteBook.ParsedBookInfo.Quality.Quality = qualityType;
|
||||
_remoteBook.Author.QualityProfile.Value.Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3_320, Quality.MP3_320, Quality.MP3_320);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class QueueSpecificationFixture : CoreTest<QueueSpecification>
|
|||
{
|
||||
private Author _artist;
|
||||
private Book _album;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
private Author _otherArtist;
|
||||
private Book _otherAlbum;
|
||||
|
|
@ -55,7 +55,7 @@ public void Setup()
|
|||
_releaseInfo = Builder<ReleaseInfo>.CreateNew()
|
||||
.Build();
|
||||
|
||||
_remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
_remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo { Quality = new QualityModel(Quality.MP3_320) })
|
||||
|
|
@ -70,11 +70,11 @@ private void GivenEmptyQueue()
|
|||
.Returns(new List<Queue.Queue>());
|
||||
}
|
||||
|
||||
private void GivenQueue(IEnumerable<RemoteBook> remoteAlbums, TrackedDownloadState trackedDownloadState = TrackedDownloadState.Downloading)
|
||||
private void GivenQueue(IEnumerable<RemoteBook> remoteBooks, TrackedDownloadState trackedDownloadState = TrackedDownloadState.Downloading)
|
||||
{
|
||||
var queue = remoteAlbums.Select(remoteAlbum => new Queue.Queue
|
||||
var queue = remoteBooks.Select(remoteBook => new Queue.Queue
|
||||
{
|
||||
RemoteBook = remoteAlbum,
|
||||
RemoteBook = remoteBook,
|
||||
TrackedDownloadState = trackedDownloadState
|
||||
});
|
||||
|
||||
|
|
@ -87,20 +87,20 @@ private void GivenQueue(IEnumerable<RemoteBook> remoteAlbums, TrackedDownloadSta
|
|||
public void should_return_true_when_queue_is_empty()
|
||||
{
|
||||
GivenEmptyQueue();
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_artist_doesnt_match()
|
||||
{
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _otherArtist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -108,7 +108,7 @@ public void should_return_false_if_everything_is_the_same()
|
|||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -118,9 +118,9 @@ public void should_return_false_if_everything_is_the_same()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -128,7 +128,7 @@ public void should_return_true_when_quality_in_queue_is_lower()
|
|||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.MP3_320.Id;
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -138,14 +138,14 @@ public void should_return_true_when_quality_in_queue_is_lower()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_album_doesnt_match()
|
||||
{
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _otherAlbum })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -155,16 +155,16 @@ public void should_return_true_when_album_doesnt_match()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_qualities_are_the_same_with_higher_preferred_word_score()
|
||||
{
|
||||
_remoteAlbum.PreferredWordScore = 1;
|
||||
_remoteBook.PreferredWordScore = 1;
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -174,14 +174,14 @@ public void should_return_true_when_qualities_are_the_same_with_higher_preferred
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_when_qualities_are_the_same()
|
||||
{
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -191,8 +191,8 @@ public void should_return_false_when_qualities_are_the_same()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -200,7 +200,7 @@ public void should_return_false_when_quality_in_queue_is_better()
|
|||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -210,14 +210,14 @@ public void should_return_false_when_quality_in_queue_is_better()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_matching_multi_album_is_in_queue()
|
||||
{
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album, _otherAlbum })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -227,14 +227,14 @@ public void should_return_false_if_matching_multi_album_is_in_queue()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_album_has_one_album_in_queue()
|
||||
{
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -244,16 +244,16 @@ public void should_return_false_if_multi_album_has_one_album_in_queue()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
_remoteAlbum.Books.Add(_otherAlbum);
|
||||
_remoteBook.Books.Add(_otherAlbum);
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_part_album_is_already_in_queue()
|
||||
{
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album, _otherAlbum })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -263,16 +263,16 @@ public void should_return_false_if_multi_part_album_is_already_in_queue()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
_remoteAlbum.Books.Add(_otherAlbum);
|
||||
_remoteBook.Books.Add(_otherAlbum);
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_multi_part_album_has_two_albums_in_queue()
|
||||
{
|
||||
var remoteAlbums = Builder<RemoteBook>.CreateListOfSize(2)
|
||||
var remoteBooks = Builder<RemoteBook>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -286,9 +286,9 @@ public void should_return_false_if_multi_part_album_has_two_albums_in_queue()
|
|||
.With(r => r.Books = new List<Book> { _otherAlbum })
|
||||
.Build();
|
||||
|
||||
_remoteAlbum.Books.Add(_otherAlbum);
|
||||
GivenQueue(remoteAlbums);
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
_remoteBook.Books.Add(_otherAlbum);
|
||||
GivenQueue(remoteBooks);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -297,7 +297,7 @@ public void should_return_false_when_quality_is_better_and_upgrade_allowed_is_fa
|
|||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
_artist.QualityProfile.Value.UpgradeAllowed = false;
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -307,8 +307,8 @@ public void should_return_false_when_quality_is_better_and_upgrade_allowed_is_fa
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum });
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
GivenQueue(new List<RemoteBook> { remoteBook });
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -316,7 +316,7 @@ public void should_return_true_if_everything_is_the_same_for_failed_pending()
|
|||
{
|
||||
_artist.QualityProfile.Value.Cutoff = Quality.FLAC.Id;
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = _artist)
|
||||
.With(r => r.Books = new List<Book> { _album })
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo
|
||||
|
|
@ -326,9 +326,9 @@ public void should_return_true_if_everything_is_the_same_for_failed_pending()
|
|||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteBook> { remoteAlbum }, TrackedDownloadState.DownloadFailedPending);
|
||||
GivenQueue(new List<RemoteBook> { remoteBook }, TrackedDownloadState.DownloadFailedPending);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class RawDiskSpecificationFixture : CoreTest<RawDiskSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Torrent }
|
||||
};
|
||||
|
|
@ -24,41 +24,41 @@ public void Setup()
|
|||
|
||||
private void WithContainer(string container)
|
||||
{
|
||||
_remoteAlbum.Release.Container = container;
|
||||
_remoteBook.Release.Container = container;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_no_container_specified()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_flac()
|
||||
{
|
||||
WithContainer("FLAC");
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_vob()
|
||||
{
|
||||
WithContainer("VOB");
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_iso()
|
||||
{
|
||||
WithContainer("ISO");
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_compare_case_insensitive()
|
||||
{
|
||||
WithContainer("vob");
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[TestFixture]
|
||||
public class ReleaseRestrictionsSpecificationFixture : CoreTest<ReleaseRestrictionsSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = new Author
|
||||
{
|
||||
|
|
@ -54,7 +54,7 @@ public void should_be_true_when_restrictions_are_empty()
|
|||
.Setup(s => s.AllForTags(It.IsAny<HashSet<int>>()))
|
||||
.Returns(new List<ReleaseProfile>());
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -62,7 +62,7 @@ public void should_be_true_when_title_contains_one_required_term()
|
|||
{
|
||||
GivenRestictions("WEBRip", null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -70,7 +70,7 @@ public void should_be_false_when_title_does_not_contain_any_required_terms()
|
|||
{
|
||||
GivenRestictions("doesnt,exist", null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -78,7 +78,7 @@ public void should_be_true_when_title_does_not_contain_any_ignored_terms()
|
|||
{
|
||||
GivenRestictions(null, "ignored");
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -86,7 +86,7 @@ public void should_be_false_when_title_contains_one_anded_ignored_terms()
|
|||
{
|
||||
GivenRestictions(null, "edited");
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[TestCase("EdiTED")]
|
||||
|
|
@ -97,7 +97,7 @@ public void should_ignore_case_when_matching_required(string required)
|
|||
{
|
||||
GivenRestictions(required, null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase("EdiTED")]
|
||||
|
|
@ -108,13 +108,13 @@ public void should_ignore_case_when_matching_ignored(string ignored)
|
|||
{
|
||||
GivenRestictions(null, ignored);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_contains_one_restricted_word_and_one_required_word()
|
||||
{
|
||||
_remoteAlbum.Release.Title = "[ www.Speed.cd ] - Katy Perry - Witness (2017) MP3 [320 kbps] ";
|
||||
_remoteBook.Release.Title = "[ www.Speed.cd ] - Katy Perry - Witness (2017) MP3 [320 kbps] ";
|
||||
|
||||
Mocker.GetMock<IReleaseProfileService>()
|
||||
.Setup(s => s.AllForTags(It.IsAny<HashSet<int>>()))
|
||||
|
|
@ -123,7 +123,7 @@ public void should_be_false_when_release_contains_one_restricted_word_and_one_re
|
|||
new ReleaseProfile { Required = "320", Ignored = "www.Speed.cd" }
|
||||
});
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[TestCase("/WEB/", true)]
|
||||
|
|
@ -134,7 +134,7 @@ public void should_match_perl_regex(string pattern, bool expected)
|
|||
{
|
||||
GivenRestictions(pattern, null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().Be(expected);
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().Be(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
[TestFixture]
|
||||
public class RepackSpecificationFixture : CoreTest<RepackSpecification>
|
||||
{
|
||||
private ParsedBookInfo _parsedAlbumInfo;
|
||||
private ParsedBookInfo _parsedBookInfo;
|
||||
private List<Book> _albums;
|
||||
private List<BookFile> _trackFiles;
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ public void Setup()
|
|||
{
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
|
||||
_parsedAlbumInfo = Builder<ParsedBookInfo>.CreateNew()
|
||||
_parsedBookInfo = Builder<ParsedBookInfo>.CreateNew()
|
||||
.With(p => p.Quality = new QualityModel(Quality.FLAC,
|
||||
new Revision(2, 0, false)))
|
||||
.With(p => p.ReleaseGroup = "Readarr")
|
||||
|
|
@ -48,12 +48,12 @@ public void Setup()
|
|||
[Test]
|
||||
public void should_return_true_if_it_is_not_a_repack()
|
||||
{
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeTrue();
|
||||
|
|
@ -66,14 +66,14 @@ public void should_return_true_if_there_are_is_no_track_files()
|
|||
.Setup(c => c.GetFilesByBook(It.IsAny<int>()))
|
||||
.Returns(new List<BookFile>());
|
||||
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedBookInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeTrue();
|
||||
|
|
@ -82,7 +82,7 @@ public void should_return_true_if_there_are_is_no_track_files()
|
|||
[Test]
|
||||
public void should_return_true_if_is_a_repack_for_a_different_quality()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedBookInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
|
|
@ -95,12 +95,12 @@ public void should_return_true_if_is_a_repack_for_a_different_quality()
|
|||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeTrue();
|
||||
|
|
@ -109,7 +109,7 @@ public void should_return_true_if_is_a_repack_for_a_different_quality()
|
|||
[Test]
|
||||
public void should_return_true_if_is_a_repack_for_all_existing_files()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedBookInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
|
|
@ -122,12 +122,12 @@ public void should_return_true_if_is_a_repack_for_all_existing_files()
|
|||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeTrue();
|
||||
|
|
@ -136,7 +136,7 @@ public void should_return_true_if_is_a_repack_for_all_existing_files()
|
|||
[Test]
|
||||
public void should_return_false_if_is_a_repack_for_some_but_not_all_trackfiles()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedBookInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
|
|
@ -151,12 +151,12 @@ public void should_return_false_if_is_a_repack_for_some_but_not_all_trackfiles()
|
|||
|
||||
_trackFiles.First().ReleaseGroup = "NotReadarr";
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeFalse();
|
||||
|
|
@ -165,7 +165,7 @@ public void should_return_false_if_is_a_repack_for_some_but_not_all_trackfiles()
|
|||
[Test]
|
||||
public void should_return_false_if_is_a_repack_for_different_group()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedBookInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
|
|
@ -178,12 +178,12 @@ public void should_return_false_if_is_a_repack_for_different_group()
|
|||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeFalse();
|
||||
|
|
@ -192,7 +192,7 @@ public void should_return_false_if_is_a_repack_for_different_group()
|
|||
[Test]
|
||||
public void should_return_false_if_release_group_for_existing_file_is_unknown()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedBookInfo.Quality.Revision.IsRepack = true;
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
|
|
@ -205,12 +205,12 @@ public void should_return_false_if_release_group_for_existing_file_is_unknown()
|
|||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeFalse();
|
||||
|
|
@ -219,8 +219,8 @@ public void should_return_false_if_release_group_for_existing_file_is_unknown()
|
|||
[Test]
|
||||
public void should_return_false_if_release_group_for_release_is_unknown()
|
||||
{
|
||||
_parsedAlbumInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedAlbumInfo.ReleaseGroup = null;
|
||||
_parsedBookInfo.Quality.Revision.IsRepack = true;
|
||||
_parsedBookInfo.ReleaseGroup = null;
|
||||
|
||||
_trackFiles.Select(c =>
|
||||
{
|
||||
|
|
@ -234,12 +234,12 @@ public void should_return_false_if_release_group_for_release_is_unknown()
|
|||
return c;
|
||||
}).ToList();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedAlbumInfo)
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(e => e.ParsedBookInfo = _parsedBookInfo)
|
||||
.With(e => e.Books = _albums)
|
||||
.Build();
|
||||
|
||||
Subject.IsSatisfiedBy(remoteAlbum, null)
|
||||
Subject.IsSatisfiedBy(remoteBook, null)
|
||||
.Accepted
|
||||
.Should()
|
||||
.BeFalse();
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
|||
|
||||
public class RetentionSpecificationFixture : CoreTest<RetentionSpecification>
|
||||
{
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Release = new ReleaseInfo() { DownloadProtocol = DownloadProtocol.Usenet }
|
||||
};
|
||||
|
|
@ -31,7 +31,7 @@ private void WithRetention(int days)
|
|||
|
||||
private void WithAge(int days)
|
||||
{
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow.AddDays(-days);
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow.AddDays(-days);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -40,7 +40,7 @@ public void should_return_true_when_retention_is_set_to_zero()
|
|||
WithRetention(0);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -49,7 +49,7 @@ public void should_return_true_when_release_if_younger_than_retention()
|
|||
WithRetention(1000);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -58,7 +58,7 @@ public void should_return_true_when_release_and_retention_are_the_same()
|
|||
WithRetention(100);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -67,7 +67,7 @@ public void should_return_false_when_old_than_retention()
|
|||
WithRetention(10);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -76,18 +76,18 @@ public void should_return_true_if_release_came_out_today_and_retention_is_zero()
|
|||
WithRetention(0);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_release_is_not_usenet()
|
||||
{
|
||||
_remoteAlbum.Release.DownloadProtocol = DownloadProtocol.Torrent;
|
||||
_remoteBook.Release.DownloadProtocol = DownloadProtocol.Torrent;
|
||||
|
||||
WithRetention(10);
|
||||
WithAge(100);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class DelaySpecificationFixture : CoreTest<DelaySpecification>
|
|||
{
|
||||
private QualityProfile _profile;
|
||||
private DelayProfile _delayProfile;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
|
@ -41,7 +41,7 @@ public void Setup()
|
|||
.With(s => s.QualityProfile = _profile)
|
||||
.Build();
|
||||
|
||||
_remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
_remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = artist)
|
||||
.Build();
|
||||
|
||||
|
|
@ -52,11 +52,11 @@ public void Setup()
|
|||
|
||||
_profile.Cutoff = Quality.AZW3.Id;
|
||||
|
||||
_remoteAlbum.ParsedBookInfo = new ParsedBookInfo();
|
||||
_remoteAlbum.Release = new ReleaseInfo();
|
||||
_remoteAlbum.Release.DownloadProtocol = DownloadProtocol.Usenet;
|
||||
_remoteBook.ParsedBookInfo = new ParsedBookInfo();
|
||||
_remoteBook.Release = new ReleaseInfo();
|
||||
_remoteBook.Release.DownloadProtocol = DownloadProtocol.Usenet;
|
||||
|
||||
_remoteAlbum.Books = Builder<Book>.CreateListOfSize(1).Build().ToList();
|
||||
_remoteBook.Books = Builder<Book>.CreateListOfSize(1).Build().ToList();
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
.Setup(s => s.GetFilesByBook(It.IsAny<int>()))
|
||||
|
|
@ -100,12 +100,12 @@ public void should_be_true_when_user_invoked_search()
|
|||
[Test]
|
||||
public void should_be_false_when_system_invoked_search_and_release_is_younger_than_delay()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI);
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI);
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, new BookSearchCriteria()).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, new BookSearchCriteria()).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -113,44 +113,44 @@ public void should_be_true_when_profile_does_not_have_a_delay()
|
|||
{
|
||||
_delayProfile.UsenetDelay = 0;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_quality_is_last_allowed_in_profile()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_is_older_than_delay()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI);
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow.AddHours(-10);
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI);
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow.AddHours(-10);
|
||||
|
||||
_delayProfile.UsenetDelay = 60;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_younger_than_delay()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI);
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MOBI);
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_is_a_proper_for_existing_album()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2));
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(version: 2));
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.MP3_320));
|
||||
GivenUpgradeForExistingFile();
|
||||
|
|
@ -161,14 +161,14 @@ public void should_be_true_when_release_is_a_proper_for_existing_album()
|
|||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_release_is_a_real_for_existing_album()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(real: 1));
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.MP3_320, new Revision(real: 1));
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.MP3_320));
|
||||
GivenUpgradeForExistingFile();
|
||||
|
|
@ -179,20 +179,20 @@ public void should_be_true_when_release_is_a_real_for_existing_album()
|
|||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_release_is_proper_for_existing_album_of_different_quality()
|
||||
{
|
||||
_remoteAlbum.ParsedBookInfo.Quality = new QualityModel(Quality.AZW3, new Revision(version: 2));
|
||||
_remoteAlbum.Release.PublishDate = DateTime.UtcNow;
|
||||
_remoteBook.ParsedBookInfo.Quality = new QualityModel(Quality.AZW3, new Revision(version: 2));
|
||||
_remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
GivenExistingFile(new QualityModel(Quality.PDF));
|
||||
|
||||
_delayProfile.UsenetDelay = 720;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class ArtistSpecificationFixture : TestBase<AuthorSpecification>
|
|||
{
|
||||
private Author _artist1;
|
||||
private Author _artist2;
|
||||
private RemoteBook _remoteAlbum = new RemoteBook();
|
||||
private RemoteBook _remoteBook = new RemoteBook();
|
||||
private SearchCriteriaBase _searchCriteria = new BookSearchCriteria();
|
||||
|
||||
[SetUp]
|
||||
|
|
@ -23,7 +23,7 @@ public void Setup()
|
|||
_artist1 = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
_artist2 = Builder<Author>.CreateNew().With(s => s.Id = 2).Build();
|
||||
|
||||
_remoteAlbum.Author = _artist1;
|
||||
_remoteBook.Author = _artist1;
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -31,7 +31,7 @@ public void should_return_false_if_artist_doesnt_match()
|
|||
{
|
||||
_searchCriteria.Author = _artist2;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, _searchCriteria).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, _searchCriteria).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -39,7 +39,7 @@ public void should_return_true_when_artist_ids_match()
|
|||
{
|
||||
_searchCriteria.Author = _artist1;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, _searchCriteria).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, _searchCriteria).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.Search
|
|||
public class TorrentSeedingSpecificationFixture : TestBase<TorrentSeedingSpecification>
|
||||
{
|
||||
private Author _artist;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
private IndexerDefinition _indexerDefinition;
|
||||
|
||||
[SetUp]
|
||||
|
|
@ -24,7 +24,7 @@ public void Setup()
|
|||
{
|
||||
_artist = Builder<Author>.CreateNew().With(s => s.Id = 1).Build();
|
||||
|
||||
_remoteAlbum = new RemoteBook
|
||||
_remoteBook = new RemoteBook
|
||||
{
|
||||
Author = _artist,
|
||||
Release = new TorrentInfo
|
||||
|
|
@ -47,27 +47,27 @@ public void Setup()
|
|||
|
||||
private void GivenReleaseSeeders(int? seeders)
|
||||
{
|
||||
(_remoteAlbum.Release as TorrentInfo).Seeders = seeders;
|
||||
(_remoteBook.Release as TorrentInfo).Seeders = seeders;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_not_torrent()
|
||||
{
|
||||
_remoteAlbum.Release = new ReleaseInfo
|
||||
_remoteBook.Release = new ReleaseInfo
|
||||
{
|
||||
IndexerId = 1,
|
||||
Title = "Artist - Album [FLAC-RlsGrp]"
|
||||
};
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_indexer_not_specified()
|
||||
{
|
||||
_remoteAlbum.Release.IndexerId = 0;
|
||||
_remoteBook.Release.IndexerId = 0;
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -77,7 +77,7 @@ public void should_return_true_if_indexer_no_longer_exists()
|
|||
.Setup(v => v.Get(It.IsAny<int>()))
|
||||
.Callback<int>(i => { throw new ModelNotFoundException(typeof(IndexerDefinition), i); });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -85,7 +85,7 @@ public void should_return_true_if_seeds_unknown()
|
|||
{
|
||||
GivenReleaseSeeders(null);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase(5)]
|
||||
|
|
@ -94,7 +94,7 @@ public void should_return_true_if_seeds_above_or_equal_to_limit(int seeders)
|
|||
{
|
||||
GivenReleaseSeeders(seeders);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestCase(0)]
|
||||
|
|
@ -103,7 +103,7 @@ public void should_return_false_if_seeds_belove_limit(int seeders)
|
|||
{
|
||||
GivenReleaseSeeders(seeders);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteAlbum, null).Accepted.Should().BeFalse();
|
||||
Subject.IsSatisfiedBy(_remoteBook, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ public void Setup()
|
|||
.With(h => h.Title = "Drone.S01E01.HDTV")
|
||||
.Build();
|
||||
|
||||
var remoteAlbum = BuildRemoteAlbum();
|
||||
var remoteBook = BuildRemoteAlbum();
|
||||
|
||||
_trackedDownload = Builder<TrackedDownload>.CreateNew()
|
||||
.With(c => c.State = TrackedDownloadState.Downloading)
|
||||
.With(c => c.DownloadItem = completed)
|
||||
.With(c => c.RemoteBook = remoteAlbum)
|
||||
.With(c => c.RemoteBook = remoteBook)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
|
|
@ -55,7 +55,7 @@ public void Setup()
|
|||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetArtist("Drone.S01E01.HDTV"))
|
||||
.Returns(remoteAlbum.Author);
|
||||
.Returns(remoteBook.Author);
|
||||
}
|
||||
|
||||
private Book CreateAlbum(int id)
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ public void Setup()
|
|||
.With(h => h.Title = "Drone.S01E01.HDTV")
|
||||
.Build();
|
||||
|
||||
var remoteAlbum = BuildRemoteAlbum();
|
||||
var remoteBook = BuildRemoteAlbum();
|
||||
|
||||
_trackedDownload = Builder<TrackedDownload>.CreateNew()
|
||||
.With(c => c.State = TrackedDownloadState.Downloading)
|
||||
.With(c => c.DownloadItem = completed)
|
||||
.With(c => c.RemoteBook = remoteAlbum)
|
||||
.With(c => c.RemoteBook = remoteBook)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IDownloadClient>()
|
||||
|
|
@ -51,7 +51,7 @@ public void Setup()
|
|||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetArtist("Drone.S01E01.HDTV"))
|
||||
.Returns(remoteAlbum.Author);
|
||||
.Returns(remoteBook.Author);
|
||||
}
|
||||
|
||||
private RemoteBook BuildRemoteAlbum()
|
||||
|
|
|
|||
|
|
@ -39,32 +39,32 @@ private Book GetAlbum(int id)
|
|||
|
||||
private RemoteBook GetRemoteAlbum(List<Book> albums, QualityModel quality, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet)
|
||||
{
|
||||
var remoteAlbum = new RemoteBook();
|
||||
remoteAlbum.ParsedBookInfo = new ParsedBookInfo();
|
||||
remoteAlbum.ParsedBookInfo.Quality = quality;
|
||||
var remoteBook = new RemoteBook();
|
||||
remoteBook.ParsedBookInfo = new ParsedBookInfo();
|
||||
remoteBook.ParsedBookInfo.Quality = quality;
|
||||
|
||||
remoteAlbum.Books = new List<Book>();
|
||||
remoteAlbum.Books.AddRange(albums);
|
||||
remoteBook.Books = new List<Book>();
|
||||
remoteBook.Books.AddRange(albums);
|
||||
|
||||
remoteAlbum.Release = new ReleaseInfo();
|
||||
remoteAlbum.Release.DownloadProtocol = downloadProtocol;
|
||||
remoteAlbum.Release.PublishDate = DateTime.UtcNow;
|
||||
remoteBook.Release = new ReleaseInfo();
|
||||
remoteBook.Release.DownloadProtocol = downloadProtocol;
|
||||
remoteBook.Release.PublishDate = DateTime.UtcNow;
|
||||
|
||||
remoteAlbum.Author = Builder<Author>.CreateNew()
|
||||
remoteBook.Author = Builder<Author>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||
.Build();
|
||||
|
||||
return remoteAlbum;
|
||||
return remoteBook;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_download_report_if_album_was_not_already_downloaded()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteBook>()), Times.Once());
|
||||
|
|
@ -74,11 +74,11 @@ public void should_download_report_if_album_was_not_already_downloaded()
|
|||
public void should_only_download_album_once()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteBook>()), Times.Once());
|
||||
|
|
@ -87,17 +87,17 @@ public void should_only_download_album_once()
|
|||
[Test]
|
||||
public void should_not_download_if_any_album_was_already_downloaded()
|
||||
{
|
||||
var remoteAlbum1 = GetRemoteAlbum(
|
||||
var remoteBook1 = GetRemoteAlbum(
|
||||
new List<Book> { GetAlbum(1) },
|
||||
new QualityModel(Quality.MP3_320));
|
||||
|
||||
var remoteAlbum2 = GetRemoteAlbum(
|
||||
var remoteBook2 = GetRemoteAlbum(
|
||||
new List<Book> { GetAlbum(1), GetAlbum(2) },
|
||||
new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteBook>()), Times.Once());
|
||||
|
|
@ -107,10 +107,10 @@ public void should_not_download_if_any_album_was_already_downloaded()
|
|||
public void should_return_downloaded_reports()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(1);
|
||||
}
|
||||
|
|
@ -118,17 +118,17 @@ public void should_return_downloaded_reports()
|
|||
[Test]
|
||||
public void should_return_all_downloaded_reports()
|
||||
{
|
||||
var remoteAlbum1 = GetRemoteAlbum(
|
||||
var remoteBook1 = GetRemoteAlbum(
|
||||
new List<Book> { GetAlbum(1) },
|
||||
new QualityModel(Quality.MP3_320));
|
||||
|
||||
var remoteAlbum2 = GetRemoteAlbum(
|
||||
var remoteBook2 = GetRemoteAlbum(
|
||||
new List<Book> { GetAlbum(2) },
|
||||
new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2);
|
||||
}
|
||||
|
|
@ -136,22 +136,22 @@ public void should_return_all_downloaded_reports()
|
|||
[Test]
|
||||
public void should_only_return_downloaded_reports()
|
||||
{
|
||||
var remoteAlbum1 = GetRemoteAlbum(
|
||||
var remoteBook1 = GetRemoteAlbum(
|
||||
new List<Book> { GetAlbum(1) },
|
||||
new QualityModel(Quality.MP3_320));
|
||||
|
||||
var remoteAlbum2 = GetRemoteAlbum(
|
||||
var remoteBook2 = GetRemoteAlbum(
|
||||
new List<Book> { GetAlbum(2) },
|
||||
new QualityModel(Quality.MP3_320));
|
||||
|
||||
var remoteAlbum3 = GetRemoteAlbum(
|
||||
var remoteBook3 = GetRemoteAlbum(
|
||||
new List<Book> { GetAlbum(2) },
|
||||
new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum1));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum3));
|
||||
decisions.Add(new DownloadDecision(remoteBook1));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
decisions.Add(new DownloadDecision(remoteBook3));
|
||||
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().HaveCount(2);
|
||||
}
|
||||
|
|
@ -160,10 +160,10 @@ public void should_only_return_downloaded_reports()
|
|||
public void should_not_add_to_downloaded_list_when_download_fails()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
|
||||
Mocker.GetMock<IDownloadService>().Setup(s => s.DownloadReport(It.IsAny<RemoteBook>())).Throws(new Exception());
|
||||
Subject.ProcessDecisions(decisions).Grabbed.Should().BeEmpty();
|
||||
|
|
@ -184,10 +184,10 @@ public void should_return_an_empty_list_when_none_are_appproved()
|
|||
public void should_not_grab_if_pending()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
decisions.Add(new DownloadDecision(remoteBook, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.IsAny<RemoteBook>()), Times.Never());
|
||||
|
|
@ -197,11 +197,11 @@ public void should_not_grab_if_pending()
|
|||
public void should_not_add_to_pending_if_album_was_grabbed()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
decisions.Add(new DownloadDecision(remoteBook, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IPendingReleaseService>().Verify(v => v.AddMany(It.IsAny<List<Tuple<DownloadDecision, PendingReleaseReason>>>()), Times.Never());
|
||||
|
|
@ -211,11 +211,11 @@ public void should_not_add_to_pending_if_album_was_grabbed()
|
|||
public void should_add_to_pending_even_if_already_added_to_pending()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
decisions.Add(new DownloadDecision(remoteBook, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
decisions.Add(new DownloadDecision(remoteBook, new Rejection("Failure!", RejectionType.Temporary)));
|
||||
|
||||
Subject.ProcessDecisions(decisions);
|
||||
Mocker.GetMock<IPendingReleaseService>().Verify(v => v.AddMany(It.IsAny<List<Tuple<DownloadDecision, PendingReleaseReason>>>()), Times.Once());
|
||||
|
|
@ -225,11 +225,11 @@ public void should_add_to_pending_even_if_already_added_to_pending()
|
|||
public void should_add_to_failed_if_already_failed_for_that_protocol()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
|
||||
Mocker.GetMock<IDownloadService>().Setup(s => s.DownloadReport(It.IsAny<RemoteBook>()))
|
||||
.Throws(new DownloadClientUnavailableException("Download client failed"));
|
||||
|
|
@ -242,12 +242,12 @@ public void should_add_to_failed_if_already_failed_for_that_protocol()
|
|||
public void should_not_add_to_failed_if_failed_for_a_different_protocol()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320), DownloadProtocol.Usenet);
|
||||
var remoteAlbum2 = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320), DownloadProtocol.Torrent);
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320), DownloadProtocol.Usenet);
|
||||
var remoteBook2 = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320), DownloadProtocol.Torrent);
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteAlbum2));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
decisions.Add(new DownloadDecision(remoteBook2));
|
||||
|
||||
Mocker.GetMock<IDownloadService>().Setup(s => s.DownloadReport(It.Is<RemoteBook>(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet)))
|
||||
.Throws(new DownloadClientUnavailableException("Download client failed"));
|
||||
|
|
@ -261,14 +261,14 @@ public void should_not_add_to_failed_if_failed_for_a_different_protocol()
|
|||
public void should_add_to_rejected_if_release_unavailable_on_indexer()
|
||||
{
|
||||
var albums = new List<Book> { GetAlbum(1) };
|
||||
var remoteAlbum = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
var remoteBook = GetRemoteAlbum(albums, new QualityModel(Quality.MP3_320));
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteAlbum));
|
||||
decisions.Add(new DownloadDecision(remoteBook));
|
||||
|
||||
Mocker.GetMock<IDownloadService>()
|
||||
.Setup(s => s.DownloadReport(It.IsAny<RemoteBook>()))
|
||||
.Throws(new ReleaseUnavailableException(remoteAlbum.Release, "That 404 Error is not just a Quirk"));
|
||||
.Throws(new ReleaseUnavailableException(remoteBook.Release, "That 404 Error is not just a Quirk"));
|
||||
|
||||
var result = Subject.ProcessDecisions(decisions);
|
||||
|
||||
|
|
|
|||
|
|
@ -89,17 +89,17 @@ protected void GivenMagnetFilePath(string extension = ".magnet")
|
|||
|
||||
protected override RemoteBook CreateRemoteAlbum()
|
||||
{
|
||||
var remoteAlbum = base.CreateRemoteAlbum();
|
||||
var remoteBook = base.CreateRemoteAlbum();
|
||||
var torrentInfo = new TorrentInfo();
|
||||
|
||||
torrentInfo.Title = remoteAlbum.Release.Title;
|
||||
torrentInfo.DownloadUrl = remoteAlbum.Release.DownloadUrl;
|
||||
torrentInfo.DownloadProtocol = remoteAlbum.Release.DownloadProtocol;
|
||||
torrentInfo.Title = remoteBook.Release.Title;
|
||||
torrentInfo.DownloadUrl = remoteBook.Release.DownloadUrl;
|
||||
torrentInfo.DownloadProtocol = remoteBook.Release.DownloadProtocol;
|
||||
torrentInfo.MagnetUrl = "magnet:?xt=urn:btih:755248817d32b00cc853e633ecdc48e4c21bff15&dn=Artist.Album.FLAC.loseless-DEFiNE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710";
|
||||
|
||||
remoteAlbum.Release = torrentInfo;
|
||||
remoteBook.Release = torrentInfo;
|
||||
|
||||
return remoteAlbum;
|
||||
return remoteBook;
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -141,9 +141,9 @@ public void should_return_category()
|
|||
[Test]
|
||||
public void Download_should_download_file_if_it_doesnt_exist()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Once());
|
||||
|
|
@ -155,9 +155,9 @@ public void Download_should_save_magnet_if_enabled()
|
|||
{
|
||||
GivenMagnetFilePath();
|
||||
Subject.Definition.Settings.As<TorrentBlackholeSettings>().SaveMagnetFiles = true;
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
Subject.Download(remoteAlbum);
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = null;
|
||||
Subject.Download(remoteBook);
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_magnetFilePath), Times.Once());
|
||||
|
|
@ -173,10 +173,10 @@ public void Download_should_save_magnet_using_specified_extension()
|
|||
Subject.Definition.Settings.As<TorrentBlackholeSettings>().SaveMagnetFiles = true;
|
||||
Subject.Definition.Settings.As<TorrentBlackholeSettings>().MagnetFileExtension = magnetFileExtension;
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = null;
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Never());
|
||||
|
|
@ -188,10 +188,10 @@ public void Download_should_save_magnet_using_specified_extension()
|
|||
public void Download_should_not_save_magnet_if_disabled()
|
||||
{
|
||||
GivenMagnetFilePath();
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = null;
|
||||
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteBook));
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Never());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Never());
|
||||
|
|
@ -204,9 +204,9 @@ public void Download_should_prefer_torrent_over_magnet()
|
|||
{
|
||||
Subject.Definition.Settings.As<TorrentBlackholeSettings>().SaveMagnetFiles = true;
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Once());
|
||||
|
|
@ -220,10 +220,10 @@ public void Download_should_replace_illegal_characters_in_title()
|
|||
var illegalTitle = "Radiohead - Scotch Mist [2008/FLAC/Lossless]";
|
||||
var expectedFilename = Path.Combine(_blackholeFolder, "Radiohead - Scotch Mist [2008+FLAC+Lossless]" + Path.GetExtension(_filePath));
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.Title = illegalTitle;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.Title = illegalTitle;
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(expectedFilename), Times.Once());
|
||||
|
|
@ -233,10 +233,10 @@ public void Download_should_replace_illegal_characters_in_title()
|
|||
[Test]
|
||||
public void Download_should_throw_if_magnet_and_torrent_url_does_not_exist()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = null;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = null;
|
||||
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteBook));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -308,9 +308,9 @@ public void should_return_status_with_outputdirs()
|
|||
[Test]
|
||||
public void should_return_null_hash()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum).Should().BeNull();
|
||||
Subject.Download(remoteBook).Should().BeNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ public void should_return_category()
|
|||
[Test]
|
||||
public void Download_should_download_file_if_it_doesnt_exist()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(_filePath), Times.Once());
|
||||
|
|
@ -128,10 +128,10 @@ public void Download_should_replace_illegal_characters_in_title()
|
|||
var illegalTitle = "Radiohead - Scotch Mist [2008/FLAC/Lossless]";
|
||||
var expectedFilename = Path.Combine(_blackholeFolder, "Radiohead - Scotch Mist [2008+FLAC+Lossless]" + Path.GetExtension(_filePath));
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.Title = illegalTitle;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.Title = illegalTitle;
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.Get(It.Is<HttpRequest>(v => v.Url.FullUri == _downloadUrl)), Times.Once());
|
||||
Mocker.GetMock<IDiskProvider>().Verify(c => c.OpenWriteStream(expectedFilename), Times.Once());
|
||||
|
|
|
|||
|
|
@ -204,9 +204,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -216,10 +216,10 @@ public void Download_should_get_hash_from_magnet_url(string magnetUrl, string ex
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,19 +44,19 @@ public void SetupBase()
|
|||
|
||||
protected virtual RemoteBook CreateRemoteAlbum()
|
||||
{
|
||||
var remoteAlbum = new RemoteBook();
|
||||
remoteAlbum.Release = new ReleaseInfo();
|
||||
remoteAlbum.Release.Title = _title;
|
||||
remoteAlbum.Release.DownloadUrl = _downloadUrl;
|
||||
remoteAlbum.Release.DownloadProtocol = Subject.Protocol;
|
||||
var remoteBook = new RemoteBook();
|
||||
remoteBook.Release = new ReleaseInfo();
|
||||
remoteBook.Release.Title = _title;
|
||||
remoteBook.Release.DownloadUrl = _downloadUrl;
|
||||
remoteBook.Release.DownloadProtocol = Subject.Protocol;
|
||||
|
||||
remoteAlbum.ParsedBookInfo = new ParsedBookInfo();
|
||||
remoteBook.ParsedBookInfo = new ParsedBookInfo();
|
||||
|
||||
remoteAlbum.Books = new List<Book>();
|
||||
remoteBook.Books = new List<Book>();
|
||||
|
||||
remoteAlbum.Author = new Author();
|
||||
remoteBook.Author = new Author();
|
||||
|
||||
return remoteAlbum;
|
||||
return remoteBook;
|
||||
}
|
||||
|
||||
protected void VerifyIdentifiable(DownloadClientItem downloadClientItem)
|
||||
|
|
|
|||
|
|
@ -387,9 +387,9 @@ public void Download_with_TvDirectory_should_force_directory()
|
|||
GivenTvDirectory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -404,9 +404,9 @@ public void Download_with_category_should_force_directory()
|
|||
GivenMusicCategory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -420,9 +420,9 @@ public void Download_without_TvDirectory_and_Category_should_use_default()
|
|||
GivenSerialNumber();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -495,13 +495,13 @@ public void GetItems_should_throw_if_serial_number_unavailable()
|
|||
[Test]
|
||||
public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Mocker.GetMock<ISerialNumberProvider>()
|
||||
.Setup(s => s.GetSerialNumber(_settings))
|
||||
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));
|
||||
|
||||
Assert.Throws(Is.InstanceOf<Exception>(), () => Subject.Download(remoteAlbum));
|
||||
Assert.Throws(Is.InstanceOf<Exception>(), () => Subject.Download(remoteBook));
|
||||
|
||||
Mocker.GetMock<IDownloadStationTaskProxy>()
|
||||
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ public class UsenetDownloadStationFixture : DownloadClientFixtureBase<UsenetDown
|
|||
protected string _defaultDestination = "somepath";
|
||||
protected OsPath _physicalPath = new OsPath("/mnt/sdb1/mydata");
|
||||
|
||||
protected RemoteBook _remoteAlbum;
|
||||
protected RemoteBook _remoteBook;
|
||||
|
||||
protected Dictionary<string, object> _downloadStationConfigItems;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_remoteAlbum = CreateRemoteAlbum();
|
||||
_remoteBook = CreateRemoteAlbum();
|
||||
|
||||
_settings = new DownloadStationSettings()
|
||||
{
|
||||
|
|
@ -66,7 +66,7 @@ public void Setup()
|
|||
Detail = new Dictionary<string, string>
|
||||
{
|
||||
{ "destination", "shared/folder" },
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" }
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteBook.Release.Title) + ".nzb" }
|
||||
},
|
||||
Transfer = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -89,7 +89,7 @@ public void Setup()
|
|||
Detail = new Dictionary<string, string>
|
||||
{
|
||||
{ "destination", "shared/folder" },
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" }
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteBook.Release.Title) + ".nzb" }
|
||||
},
|
||||
Transfer = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -112,7 +112,7 @@ public void Setup()
|
|||
Detail = new Dictionary<string, string>
|
||||
{
|
||||
{ "destination", "shared/folder" },
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" }
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteBook.Release.Title) + ".nzb" }
|
||||
},
|
||||
Transfer = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -135,7 +135,7 @@ public void Setup()
|
|||
Detail = new Dictionary<string, string>
|
||||
{
|
||||
{ "destination", "shared/folder" },
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" }
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteBook.Release.Title) + ".nzb" }
|
||||
},
|
||||
Transfer = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -158,7 +158,7 @@ public void Setup()
|
|||
Detail = new Dictionary<string, string>
|
||||
{
|
||||
{ "destination", "shared/folder" },
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteAlbum.Release.Title) + ".nzb" }
|
||||
{ "uri", FileNameBuilder.CleanFileName(_remoteBook.Release.Title) + ".nzb" }
|
||||
},
|
||||
Transfer = new Dictionary<string, string>
|
||||
{
|
||||
|
|
@ -264,9 +264,9 @@ public void Download_with_TvDirectory_should_force_directory()
|
|||
GivenTvDirectory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -281,9 +281,9 @@ public void Download_with_category_should_force_directory()
|
|||
GivenMusicCategory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -297,9 +297,9 @@ public void Download_without_TvDirectory_and_Category_should_use_default()
|
|||
GivenSerialNumber();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -372,13 +372,13 @@ public void GetItems_should_throw_if_serial_number_unavailable()
|
|||
[Test]
|
||||
public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Mocker.GetMock<ISerialNumberProvider>()
|
||||
.Setup(s => s.GetSerialNumber(_settings))
|
||||
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));
|
||||
|
||||
Assert.Throws(Is.InstanceOf<Exception>(), () => Subject.Download(remoteAlbum));
|
||||
Assert.Throws(Is.InstanceOf<Exception>(), () => Subject.Download(remoteBook));
|
||||
|
||||
Mocker.GetMock<IDownloadStationTaskProxy>()
|
||||
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, _settings), Times.Never());
|
||||
|
|
|
|||
|
|
@ -200,9 +200,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -279,14 +279,14 @@ public void GetItems_should_ignore_torrents_with_a_different_category()
|
|||
[Test]
|
||||
public void Download_from_magnet_link_should_return_hash_uppercase()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
remoteAlbum.Release.DownloadUrl = "magnet:?xt=urn:btih:a45129e59d8750f9da982f53552b1e4f0457ee9f";
|
||||
remoteBook.Release.DownloadUrl = "magnet:?xt=urn:btih:a45129e59d8750f9da982f53552b1e4f0457ee9f";
|
||||
|
||||
Mocker.GetMock<IHadoukenProxy>()
|
||||
.Setup(v => v.AddTorrentUri(It.IsAny<HadoukenSettings>(), It.IsAny<string>()));
|
||||
|
||||
var result = Subject.Download(remoteAlbum);
|
||||
var result = Subject.Download(remoteBook);
|
||||
|
||||
Assert.IsFalse(result.Any(c => char.IsLower(c)));
|
||||
}
|
||||
|
|
@ -294,13 +294,13 @@ public void Download_from_magnet_link_should_return_hash_uppercase()
|
|||
[Test]
|
||||
public void Download_from_torrent_file_should_return_hash_uppercase()
|
||||
{
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Mocker.GetMock<IHadoukenProxy>()
|
||||
.Setup(v => v.AddTorrentFile(It.IsAny<HadoukenSettings>(), It.IsAny<byte[]>()))
|
||||
.Returns("hash");
|
||||
|
||||
var result = Subject.Download(remoteAlbum);
|
||||
var result = Subject.Download(remoteBook);
|
||||
|
||||
Assert.IsFalse(result.Any(c => char.IsLower(c)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,9 +204,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -216,9 +216,9 @@ public void Download_should_throw_if_failed()
|
|||
{
|
||||
GivenFailedDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Assert.Throws<DownloadClientException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<DownloadClientException>(() => Subject.Download(remoteBook));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
|||
|
|
@ -335,9 +335,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -347,9 +347,9 @@ public void Download_should_throw_if_failed()
|
|||
{
|
||||
GivenFailedDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
Assert.Throws<DownloadClientRejectedReleaseException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<DownloadClientRejectedReleaseException>(() => Subject.Download(remoteBook));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class PneumaticProviderFixture : CoreTest<Pneumatic>
|
|||
private string _pneumaticFolder;
|
||||
private string _strmFolder;
|
||||
private string _nzbPath;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
|
@ -30,12 +30,12 @@ public void Setup()
|
|||
_nzbPath = Path.Combine(_pneumaticFolder, _title + ".nzb").AsOsAgnostic();
|
||||
_strmFolder = @"d:\unsorted tv\".AsOsAgnostic();
|
||||
|
||||
_remoteAlbum = new RemoteBook();
|
||||
_remoteAlbum.Release = new ReleaseInfo();
|
||||
_remoteAlbum.Release.Title = _title;
|
||||
_remoteAlbum.Release.DownloadUrl = _nzbUrl;
|
||||
_remoteBook = new RemoteBook();
|
||||
_remoteBook.Release = new ReleaseInfo();
|
||||
_remoteBook.Release.Title = _title;
|
||||
_remoteBook.Release.DownloadUrl = _nzbUrl;
|
||||
|
||||
_remoteAlbum.ParsedBookInfo = new ParsedBookInfo();
|
||||
_remoteBook.ParsedBookInfo = new ParsedBookInfo();
|
||||
|
||||
Subject.Definition = new DownloadClientDefinition();
|
||||
Subject.Definition.Settings = new PneumaticSettings
|
||||
|
|
@ -53,7 +53,7 @@ private void WithFailedDownload()
|
|||
[Test]
|
||||
public void should_download_file_if_it_doesnt_exist()
|
||||
{
|
||||
Subject.Download(_remoteAlbum);
|
||||
Subject.Download(_remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(_nzbUrl, _nzbPath, null), Times.Once());
|
||||
}
|
||||
|
|
@ -63,16 +63,16 @@ public void should_throw_on_failed_download()
|
|||
{
|
||||
WithFailedDownload();
|
||||
|
||||
Assert.Throws<WebException>(() => Subject.Download(_remoteAlbum));
|
||||
Assert.Throws<WebException>(() => Subject.Download(_remoteBook));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_if_discography_download()
|
||||
{
|
||||
_remoteAlbum.Release.Title = "Alien Ant Farm - Discography";
|
||||
_remoteAlbum.ParsedBookInfo.Discography = true;
|
||||
_remoteBook.Release.Title = "Alien Ant Farm - Discography";
|
||||
_remoteBook.ParsedBookInfo.Discography = true;
|
||||
|
||||
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteAlbum));
|
||||
Assert.Throws<NotSupportedException>(() => Subject.Download(_remoteBook));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -86,9 +86,9 @@ public void should_replace_illegal_characters_in_title()
|
|||
{
|
||||
var illegalTitle = "Saturday Night Live - S38E08 - Jeremy Renner/Maroon 5 [SDTV]";
|
||||
var expectedFilename = Path.Combine(_pneumaticFolder, "Saturday Night Live - S38E08 - Jeremy Renner+Maroon 5 [SDTV].nzb");
|
||||
_remoteAlbum.Release.Title = illegalTitle;
|
||||
_remoteBook.Release.Title = illegalTitle;
|
||||
|
||||
Subject.Download(_remoteAlbum);
|
||||
Subject.Download(_remoteBook);
|
||||
|
||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(It.IsAny<string>(), expectedFilename, null), Times.Once());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,9 +263,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -275,10 +275,10 @@ public void Download_should_get_hash_from_magnet_url(string magnetUrl, string ex
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
@ -290,10 +290,10 @@ public void Download_should_refuse_magnet_if_no_trackers_provided_and_dht_is_dis
|
|||
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
|
||||
.Returns(new QBittorrentPreferences() { DhtEnabled = false });
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR";
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR";
|
||||
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteAlbum));
|
||||
Assert.Throws<ReleaseDownloadException>(() => Subject.Download(remoteBook));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -303,10 +303,10 @@ public void Download_should_accept_magnet_if_trackers_provided_and_dht_is_disabl
|
|||
.Setup(s => s.GetConfig(It.IsAny<QBittorrentSettings>()))
|
||||
.Returns(new QBittorrentPreferences { DhtEnabled = false });
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp://abc";
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = "magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp://abc";
|
||||
|
||||
Assert.DoesNotThrow(() => Subject.Download(remoteAlbum));
|
||||
Assert.DoesNotThrow(() => Subject.Download(remoteBook));
|
||||
|
||||
Mocker.GetMock<IQBittorrentProxy>()
|
||||
.Verify(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()), Times.Once());
|
||||
|
|
@ -318,9 +318,9 @@ public void Download_should_set_top_priority()
|
|||
GivenHighPriority();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<IQBittorrentProxy>()
|
||||
.Verify(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()), Times.Once());
|
||||
|
|
@ -336,9 +336,9 @@ public void Download_should_not_fail_if_top_priority_not_available()
|
|||
.Setup(v => v.MoveTorrentToTopInQueue(It.IsAny<string>(), It.IsAny<QBittorrentSettings>()))
|
||||
.Throws(new HttpException(new HttpResponse(new HttpRequest("http://me.local/"), new HttpHeader(), new byte[0], System.Net.HttpStatusCode.Forbidden)));
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -370,9 +370,9 @@ public void Download_should_handle_http_redirect_to_magnet()
|
|||
GivenRedirectToMagnet();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -383,9 +383,9 @@ public void Download_should_handle_http_redirect_to_torrent()
|
|||
GivenRedirectToTorrent();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,9 +115,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,10 +298,10 @@ public void Download_should_use_clean_title(string title, string filename)
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.Title = title;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.Title = title;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<ISabnzbdProxy>()
|
||||
.Verify(v => v.DownloadNzb(It.IsAny<byte[]>(), filename, It.IsAny<string>(), It.IsAny<int>(), It.IsAny<SabnzbdSettings>()), Times.Once());
|
||||
|
|
@ -312,9 +312,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -353,14 +353,14 @@ public void Download_should_use_sabRecentTvPriority_when_recentEpisode_is_true()
|
|||
.Setup(s => s.DownloadNzb(It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<string>(), (int)SabnzbdPriority.High, It.IsAny<SabnzbdSettings>()))
|
||||
.Returns(new SabnzbdAddResponse { Ids = new List<string> { "readarrtest" } });
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Books = Builder<Book>.CreateListOfSize(1)
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Books = Builder<Book>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.ReleaseDate = DateTime.Today)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
Subject.Download(remoteAlbum);
|
||||
Subject.Download(remoteBook);
|
||||
|
||||
Mocker.GetMock<ISabnzbdProxy>()
|
||||
.Verify(v => v.DownloadNzb(It.IsAny<byte[]>(), It.IsAny<string>(), It.IsAny<string>(), (int)SabnzbdPriority.High, It.IsAny<SabnzbdSettings>()), Times.Once());
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -71,9 +71,9 @@ public void Download_with_TvDirectory_should_force_directory()
|
|||
GivenTvDirectory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -87,9 +87,9 @@ public void Download_with_category_should_force_directory()
|
|||
GivenMusicCategory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -105,9 +105,9 @@ public void Download_with_category_should_not_have_double_slashes()
|
|||
|
||||
_transmissionConfigItems["download-dir"] += "/";
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -120,9 +120,9 @@ public void Download_without_TvDirectory_and_Category_should_use_default()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -135,10 +135,10 @@ public void Download_should_get_hash_from_magnet_url(string magnetUrl, string ex
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,9 +232,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -256,10 +256,10 @@ public void Download_should_get_hash_from_magnet_url(string magnetUrl, string ex
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
@ -355,9 +355,9 @@ public void Download_should_handle_http_redirect_to_magnet()
|
|||
GivenRedirectToMagnet();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -368,9 +368,9 @@ public void Download_should_handle_http_redirect_to_torrent()
|
|||
GivenRedirectToTorrent();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ public void Download_should_return_unique_id()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
|
@ -80,9 +80,9 @@ public void Download_with_TvDirectory_should_force_directory()
|
|||
GivenTvDirectory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -96,9 +96,9 @@ public void Download_with_category_should_force_directory()
|
|||
GivenMusicCategory();
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -114,9 +114,9 @@ public void Download_with_category_should_not_have_double_slashes()
|
|||
|
||||
_transmissionConfigItems["download-dir"] += "/";
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -129,9 +129,9 @@ public void Download_without_TvDirectory_and_Category_should_use_default()
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().NotBeNullOrEmpty();
|
||||
|
||||
|
|
@ -144,10 +144,10 @@ public void Download_should_get_hash_from_magnet_url(string magnetUrl, string ex
|
|||
{
|
||||
GivenSuccessfulDownload();
|
||||
|
||||
var remoteAlbum = CreateRemoteAlbum();
|
||||
remoteAlbum.Release.DownloadUrl = magnetUrl;
|
||||
var remoteBook = CreateRemoteAlbum();
|
||||
remoteBook.Release.DownloadUrl = magnetUrl;
|
||||
|
||||
var id = Subject.Download(remoteAlbum);
|
||||
var id = Subject.Download(remoteBook);
|
||||
|
||||
id.Should().Be(expectedHash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public void Setup()
|
|||
|
||||
_grabHistory = Builder<History.History>.CreateListOfSize(2).BuildList();
|
||||
|
||||
var remoteAlbum = new RemoteBook
|
||||
var remoteBook = new RemoteBook
|
||||
{
|
||||
Author = new Author(),
|
||||
Books = new List<Book> { new Book { Id = 1 } }
|
||||
|
|
@ -41,7 +41,7 @@ public void Setup()
|
|||
_trackedDownload = Builder<TrackedDownload>.CreateNew()
|
||||
.With(c => c.State = TrackedDownloadState.DownloadFailedPending)
|
||||
.With(c => c.DownloadItem = completed)
|
||||
.With(c => c.RemoteBook = remoteAlbum)
|
||||
.With(c => c.RemoteBook = remoteBook)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public void Setup()
|
|||
|
||||
_grabHistory = Builder<History.History>.CreateListOfSize(2).BuildList();
|
||||
|
||||
var remoteAlbum = new RemoteBook
|
||||
var remoteBook = new RemoteBook
|
||||
{
|
||||
Author = new Author(),
|
||||
Books = new List<Book> { new Book { Id = 1 } }
|
||||
|
|
@ -41,7 +41,7 @@ public void Setup()
|
|||
_trackedDownload = Builder<TrackedDownload>.CreateNew()
|
||||
.With(c => c.State = TrackedDownloadState.Downloading)
|
||||
.With(c => c.DownloadItem = completed)
|
||||
.With(c => c.RemoteBook = remoteAlbum)
|
||||
.With(c => c.RemoteBook = remoteBook)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ public class AddFixture : CoreTest<PendingReleaseService>
|
|||
private Book _album;
|
||||
private QualityProfile _profile;
|
||||
private ReleaseInfo _release;
|
||||
private ParsedBookInfo _parsedAlbumInfo;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private ParsedBookInfo _parsedBookInfo;
|
||||
private RemoteBook _remoteBook;
|
||||
private List<PendingRelease> _heldReleases;
|
||||
|
||||
[SetUp]
|
||||
|
|
@ -54,16 +54,16 @@ public void Setup()
|
|||
|
||||
_release = Builder<ReleaseInfo>.CreateNew().Build();
|
||||
|
||||
_parsedAlbumInfo = Builder<ParsedBookInfo>.CreateNew().Build();
|
||||
_parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
_parsedBookInfo = Builder<ParsedBookInfo>.CreateNew().Build();
|
||||
_parsedBookInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
|
||||
_remoteAlbum = new RemoteBook();
|
||||
_remoteAlbum.Books = new List<Book> { _album };
|
||||
_remoteAlbum.Author = _artist;
|
||||
_remoteAlbum.ParsedBookInfo = _parsedAlbumInfo;
|
||||
_remoteAlbum.Release = _release;
|
||||
_remoteBook = new RemoteBook();
|
||||
_remoteBook.Books = new List<Book> { _album };
|
||||
_remoteBook.Author = _artist;
|
||||
_remoteBook.ParsedBookInfo = _parsedBookInfo;
|
||||
_remoteBook.Release = _release;
|
||||
|
||||
_temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
_temporarilyRejected = new DownloadDecision(_remoteBook, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
|
||||
_heldReleases = new List<PendingRelease>();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ public class RemoveGrabbedFixture : CoreTest<PendingReleaseService>
|
|||
private Book _album;
|
||||
private QualityProfile _profile;
|
||||
private ReleaseInfo _release;
|
||||
private ParsedBookInfo _parsedAlbumInfo;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private ParsedBookInfo _parsedBookInfo;
|
||||
private RemoteBook _remoteBook;
|
||||
private List<PendingRelease> _heldReleases;
|
||||
|
||||
[SetUp]
|
||||
|
|
@ -54,16 +54,16 @@ public void Setup()
|
|||
|
||||
_release = Builder<ReleaseInfo>.CreateNew().Build();
|
||||
|
||||
_parsedAlbumInfo = Builder<ParsedBookInfo>.CreateNew().Build();
|
||||
_parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
_parsedBookInfo = Builder<ParsedBookInfo>.CreateNew().Build();
|
||||
_parsedBookInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
|
||||
_remoteAlbum = new RemoteBook();
|
||||
_remoteAlbum.Books = new List<Book> { _album };
|
||||
_remoteAlbum.Author = _artist;
|
||||
_remoteAlbum.ParsedBookInfo = _parsedAlbumInfo;
|
||||
_remoteAlbum.Release = _release;
|
||||
_remoteBook = new RemoteBook();
|
||||
_remoteBook.Books = new List<Book> { _album };
|
||||
_remoteBook.Author = _artist;
|
||||
_remoteBook.ParsedBookInfo = _parsedBookInfo;
|
||||
_remoteBook.Release = _release;
|
||||
|
||||
_temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
_temporarilyRejected = new DownloadDecision(_remoteBook, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
|
||||
_heldReleases = new List<PendingRelease>();
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public void Setup()
|
|||
|
||||
private void GivenHeldRelease(QualityModel quality)
|
||||
{
|
||||
var parsedEpisodeInfo = _parsedAlbumInfo.JsonClone();
|
||||
var parsedEpisodeInfo = _parsedBookInfo.JsonClone();
|
||||
parsedEpisodeInfo.Quality = quality;
|
||||
|
||||
var heldReleases = Builder<PendingRelease>.CreateListOfSize(1)
|
||||
|
|
@ -110,9 +110,9 @@ private void GivenHeldRelease(QualityModel quality)
|
|||
[Test]
|
||||
public void should_delete_if_the_grabbed_quality_is_the_same()
|
||||
{
|
||||
GivenHeldRelease(_parsedAlbumInfo.Quality);
|
||||
GivenHeldRelease(_parsedBookInfo.Quality);
|
||||
|
||||
Subject.Handle(new BookGrabbedEvent(_remoteAlbum));
|
||||
Subject.Handle(new BookGrabbedEvent(_remoteBook));
|
||||
|
||||
VerifyDelete();
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ public void should_delete_if_the_grabbed_quality_is_the_higher()
|
|||
{
|
||||
GivenHeldRelease(new QualityModel(Quality.MP3_320));
|
||||
|
||||
Subject.Handle(new BookGrabbedEvent(_remoteAlbum));
|
||||
Subject.Handle(new BookGrabbedEvent(_remoteBook));
|
||||
|
||||
VerifyDelete();
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ public void should_not_delete_if_the_grabbed_quality_is_the_lower()
|
|||
{
|
||||
GivenHeldRelease(new QualityModel(Quality.FLAC));
|
||||
|
||||
Subject.Handle(new BookGrabbedEvent(_remoteAlbum));
|
||||
Subject.Handle(new BookGrabbedEvent(_remoteBook));
|
||||
|
||||
VerifyNoDelete();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ public class RemoveRejectedFixture : CoreTest<PendingReleaseService>
|
|||
private Book _album;
|
||||
private QualityProfile _profile;
|
||||
private ReleaseInfo _release;
|
||||
private ParsedBookInfo _parsedAlbumInfo;
|
||||
private RemoteBook _remoteAlbum;
|
||||
private ParsedBookInfo _parsedBookInfo;
|
||||
private RemoteBook _remoteBook;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
|
@ -54,16 +54,16 @@ public void Setup()
|
|||
|
||||
_release = Builder<ReleaseInfo>.CreateNew().Build();
|
||||
|
||||
_parsedAlbumInfo = Builder<ParsedBookInfo>.CreateNew().Build();
|
||||
_parsedAlbumInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
_parsedBookInfo = Builder<ParsedBookInfo>.CreateNew().Build();
|
||||
_parsedBookInfo.Quality = new QualityModel(Quality.MP3_320);
|
||||
|
||||
_remoteAlbum = new RemoteBook();
|
||||
_remoteAlbum.Books = new List<Book> { _album };
|
||||
_remoteAlbum.Author = _artist;
|
||||
_remoteAlbum.ParsedBookInfo = _parsedAlbumInfo;
|
||||
_remoteAlbum.Release = _release;
|
||||
_remoteBook = new RemoteBook();
|
||||
_remoteBook.Books = new List<Book> { _album };
|
||||
_remoteBook.Author = _artist;
|
||||
_remoteBook.ParsedBookInfo = _parsedBookInfo;
|
||||
_remoteBook.Release = _release;
|
||||
|
||||
_temporarilyRejected = new DownloadDecision(_remoteAlbum, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
_temporarilyRejected = new DownloadDecision(_remoteBook, new Rejection("Temp Rejected", RejectionType.Temporary));
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ public void Setup()
|
|||
{
|
||||
_albums = new List<Book>();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Books = _albums)
|
||||
.Build();
|
||||
|
||||
_trackedDownload = Builder<TrackedDownload>.CreateNew()
|
||||
.With(t => t.RemoteBook = remoteAlbum)
|
||||
.With(t => t.RemoteBook = remoteBook)
|
||||
.Build();
|
||||
|
||||
_historyItems = new List<History.History>();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public void should_track_downloads_using_the_source_title_if_it_cannot_be_found_
|
|||
{
|
||||
GivenDownloadHistory();
|
||||
|
||||
var remoteAlbum = new RemoteBook
|
||||
var remoteBook = new RemoteBook
|
||||
{
|
||||
Author = new Author() { Id = 5 },
|
||||
Books = new List<Book> { new Book { Id = 4 } },
|
||||
|
|
@ -52,7 +52,7 @@ public void should_track_downloads_using_the_source_title_if_it_cannot_be_found_
|
|||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.Map(It.Is<ParsedBookInfo>(i => i.BookTitle == "Audio Album" && i.AuthorName == "Audio Artist"), It.IsAny<int>(), It.IsAny<IEnumerable<int>>()))
|
||||
.Returns(remoteAlbum);
|
||||
.Returns(remoteBook);
|
||||
|
||||
var client = new DownloadClientDefinition()
|
||||
{
|
||||
|
|
@ -80,7 +80,7 @@ public void should_unmap_tracked_download_if_album_deleted()
|
|||
{
|
||||
GivenDownloadHistory();
|
||||
|
||||
var remoteAlbum = new RemoteBook
|
||||
var remoteBook = new RemoteBook
|
||||
{
|
||||
Author = new Author() { Id = 5 },
|
||||
Books = new List<Book> { new Book { Id = 4 } },
|
||||
|
|
@ -93,7 +93,7 @@ public void should_unmap_tracked_download_if_album_deleted()
|
|||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.Map(It.Is<ParsedBookInfo>(i => i.BookTitle == "Audio Album" && i.AuthorName == "Audio Artist"), It.IsAny<int>(), It.IsAny<IEnumerable<int>>()))
|
||||
.Returns(remoteAlbum);
|
||||
.Returns(remoteBook);
|
||||
|
||||
var client = new DownloadClientDefinition()
|
||||
{
|
||||
|
|
@ -117,7 +117,7 @@ public void should_unmap_tracked_download_if_album_deleted()
|
|||
.Returns(default(RemoteBook));
|
||||
|
||||
// handle deletion event
|
||||
Subject.Handle(new BookDeletedEvent(remoteAlbum.Books.First(), false, false));
|
||||
Subject.Handle(new BookDeletedEvent(remoteBook.Books.First(), false, false));
|
||||
|
||||
// verify download has null remote album
|
||||
var trackedDownloads = Subject.GetTrackedDownloads();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public void Setup()
|
|||
.Returns(_artist);
|
||||
|
||||
Mocker.GetMock<IMetadataFileService>()
|
||||
.Setup(c => c.GetFilesByArtist(_artist.First().Id))
|
||||
.Setup(c => c.GetFilesByAuthor(_artist.First().Id))
|
||||
.Returns(_metadata);
|
||||
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.CleanupMetadataImages).Returns(true);
|
||||
|
|
@ -48,7 +48,7 @@ public void Setup()
|
|||
public void should_not_process_non_image_files()
|
||||
{
|
||||
_metadata.First().RelativePath = "album\\file.xml".AsOsAgnostic();
|
||||
_metadata.First().Type = MetadataType.TrackMetadata;
|
||||
_metadata.First().Type = MetadataType.BookMetadata;
|
||||
|
||||
Subject.Clean();
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public void should_delete_html_images()
|
|||
var imagePath = "C:\\Music\\Album\\image.jpg".AsOsAgnostic();
|
||||
_metadata.First().LastUpdated = new DateTime(2014, 12, 29);
|
||||
_metadata.First().RelativePath = "Album\\image.jpg".AsOsAgnostic();
|
||||
_metadata.First().Type = MetadataType.ArtistImage;
|
||||
_metadata.First().Type = MetadataType.AuthorImage;
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.OpenReadStream(imagePath))
|
||||
|
|
@ -111,7 +111,7 @@ public void should_delete_empty_images()
|
|||
{
|
||||
var imagePath = "C:\\Music\\Album\\image.jpg".AsOsAgnostic();
|
||||
_metadata.First().LastUpdated = new DateTime(2014, 12, 29);
|
||||
_metadata.First().Type = MetadataType.AlbumImage;
|
||||
_metadata.First().Type = MetadataType.BookImage;
|
||||
_metadata.First().RelativePath = "Album\\image.jpg".AsOsAgnostic();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public void should_not_delete_metadata_files_when_they_are_for_the_same_artist_b
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.ArtistMetadata)
|
||||
.With(m => m.Type = MetadataType.AuthorMetadata)
|
||||
.With(m => m.AuthorId = 1)
|
||||
.BuildListOfNew();
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ public void should_not_delete_metadata_files_for_different_artist()
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.ArtistMetadata)
|
||||
.With(m => m.Type = MetadataType.AuthorMetadata)
|
||||
.With(m => m.Consumer = "XbmcMetadata")
|
||||
.BuildListOfNew();
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ public void should_delete_metadata_files_when_they_are_for_the_same_artist_and_c
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.ArtistMetadata)
|
||||
.With(m => m.Type = MetadataType.AuthorMetadata)
|
||||
.With(m => m.AuthorId = 1)
|
||||
.With(m => m.Consumer = "XbmcMetadata")
|
||||
.BuildListOfNew();
|
||||
|
|
@ -70,7 +70,7 @@ public void should_not_delete_metadata_files_when_they_are_for_the_same_album_bu
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.AlbumMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.AuthorId = 1)
|
||||
.With(m => m.BookId = 1)
|
||||
.BuildListOfNew();
|
||||
|
|
@ -85,7 +85,7 @@ public void should_not_delete_metadata_files_for_different_album()
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.AlbumMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.Consumer = "XbmcMetadata")
|
||||
.With(m => m.AuthorId = 1)
|
||||
.BuildListOfNew();
|
||||
|
|
@ -100,7 +100,7 @@ public void should_delete_metadata_files_when_they_are_for_the_same_album_and_co
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.AlbumMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.AuthorId = 1)
|
||||
.With(m => m.BookId = 1)
|
||||
.With(m => m.Consumer = "XbmcMetadata")
|
||||
|
|
@ -127,7 +127,7 @@ public void should_not_delete_metadata_files_when_they_are_for_the_same_track_bu
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.TrackMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.BookFileId = 1)
|
||||
.BuildListOfNew();
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ public void should_not_delete_metadata_files_for_different_track()
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.TrackMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.Consumer = "XbmcMetadata")
|
||||
.BuildListOfNew();
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ public void should_delete_metadata_files_when_they_are_for_the_same_track_and_co
|
|||
{
|
||||
var files = Builder<MetadataFile>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(m => m.Type = MetadataType.TrackMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.BookFileId = 1)
|
||||
.With(m => m.Consumer = "XbmcMetadata")
|
||||
.BuildListOfNew();
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public void should_delete_album_metadata_files_that_have_albumid_of_zero()
|
|||
|
||||
var metadataFile = Builder<MetadataFile>.CreateNew()
|
||||
.With(m => m.AuthorId = artist.Id)
|
||||
.With(m => m.Type = MetadataType.AlbumMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.BookId = 0)
|
||||
.With(m => m.BookFileId = null)
|
||||
.BuildNew();
|
||||
|
|
@ -168,7 +168,7 @@ public void should_delete_album_image_files_that_have_albumid_of_zero()
|
|||
|
||||
var metadataFile = Builder<MetadataFile>.CreateNew()
|
||||
.With(m => m.AuthorId = artist.Id)
|
||||
.With(m => m.Type = MetadataType.AlbumImage)
|
||||
.With(m => m.Type = MetadataType.BookImage)
|
||||
.With(m => m.BookId = 0)
|
||||
.With(m => m.BookFileId = null)
|
||||
.BuildNew();
|
||||
|
|
@ -188,7 +188,7 @@ public void should_delete_track_metadata_files_that_have_trackfileid_of_zero()
|
|||
|
||||
var metadataFile = Builder<MetadataFile>.CreateNew()
|
||||
.With(m => m.AuthorId = artist.Id)
|
||||
.With(m => m.Type = MetadataType.TrackMetadata)
|
||||
.With(m => m.Type = MetadataType.BookMetadata)
|
||||
.With(m => m.BookFileId = 0)
|
||||
.BuildNew();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ public void Setup()
|
|||
.With(v => v.Status = DownloadItemStatus.Downloading)
|
||||
.Build();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(v => v.Author = new Author())
|
||||
.Build();
|
||||
|
||||
_trackedDownload = new TrackedDownload
|
||||
{
|
||||
DownloadItem = downloadItem,
|
||||
RemoteBook = remoteAlbum,
|
||||
RemoteBook = remoteBook,
|
||||
State = TrackedDownloadState.Downloading
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ public void Setup()
|
|||
.With(v => v.Status = DownloadItemStatus.Downloading)
|
||||
.Build();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(v => v.Author = new Author())
|
||||
.Build();
|
||||
|
||||
_trackedDownload = new TrackedDownload
|
||||
{
|
||||
DownloadItem = downloadItem,
|
||||
RemoteBook = remoteAlbum,
|
||||
RemoteBook = remoteBook,
|
||||
State = TrackedDownloadState.Downloading
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class RefreshArtistServiceFixture : CoreTest<RefreshAuthorService>
|
|||
private Book _album1;
|
||||
private Book _album2;
|
||||
private List<Book> _albums;
|
||||
private List<Book> _remoteAlbums;
|
||||
private List<Book> _remoteBooks;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
|
|
@ -40,8 +40,8 @@ public void Setup()
|
|||
|
||||
_albums = new List<Book> { _album1, _album2 };
|
||||
|
||||
_remoteAlbums = _albums.JsonClone();
|
||||
_remoteAlbums.ForEach(x => x.Id = 0);
|
||||
_remoteBooks = _albums.JsonClone();
|
||||
_remoteBooks.ForEach(x => x.Id = 0);
|
||||
|
||||
var metadata = Builder<AuthorMetadata>.CreateNew().Build();
|
||||
var series = Builder<Series>.CreateListOfSize(1).BuildList();
|
||||
|
|
@ -116,7 +116,7 @@ public void should_not_publish_artist_updated_event_if_metadata_not_updated()
|
|||
{
|
||||
var newArtistInfo = _artist.JsonClone();
|
||||
newArtistInfo.Metadata = _artist.Metadata.Value.JsonClone();
|
||||
newArtistInfo.Books = _remoteAlbums;
|
||||
newArtistInfo.Books = _remoteBooks;
|
||||
|
||||
GivenNewArtistInfo(newArtistInfo);
|
||||
GivenAlbumsForRefresh(_albums);
|
||||
|
|
@ -137,7 +137,7 @@ public void should_publish_artist_updated_event_if_metadata_updated()
|
|||
{
|
||||
new MediaCover.MediaCover(MediaCover.MediaCoverTypes.Logo, "dummy")
|
||||
};
|
||||
newArtistInfo.Books = _remoteAlbums;
|
||||
newArtistInfo.Books = _remoteBooks;
|
||||
|
||||
GivenNewArtistInfo(newArtistInfo);
|
||||
GivenAlbumsForRefresh(new List<Book>());
|
||||
|
|
@ -189,7 +189,7 @@ public void should_update_if_musicbrainz_id_changed_and_no_clash()
|
|||
{
|
||||
var newArtistInfo = _artist.JsonClone();
|
||||
newArtistInfo.Metadata = _artist.Metadata.Value.JsonClone();
|
||||
newArtistInfo.Books = _remoteAlbums;
|
||||
newArtistInfo.Books = _remoteBooks;
|
||||
newArtistInfo.ForeignAuthorId = _artist.ForeignAuthorId + 1;
|
||||
newArtistInfo.Metadata.Value.Id = 100;
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ public void should_merge_if_musicbrainz_id_changed_and_new_id_already_exists()
|
|||
|
||||
var newArtistInfo = clash.JsonClone();
|
||||
newArtistInfo.Metadata = clash.Metadata.Value.JsonClone();
|
||||
newArtistInfo.Books = _remoteAlbums;
|
||||
newArtistInfo.Books = _remoteBooks;
|
||||
|
||||
GivenNewArtistInfo(newArtistInfo);
|
||||
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public void should_parse_artist_name_and_album_title(string postTitle, string na
|
|||
public void should_parse_artist_name_and_album_title_by_search_criteria(string releaseTitle)
|
||||
{
|
||||
GivenSearchCriteria("Black Sabbath", "Black Sabbath");
|
||||
var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
var parseResult = Parser.Parser.ParseBookTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
parseResult.AuthorName.ToLowerInvariant().Should().Be("black sabbath");
|
||||
parseResult.BookTitle.ToLowerInvariant().Should().Be("black sabbath");
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ public void should_parse_year_or_year_range_from_discography(string releaseTitle
|
|||
public void should_not_parse_artist_name_and_album_title_by_incorrect_search_criteria()
|
||||
{
|
||||
GivenSearchCriteria("Abba", "Abba");
|
||||
var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria("Black Sabbath Black Sabbath FLAC", _artist, _albums);
|
||||
var parseResult = Parser.Parser.ParseBookTitleWithSearchCriteria("Black Sabbath Black Sabbath FLAC", _artist, _albums);
|
||||
parseResult.Should().BeNull();
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ public void should_not_parse_artist_name_and_album_title_by_incorrect_search_cri
|
|||
public void should_escape_albums(string artist, string album, string releaseTitle)
|
||||
{
|
||||
GivenSearchCriteria(artist, album);
|
||||
var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
var parseResult = Parser.Parser.ParseBookTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
parseResult.BookTitle.Should().Be(album);
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ public void should_escape_albums(string artist, string album, string releaseTitl
|
|||
public void should_escape_artists(string artist, string album, string releaseTitle)
|
||||
{
|
||||
GivenSearchCriteria(artist, album);
|
||||
var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
var parseResult = Parser.Parser.ParseBookTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
parseResult.AuthorName.Should().Be(artist);
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ public void should_escape_artists(string artist, string album, string releaseTit
|
|||
public void should_match_with_accent_in_artist_and_album(string artist, string album, string releaseTitle)
|
||||
{
|
||||
GivenSearchCriteria(artist, album);
|
||||
var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
var parseResult = Parser.Parser.ParseBookTitleWithSearchCriteria(releaseTitle, _artist, _albums);
|
||||
parseResult.AuthorName.Should().Be("Michael Buble");
|
||||
parseResult.BookTitle.Should().Be("Michael Buble");
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ public void should_find_result_if_multiple_albums_in_searchcriteria()
|
|||
GivenSearchCriteria("Michael Bubl\u00E9", "love");
|
||||
GivenSearchCriteria("Michael Bubl\u00E9", "Christmas");
|
||||
GivenSearchCriteria("Michael Bubl\u00E9", "To Be Loved");
|
||||
var parseResult = Parser.Parser.ParseAlbumTitleWithSearchCriteria(
|
||||
var parseResult = Parser.Parser.ParseBookTitleWithSearchCriteria(
|
||||
"Michael Buble Christmas (Deluxe Special Edition) CD FLAC 2012 UNDERTONE iNT", _artist, _albums);
|
||||
parseResult.AuthorName.Should().Be("Michael Buble");
|
||||
parseResult.BookTitle.Should().Be("Christmas");
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public void SetUp()
|
|||
.With(e => e.AuthorId = artist.Id)
|
||||
.Build();
|
||||
|
||||
var remoteAlbum = Builder<RemoteBook>.CreateNew()
|
||||
var remoteBook = Builder<RemoteBook>.CreateNew()
|
||||
.With(r => r.Author = artist)
|
||||
.With(r => r.Books = new List<Book>(albums))
|
||||
.With(r => r.ParsedBookInfo = new ParsedBookInfo())
|
||||
|
|
@ -43,7 +43,7 @@ public void SetUp()
|
|||
_trackedDownloads = Builder<TrackedDownload>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(v => v.DownloadItem = downloadItem)
|
||||
.With(v => v.RemoteBook = remoteAlbum)
|
||||
.With(v => v.RemoteBook = remoteBook)
|
||||
.Build()
|
||||
.ToList();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.Books.Events
|
||||
{
|
||||
public class BookEditedEvent : IEvent
|
||||
{
|
||||
public Book Book { get; private set; }
|
||||
public Book OldAlbum { get; private set; }
|
||||
public Book OldBook { get; private set; }
|
||||
|
||||
public BookEditedEvent(Book book, Book oldAlbum)
|
||||
public BookEditedEvent(Book book, Book oldBook)
|
||||
{
|
||||
Book = book;
|
||||
OldAlbum = oldAlbum;
|
||||
OldBook = oldBook;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ private void HandleScanEvents(Author author)
|
|||
_logger.Info("[{0}] was recently added, performing post-add actions", author.Name);
|
||||
_bookMonitoredService.SetBookMonitoredStatus(author, author.AddOptions);
|
||||
|
||||
if (author.AddOptions.SearchForMissingAlbums)
|
||||
if (author.AddOptions.SearchForMissingBooks)
|
||||
{
|
||||
_commandQueueManager.Push(new MissingBookSearchCommand(author.Id));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ namespace NzbDrone.Core.Books
|
|||
{
|
||||
public class AddAuthorOptions : MonitoringOptions
|
||||
{
|
||||
public bool SearchForMissingAlbums { get; set; }
|
||||
public bool SearchForMissingBooks { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ public class AddBookOptions : IEmbeddedDocument
|
|||
public AddBookOptions()
|
||||
{
|
||||
// default in case not set in db
|
||||
AddType = AlbumAddType.Automatic;
|
||||
AddType = BookAddType.Automatic;
|
||||
}
|
||||
|
||||
public AlbumAddType AddType { get; set; }
|
||||
public bool SearchForNewAlbum { get; set; }
|
||||
public BookAddType AddType { get; set; }
|
||||
public bool SearchForNewBook { get; set; }
|
||||
}
|
||||
|
||||
public enum AlbumAddType
|
||||
public enum BookAddType
|
||||
{
|
||||
Automatic,
|
||||
Manual
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public interface IBookRepository : IBasicRepository<Book>
|
|||
List<Book> AuthorBooksBetweenDates(Author author, DateTime startDate, DateTime endDate, bool includeUnmonitored);
|
||||
void SetMonitoredFlat(Book book, bool monitored);
|
||||
void SetMonitored(IEnumerable<int> ids, bool monitored);
|
||||
List<Book> GetArtistAlbumsWithFiles(Author author);
|
||||
List<Book> GetAuthorBooksWithFiles(Author author);
|
||||
}
|
||||
|
||||
public class BookRepository : BasicRepository<Book>, IBookRepository
|
||||
|
|
@ -190,7 +190,7 @@ public Book FindByTitle(int authorMetadataId, string title)
|
|||
.ExclusiveOrDefault();
|
||||
}
|
||||
|
||||
public List<Book> GetArtistAlbumsWithFiles(Author author)
|
||||
public List<Book> GetAuthorBooksWithFiles(Author author)
|
||||
{
|
||||
return Query(Builder()
|
||||
.Join<Book, BookFile>((t, f) => t.Id == f.BookId)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public Book AddBook(Book book, bool doRefresh = true)
|
|||
_importListExclusionService.Delete(book.AuthorMetadata.Value.ForeignAuthorId);
|
||||
|
||||
// Note it's a manual addition so it's not deleted on next refresh
|
||||
book.AddOptions.AddType = AlbumAddType.Manual;
|
||||
book.AddOptions.AddType = BookAddType.Manual;
|
||||
|
||||
// Add the author if necessary
|
||||
var dbAuthor = _authorService.FindById(book.AuthorMetadata.Value.ForeignAuthorId);
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ public BookAddedService(ICacheManager cacheManager,
|
|||
public void SearchForRecentlyAdded(int authorId)
|
||||
{
|
||||
var allBooks = _bookService.GetBooksByAuthor(authorId);
|
||||
var toSearch = allBooks.Where(x => x.AddOptions.SearchForNewAlbum).ToList();
|
||||
var toSearch = allBooks.Where(x => x.AddOptions.SearchForNewBook).ToList();
|
||||
|
||||
if (toSearch.Any())
|
||||
{
|
||||
toSearch.ForEach(x => x.AddOptions.SearchForNewAlbum = false);
|
||||
toSearch.ForEach(x => x.AddOptions.SearchForNewBook = false);
|
||||
|
||||
_bookService.SetAddOptions(toSearch);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ public List<Book> AuthorBooksBetweenDates(Author author, DateTime start, DateTim
|
|||
|
||||
public List<Book> GetAuthorBooksWithFiles(Author author)
|
||||
{
|
||||
return _bookRepository.GetArtistAlbumsWithFiles(author);
|
||||
return _bookRepository.GetAuthorBooksWithFiles(author);
|
||||
}
|
||||
|
||||
public void InsertMany(List<Book> books)
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ protected override void EnsureNewParent(Book local, Book remote)
|
|||
protected override bool ShouldDelete(Book local)
|
||||
{
|
||||
// not manually added and has no files
|
||||
return local.AddOptions.AddType != AlbumAddType.Manual &&
|
||||
return local.AddOptions.AddType != BookAddType.Manual &&
|
||||
!_mediaFileService.GetFilesByBook(local.Id).Any();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.Books
|
|||
{
|
||||
public interface IRefreshSeriesService
|
||||
{
|
||||
bool RefreshSeriesInfo(int authorMetadataId, List<Series> remoteAlbums, Author remoteData, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate);
|
||||
bool RefreshSeriesInfo(int authorMetadataId, List<Series> remoteBooks, Author remoteData, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate);
|
||||
}
|
||||
|
||||
public class RefreshSeriesService : RefreshEntityServiceBase<Series, SeriesBookLink>, IRefreshSeriesService
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public int Compare(DownloadDecision x, DownloadDecision y)
|
|||
ComparePreferredWordScore,
|
||||
CompareProtocol,
|
||||
ComparePeersIfTorrent,
|
||||
CompareAlbumCount,
|
||||
CompareBookCount,
|
||||
CompareAgeIfUsenet,
|
||||
CompareSize
|
||||
};
|
||||
|
|
@ -63,44 +63,44 @@ private int CompareQuality(DownloadDecision x, DownloadDecision y)
|
|||
{
|
||||
if (_configService.DownloadPropersAndRepacks == ProperDownloadTypes.DoNotPrefer)
|
||||
{
|
||||
return CompareAll(CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Author.QualityProfile.Value.GetIndex(remoteAlbum.ParsedBookInfo.Quality.Quality)),
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.ParsedBookInfo.Quality.Revision.Real));
|
||||
return CompareAll(CompareBy(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.Author.QualityProfile.Value.GetIndex(remoteBook.ParsedBookInfo.Quality.Quality)),
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.ParsedBookInfo.Quality.Revision.Real));
|
||||
}
|
||||
|
||||
return CompareAll(CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Author.QualityProfile.Value.GetIndex(remoteAlbum.ParsedBookInfo.Quality.Quality)),
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.ParsedBookInfo.Quality.Revision.Real),
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.ParsedBookInfo.Quality.Revision.Version));
|
||||
return CompareAll(CompareBy(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.Author.QualityProfile.Value.GetIndex(remoteBook.ParsedBookInfo.Quality.Quality)),
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.ParsedBookInfo.Quality.Revision.Real),
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.ParsedBookInfo.Quality.Revision.Version));
|
||||
}
|
||||
|
||||
private int ComparePreferredWordScore(DownloadDecision x, DownloadDecision y)
|
||||
{
|
||||
return CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.PreferredWordScore);
|
||||
return CompareBy(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.PreferredWordScore);
|
||||
}
|
||||
|
||||
private int CompareProtocol(DownloadDecision x, DownloadDecision y)
|
||||
{
|
||||
var result = CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum =>
|
||||
var result = CompareBy(x.RemoteBook, y.RemoteBook, remoteBook =>
|
||||
{
|
||||
var delayProfile = _delayProfileService.BestForTags(remoteAlbum.Author.Tags);
|
||||
var downloadProtocol = remoteAlbum.Release.DownloadProtocol;
|
||||
var delayProfile = _delayProfileService.BestForTags(remoteBook.Author.Tags);
|
||||
var downloadProtocol = remoteBook.Release.DownloadProtocol;
|
||||
return downloadProtocol == delayProfile.PreferredProtocol;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private int CompareAlbumCount(DownloadDecision x, DownloadDecision y)
|
||||
private int CompareBookCount(DownloadDecision x, DownloadDecision y)
|
||||
{
|
||||
var discographyCompare = CompareBy(x.RemoteBook,
|
||||
y.RemoteBook,
|
||||
remoteAlbum => remoteAlbum.ParsedBookInfo.Discography);
|
||||
remoteBook => remoteBook.ParsedBookInfo.Discography);
|
||||
|
||||
if (discographyCompare != 0)
|
||||
{
|
||||
return discographyCompare;
|
||||
}
|
||||
|
||||
return CompareByReverse(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Books.Count);
|
||||
return CompareByReverse(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.Books.Count);
|
||||
}
|
||||
|
||||
private int ComparePeersIfTorrent(DownloadDecision x, DownloadDecision y)
|
||||
|
|
@ -114,15 +114,15 @@ private int ComparePeersIfTorrent(DownloadDecision x, DownloadDecision y)
|
|||
}
|
||||
|
||||
return CompareAll(
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum =>
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteBook =>
|
||||
{
|
||||
var seeders = TorrentInfo.GetSeeders(remoteAlbum.Release);
|
||||
var seeders = TorrentInfo.GetSeeders(remoteBook.Release);
|
||||
|
||||
return seeders.HasValue && seeders.Value > 0 ? Math.Round(Math.Log10(seeders.Value)) : 0;
|
||||
}),
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum =>
|
||||
CompareBy(x.RemoteBook, y.RemoteBook, remoteBook =>
|
||||
{
|
||||
var peers = TorrentInfo.GetPeers(remoteAlbum.Release);
|
||||
var peers = TorrentInfo.GetPeers(remoteBook.Release);
|
||||
|
||||
return peers.HasValue && peers.Value > 0 ? Math.Round(Math.Log10(peers.Value)) : 0;
|
||||
}));
|
||||
|
|
@ -136,10 +136,10 @@ private int CompareAgeIfUsenet(DownloadDecision x, DownloadDecision y)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum =>
|
||||
return CompareBy(x.RemoteBook, y.RemoteBook, remoteBook =>
|
||||
{
|
||||
var ageHours = remoteAlbum.Release.AgeHours;
|
||||
var age = remoteAlbum.Release.Age;
|
||||
var ageHours = remoteBook.Release.AgeHours;
|
||||
var age = remoteBook.Release.Age;
|
||||
|
||||
if (ageHours < 1)
|
||||
{
|
||||
|
|
@ -163,7 +163,7 @@ private int CompareAgeIfUsenet(DownloadDecision x, DownloadDecision y)
|
|||
private int CompareSize(DownloadDecision x, DownloadDecision y)
|
||||
{
|
||||
// TODO: Is smaller better? Smaller for usenet could mean no par2 files.
|
||||
return CompareBy(x.RemoteBook, y.RemoteBook, remoteAlbum => remoteAlbum.Release.Size.Round(200.Megabytes()));
|
||||
return CompareBy(x.RemoteBook, y.RemoteBook, remoteBook => remoteBook.Release.Size.Round(200.Megabytes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ public class DownloadDecisionMaker : IMakeDownloadDecision
|
|||
{
|
||||
private readonly IEnumerable<IDecisionEngineSpecification> _specifications;
|
||||
private readonly IParsingService _parsingService;
|
||||
private readonly IRemoteAlbumAggregationService _aggregationService;
|
||||
private readonly IRemoteBookAggregationService _aggregationService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DownloadDecisionMaker(IEnumerable<IDecisionEngineSpecification> specifications,
|
||||
IParsingService parsingService,
|
||||
IRemoteAlbumAggregationService aggregationService,
|
||||
IRemoteBookAggregationService aggregationService,
|
||||
Logger logger)
|
||||
{
|
||||
_specifications = specifications;
|
||||
|
|
@ -39,15 +39,15 @@ public DownloadDecisionMaker(IEnumerable<IDecisionEngineSpecification> specifica
|
|||
|
||||
public List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports)
|
||||
{
|
||||
return GetAlbumDecisions(reports).ToList();
|
||||
return GetBookDecisions(reports).ToList();
|
||||
}
|
||||
|
||||
public List<DownloadDecision> GetSearchDecision(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteriaBase)
|
||||
{
|
||||
return GetAlbumDecisions(reports, searchCriteriaBase).ToList();
|
||||
return GetBookDecisions(reports, searchCriteriaBase).ToList();
|
||||
}
|
||||
|
||||
private IEnumerable<DownloadDecision> GetAlbumDecisions(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteria = null)
|
||||
private IEnumerable<DownloadDecision> GetBookDecisions(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
if (reports.Any())
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ private IEnumerable<DownloadDecision> GetAlbumDecisions(List<ReleaseInfo> report
|
|||
{
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
parsedBookInfo = Parser.Parser.ParseAlbumTitleWithSearchCriteria(report.Title,
|
||||
parsedBookInfo = Parser.Parser.ParseBookTitleWithSearchCriteria(report.Title,
|
||||
searchCriteria.Author,
|
||||
searchCriteria.Books);
|
||||
}
|
||||
|
|
@ -95,13 +95,13 @@ private IEnumerable<DownloadDecision> GetAlbumDecisions(List<ReleaseInfo> report
|
|||
if ((remoteBook.Author == null || remoteBook.Books.Empty()) && searchCriteria != null)
|
||||
{
|
||||
_logger.Debug("Author/Book null for {0}, reparsing with search criteria", report.Title);
|
||||
var parsedAlbumInfoWithCriteria = Parser.Parser.ParseAlbumTitleWithSearchCriteria(report.Title,
|
||||
var parsedBookInfoWithCriteria = Parser.Parser.ParseBookTitleWithSearchCriteria(report.Title,
|
||||
searchCriteria.Author,
|
||||
searchCriteria.Books);
|
||||
|
||||
if (parsedAlbumInfoWithCriteria != null && parsedAlbumInfoWithCriteria.AuthorName.IsNotNullOrWhiteSpace())
|
||||
if (parsedBookInfoWithCriteria != null && parsedBookInfoWithCriteria.AuthorName.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
remoteBook = _parsingService.Map(parsedAlbumInfoWithCriteria, searchCriteria);
|
||||
remoteBook = _parsingService.Map(parsedBookInfoWithCriteria, searchCriteria);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCrite
|
|||
|
||||
foreach (var queueItem in matchingAlbum)
|
||||
{
|
||||
var remoteAlbum = queueItem.RemoteBook;
|
||||
var remoteBook = queueItem.RemoteBook;
|
||||
var qualityProfile = subject.Author.QualityProfile.Value;
|
||||
|
||||
// To avoid a race make sure it's not FailedPending (failed awaiting removal/search).
|
||||
|
|
@ -52,34 +52,34 @@ public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCrite
|
|||
continue;
|
||||
}
|
||||
|
||||
_logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteAlbum.ParsedBookInfo.Quality);
|
||||
_logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteBook.ParsedBookInfo.Quality);
|
||||
|
||||
var queuedItemPreferredWordScore = _preferredWordServiceCalculator.Calculate(subject.Author, queueItem.Title);
|
||||
|
||||
if (!_upgradableSpecification.CutoffNotMet(qualityProfile,
|
||||
new List<QualityModel> { remoteAlbum.ParsedBookInfo.Quality },
|
||||
new List<QualityModel> { remoteBook.ParsedBookInfo.Quality },
|
||||
queuedItemPreferredWordScore,
|
||||
subject.ParsedBookInfo.Quality,
|
||||
subject.PreferredWordScore))
|
||||
{
|
||||
return Decision.Reject("Release in queue already meets cutoff: {0}", remoteAlbum.ParsedBookInfo.Quality);
|
||||
return Decision.Reject("Release in queue already meets cutoff: {0}", remoteBook.ParsedBookInfo.Quality);
|
||||
}
|
||||
|
||||
_logger.Debug("Checking if release is higher quality than queued release. Queued: {0}", remoteAlbum.ParsedBookInfo.Quality);
|
||||
_logger.Debug("Checking if release is higher quality than queued release. Queued: {0}", remoteBook.ParsedBookInfo.Quality);
|
||||
|
||||
if (!_upgradableSpecification.IsUpgradable(qualityProfile,
|
||||
new List<QualityModel> { remoteAlbum.ParsedBookInfo.Quality },
|
||||
new List<QualityModel> { remoteBook.ParsedBookInfo.Quality },
|
||||
queuedItemPreferredWordScore,
|
||||
subject.ParsedBookInfo.Quality,
|
||||
subject.PreferredWordScore))
|
||||
{
|
||||
return Decision.Reject("Release in queue is of equal or higher preference: {0}", remoteAlbum.ParsedBookInfo.Quality);
|
||||
return Decision.Reject("Release in queue is of equal or higher preference: {0}", remoteBook.ParsedBookInfo.Quality);
|
||||
}
|
||||
|
||||
_logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteAlbum.ParsedBookInfo.Quality);
|
||||
_logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteBook.ParsedBookInfo.Quality);
|
||||
|
||||
if (!_upgradableSpecification.IsUpgradeAllowed(qualityProfile,
|
||||
new List<QualityModel> { remoteAlbum.ParsedBookInfo.Quality },
|
||||
new List<QualityModel> { remoteBook.ParsedBookInfo.Quality },
|
||||
subject.ParsedBookInfo.Quality))
|
||||
{
|
||||
return Decision.Reject("Another release is queued and the Quality profile does not allow upgrades");
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
|
||||
{
|
||||
public class MonitoredAlbumSpecification : IDecisionEngineSpecification
|
||||
public class MonitoredBookSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public MonitoredAlbumSpecification(Logger logger)
|
||||
public MonitoredBookSpecification(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
|
@ -42,20 +42,20 @@ public virtual Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase sea
|
|||
|
||||
if (subject.Books.Count == 1)
|
||||
{
|
||||
_logger.Debug("Album is not monitored. Rejecting", monitoredCount, subject.Books.Count);
|
||||
return Decision.Reject("Album is not monitored");
|
||||
_logger.Debug("Book is not monitored. Rejecting", monitoredCount, subject.Books.Count);
|
||||
return Decision.Reject("Book is not monitored");
|
||||
}
|
||||
|
||||
if (monitoredCount == 0)
|
||||
{
|
||||
_logger.Debug("No albums in the release are monitored. Rejecting", monitoredCount, subject.Books.Count);
|
||||
_logger.Debug("No books in the release are monitored. Rejecting", monitoredCount, subject.Books.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug("Only {0}/{1} albums in the release are monitored. Rejecting", monitoredCount, subject.Books.Count);
|
||||
_logger.Debug("Only {0}/{1} books in the release are monitored. Rejecting", monitoredCount, subject.Books.Count);
|
||||
}
|
||||
|
||||
return Decision.Reject("Album is not monitored");
|
||||
return Decision.Reject("Book is not monitored");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ public AuthorSpecification(Logger logger)
|
|||
public SpecificationPriority Priority => SpecificationPriority.Default;
|
||||
public RejectionType Type => RejectionType.Permanent;
|
||||
|
||||
public Decision IsSatisfiedBy(RemoteBook remoteAlbum, SearchCriteriaBase searchCriteria)
|
||||
public Decision IsSatisfiedBy(RemoteBook remoteBook, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
if (searchCriteria == null)
|
||||
{
|
||||
|
|
@ -25,9 +25,9 @@ public Decision IsSatisfiedBy(RemoteBook remoteAlbum, SearchCriteriaBase searchC
|
|||
|
||||
_logger.Debug("Checking if author matches searched author");
|
||||
|
||||
if (remoteAlbum.Author.Id != searchCriteria.Author.Id)
|
||||
if (remoteBook.Author.Id != searchCriteria.Author.Id)
|
||||
{
|
||||
_logger.Debug("Author {0} does not match {1}", remoteAlbum.Author, searchCriteria.Author);
|
||||
_logger.Debug("Author {0} does not match {1}", remoteBook.Author, searchCriteria.Author);
|
||||
return Decision.Reject("Wrong author");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
||||
{
|
||||
public class AlbumRequestedSpecification : IDecisionEngineSpecification
|
||||
public class BookRequestedSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public AlbumRequestedSpecification(Logger logger)
|
||||
public BookRequestedSpecification(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
|
@ -17,20 +17,20 @@ public AlbumRequestedSpecification(Logger logger)
|
|||
public SpecificationPriority Priority => SpecificationPriority.Default;
|
||||
public RejectionType Type => RejectionType.Permanent;
|
||||
|
||||
public Decision IsSatisfiedBy(RemoteBook remoteAlbum, SearchCriteriaBase searchCriteria)
|
||||
public Decision IsSatisfiedBy(RemoteBook remoteBook, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
if (searchCriteria == null)
|
||||
{
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
var criteriaAlbum = searchCriteria.Books.Select(v => v.Id).ToList();
|
||||
var remoteAlbums = remoteAlbum.Books.Select(v => v.Id).ToList();
|
||||
var criteriaBook = searchCriteria.Books.Select(v => v.Id).ToList();
|
||||
var remoteBooks = remoteBook.Books.Select(v => v.Id).ToList();
|
||||
|
||||
if (!criteriaAlbum.Intersect(remoteAlbums).Any())
|
||||
if (!criteriaBook.Intersect(remoteBooks).Any())
|
||||
{
|
||||
_logger.Debug("Release rejected since the book wasn't requested: {0}", remoteAlbum.ParsedBookInfo);
|
||||
return Decision.Reject("Album wasn't requested");
|
||||
_logger.Debug("Release rejected since the book wasn't requested: {0}", remoteBook.ParsedBookInfo);
|
||||
return Decision.Reject("Book wasn't requested");
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
|
|
@ -20,9 +20,9 @@ public TorrentSeedingSpecification(IIndexerFactory indexerFactory, Logger logger
|
|||
public SpecificationPriority Priority => SpecificationPriority.Default;
|
||||
public RejectionType Type => RejectionType.Permanent;
|
||||
|
||||
public Decision IsSatisfiedBy(RemoteBook remoteAlbum, SearchCriteriaBase searchCriteria)
|
||||
public Decision IsSatisfiedBy(RemoteBook remoteBook, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
var torrentInfo = remoteAlbum.Release as TorrentInfo;
|
||||
var torrentInfo = remoteBook.Release as TorrentInfo;
|
||||
|
||||
if (torrentInfo == null || torrentInfo.IndexerId == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace NzbDrone.Core.Download.Aggregation.Aggregators
|
||||
{
|
||||
public class AggregatePreferredWordScore : IAggregateRemoteAlbum
|
||||
public class AggregatePreferredWordScore : IAggregateRemoteBook
|
||||
{
|
||||
private readonly IPreferredWordService _preferredWordServiceCalculator;
|
||||
|
||||
|
|
@ -12,11 +12,11 @@ public AggregatePreferredWordScore(IPreferredWordService preferredWordServiceCal
|
|||
_preferredWordServiceCalculator = preferredWordServiceCalculator;
|
||||
}
|
||||
|
||||
public RemoteBook Aggregate(RemoteBook remoteAlbum)
|
||||
public RemoteBook Aggregate(RemoteBook remoteBook)
|
||||
{
|
||||
remoteAlbum.PreferredWordScore = _preferredWordServiceCalculator.Calculate(remoteAlbum.Author, remoteAlbum.Release.Title);
|
||||
remoteBook.PreferredWordScore = _preferredWordServiceCalculator.Calculate(remoteBook.Author, remoteBook.Release.Title);
|
||||
|
||||
return remoteAlbum;
|
||||
return remoteBook;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace NzbDrone.Core.Download.Aggregation.Aggregators
|
||||
{
|
||||
public interface IAggregateRemoteAlbum
|
||||
public interface IAggregateRemoteBook
|
||||
{
|
||||
RemoteBook Aggregate(RemoteBook remoteAlbum);
|
||||
RemoteBook Aggregate(RemoteBook remoteBook);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,30 +6,30 @@
|
|||
|
||||
namespace NzbDrone.Core.Download.Aggregation
|
||||
{
|
||||
public interface IRemoteAlbumAggregationService
|
||||
public interface IRemoteBookAggregationService
|
||||
{
|
||||
RemoteBook Augment(RemoteBook remoteAlbum);
|
||||
RemoteBook Augment(RemoteBook remoteBook);
|
||||
}
|
||||
|
||||
public class RemoteAlbumAggregationService : IRemoteAlbumAggregationService
|
||||
public class RemoteBookAggregationService : IRemoteBookAggregationService
|
||||
{
|
||||
private readonly IEnumerable<IAggregateRemoteAlbum> _augmenters;
|
||||
private readonly IEnumerable<IAggregateRemoteBook> _augmenters;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public RemoteAlbumAggregationService(IEnumerable<IAggregateRemoteAlbum> augmenters,
|
||||
public RemoteBookAggregationService(IEnumerable<IAggregateRemoteBook> augmenters,
|
||||
Logger logger)
|
||||
{
|
||||
_augmenters = augmenters;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public RemoteBook Augment(RemoteBook remoteAlbum)
|
||||
public RemoteBook Augment(RemoteBook remoteBook)
|
||||
{
|
||||
foreach (var augmenter in _augmenters)
|
||||
{
|
||||
try
|
||||
{
|
||||
augmenter.Aggregate(remoteAlbum);
|
||||
augmenter.Aggregate(remoteBook);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -37,7 +37,7 @@ public RemoteBook Augment(RemoteBook remoteAlbum)
|
|||
}
|
||||
}
|
||||
|
||||
return remoteAlbum;
|
||||
return remoteBook;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -37,14 +37,14 @@ public TorrentBlackhole(IScanWatchFolder scanWatchFolder,
|
|||
ScanGracePeriod = TimeSpan.FromSeconds(30);
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
if (!Settings.SaveMagnetFiles)
|
||||
{
|
||||
throw new NotSupportedException("Blackhole does not support magnet links.");
|
||||
}
|
||||
|
||||
var title = remoteAlbum.Release.Title;
|
||||
var title = remoteBook.Release.Title;
|
||||
|
||||
title = FileNameBuilder.CleanFileName(title);
|
||||
|
||||
|
|
@ -61,9 +61,9 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
return null;
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
var title = remoteAlbum.Release.Title;
|
||||
var title = remoteBook.Release.Title;
|
||||
|
||||
title = FileNameBuilder.CleanFileName(title);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ public UsenetBlackhole(IScanWatchFolder scanWatchFolder,
|
|||
ScanGracePeriod = TimeSpan.FromSeconds(30);
|
||||
}
|
||||
|
||||
protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent)
|
||||
protected override string AddFromNzbFile(RemoteBook remoteBook, string filename, byte[] fileContent)
|
||||
{
|
||||
var title = remoteAlbum.Release.Title;
|
||||
var title = remoteBook.Release.Title;
|
||||
|
||||
title = FileNameBuilder.CleanFileName(title);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public override void MarkItemAsImported(DownloadClientItem downloadClientItem)
|
|||
}
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
var actualHash = _proxy.AddTorrentFromMagnet(magnetLink, Settings);
|
||||
|
||||
|
|
@ -59,17 +59,17 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
throw new DownloadClientException("Deluge failed to add magnet " + magnetLink);
|
||||
}
|
||||
|
||||
_proxy.SetTorrentSeedingConfiguration(actualHash, remoteAlbum.SeedConfiguration, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(actualHash, remoteBook.SeedConfiguration, Settings);
|
||||
|
||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
_proxy.SetTorrentLabel(actualHash, Settings.MusicCategory, Settings);
|
||||
}
|
||||
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)DelugePriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)DelugePriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)DelugePriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)DelugePriority.First))
|
||||
{
|
||||
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
return actualHash.ToUpper();
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
var actualHash = _proxy.AddTorrentFromFile(filename, fileContent, Settings);
|
||||
|
||||
|
|
@ -86,17 +86,17 @@ protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash
|
|||
throw new DownloadClientException("Deluge failed to add torrent " + filename);
|
||||
}
|
||||
|
||||
_proxy.SetTorrentSeedingConfiguration(actualHash, remoteAlbum.SeedConfiguration, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(actualHash, remoteBook.SeedConfiguration, Settings);
|
||||
|
||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
_proxy.SetTorrentLabel(actualHash, Settings.MusicCategory, Settings);
|
||||
}
|
||||
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)DelugePriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)DelugePriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)DelugePriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)DelugePriority.First))
|
||||
{
|
||||
_proxy.MoveTorrentToTopInQueue(actualHash, Settings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ protected OsPath GetOutputPath(OsPath outputPath, DownloadStationTask torrent, s
|
|||
return finalPath;
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
|
||||
if (item != null)
|
||||
{
|
||||
_logger.Debug("{0} added correctly", remoteAlbum);
|
||||
_logger.Debug("{0} added correctly", remoteBook);
|
||||
return CreateDownloadId(item.Id, hashedSerialNumber);
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
throw new DownloadClientException("Failed to add magnet task to Download Station");
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash
|
|||
|
||||
if (item != null)
|
||||
{
|
||||
_logger.Debug("{0} added correctly", remoteAlbum);
|
||||
_logger.Debug("{0} added correctly", remoteBook);
|
||||
return CreateDownloadId(item.Id, hashedSerialNumber);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ public override void RemoveItem(string downloadId, bool deleteData)
|
|||
_logger.Debug("{0} removed correctly", downloadId);
|
||||
}
|
||||
|
||||
protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent)
|
||||
protected override string AddFromNzbFile(RemoteBook remoteBook, string filename, byte[] fileContent)
|
||||
{
|
||||
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename
|
|||
|
||||
if (item != null)
|
||||
{
|
||||
_logger.Debug("{0} added correctly", remoteAlbum);
|
||||
_logger.Debug("{0} added correctly", remoteBook);
|
||||
return CreateDownloadId(item.Id, hashedSerialNumber);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,14 +137,14 @@ protected override void Test(List<ValidationFailure> failures)
|
|||
failures.AddIfNotNull(TestGetTorrents());
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
_proxy.AddTorrentUri(Settings, magnetLink);
|
||||
|
||||
return hash.ToUpper();
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
return _proxy.AddTorrentFile(Settings, fileContent).ToUpper();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ public NzbVortex(INzbVortexProxy proxy,
|
|||
_proxy = proxy;
|
||||
}
|
||||
|
||||
protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent)
|
||||
protected override string AddFromNzbFile(RemoteBook remoteBook, string filename, byte[] fileContent)
|
||||
{
|
||||
var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority;
|
||||
var priority = remoteBook.IsRecentBook() ? Settings.RecentTvPriority : Settings.OlderTvPriority;
|
||||
|
||||
var response = _proxy.DownloadNzb(fileContent, filename, priority, Settings);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,17 +34,17 @@ public Nzbget(INzbgetProxy proxy,
|
|||
_proxy = proxy;
|
||||
}
|
||||
|
||||
protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent)
|
||||
protected override string AddFromNzbFile(RemoteBook remoteBook, string filename, byte[] fileContent)
|
||||
{
|
||||
var category = Settings.MusicCategory;
|
||||
var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority;
|
||||
var priority = remoteBook.IsRecentBook() ? Settings.RecentTvPriority : Settings.OlderTvPriority;
|
||||
|
||||
var addpaused = Settings.AddPaused;
|
||||
var response = _proxy.DownloadNzb(fileContent, filename, category, priority, addpaused, Settings);
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
throw new DownloadClientRejectedReleaseException(remoteAlbum.Release, "NZBGet rejected the NZB for an unknown reason");
|
||||
throw new DownloadClientRejectedReleaseException(remoteBook.Release, "NZBGet rejected the NZB for an unknown reason");
|
||||
}
|
||||
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ public Pneumatic(IHttpClient httpClient,
|
|||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
|
||||
|
||||
public override string Download(RemoteBook remoteAlbum)
|
||||
public override string Download(RemoteBook remoteBook)
|
||||
{
|
||||
var url = remoteAlbum.Release.DownloadUrl;
|
||||
var title = remoteAlbum.Release.Title;
|
||||
var url = remoteBook.Release.DownloadUrl;
|
||||
var title = remoteBook.Release.Title;
|
||||
|
||||
if (remoteAlbum.ParsedBookInfo.Discography)
|
||||
if (remoteBook.ParsedBookInfo.Discography)
|
||||
{
|
||||
throw new NotSupportedException("Discography releases are not supported with Pneumatic.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public override void MarkItemAsImported(DownloadClientItem downloadClientItem)
|
|||
}
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
if (!Proxy.GetConfig(Settings).DhtEnabled && !magnetLink.Contains("&tr="))
|
||||
{
|
||||
|
|
@ -71,34 +71,34 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
|
||||
Proxy.AddTorrentFromUrl(magnetLink, Settings);
|
||||
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)QBittorrentPriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)QBittorrentPriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)QBittorrentPriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)QBittorrentPriority.First))
|
||||
{
|
||||
Proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings);
|
||||
}
|
||||
|
||||
SetInitialState(hash.ToLower());
|
||||
|
||||
if (remoteAlbum.SeedConfiguration != null && (remoteAlbum.SeedConfiguration.Ratio.HasValue || remoteAlbum.SeedConfiguration.SeedTime.HasValue))
|
||||
if (remoteBook.SeedConfiguration != null && (remoteBook.SeedConfiguration.Ratio.HasValue || remoteBook.SeedConfiguration.SeedTime.HasValue))
|
||||
{
|
||||
Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteAlbum.SeedConfiguration, Settings);
|
||||
Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteBook.SeedConfiguration, Settings);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
Proxy.AddTorrentFromFile(filename, fileContent, Settings);
|
||||
|
||||
try
|
||||
{
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)QBittorrentPriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)QBittorrentPriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)QBittorrentPriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)QBittorrentPriority.First))
|
||||
{
|
||||
Proxy.MoveTorrentToTopInQueue(hash.ToLower(), Settings);
|
||||
}
|
||||
|
|
@ -110,9 +110,9 @@ protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash
|
|||
|
||||
SetInitialState(hash.ToLower());
|
||||
|
||||
if (remoteAlbum.SeedConfiguration != null && (remoteAlbum.SeedConfiguration.Ratio.HasValue || remoteAlbum.SeedConfiguration.SeedTime.HasValue))
|
||||
if (remoteBook.SeedConfiguration != null && (remoteBook.SeedConfiguration.Ratio.HasValue || remoteBook.SeedConfiguration.SeedTime.HasValue))
|
||||
{
|
||||
Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteAlbum.SeedConfiguration, Settings);
|
||||
Proxy.SetTorrentSeedingConfiguration(hash.ToLower(), remoteBook.SeedConfiguration, Settings);
|
||||
}
|
||||
|
||||
return hash;
|
||||
|
|
|
|||
|
|
@ -34,16 +34,16 @@ public Sabnzbd(ISabnzbdProxy proxy,
|
|||
// patch can be a number (releases) or 'x' (git)
|
||||
private static readonly Regex VersionRegex = new Regex(@"(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+|x)", RegexOptions.Compiled);
|
||||
|
||||
protected override string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent)
|
||||
protected override string AddFromNzbFile(RemoteBook remoteBook, string filename, byte[] fileContent)
|
||||
{
|
||||
var category = Settings.MusicCategory;
|
||||
var priority = remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority;
|
||||
var priority = remoteBook.IsRecentBook() ? Settings.RecentTvPriority : Settings.OlderTvPriority;
|
||||
|
||||
var response = _proxy.DownloadNzb(fileContent, filename, category, priority, Settings);
|
||||
|
||||
if (response == null || response.Ids.Empty())
|
||||
{
|
||||
throw new DownloadClientRejectedReleaseException(remoteAlbum.Release, "SABnzbd rejected the NZB for an unknown reason");
|
||||
throw new DownloadClientRejectedReleaseException(remoteBook.Release, "SABnzbd rejected the NZB for an unknown reason");
|
||||
}
|
||||
|
||||
return response.Ids.First();
|
||||
|
|
|
|||
|
|
@ -179,15 +179,15 @@ public override DownloadClientInfo GetStatus()
|
|||
};
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
_proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteBook.SeedConfiguration, Settings);
|
||||
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)TransmissionPriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)TransmissionPriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)TransmissionPriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)TransmissionPriority.First))
|
||||
{
|
||||
_proxy.MoveTorrentToTopInQueue(hash, Settings);
|
||||
}
|
||||
|
|
@ -195,15 +195,15 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
return hash;
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
_proxy.AddTorrentFromData(fileContent, GetDownloadDirectory(), Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteBook.SeedConfiguration, Settings);
|
||||
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)TransmissionPriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)TransmissionPriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)TransmissionPriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)TransmissionPriority.First))
|
||||
{
|
||||
_proxy.MoveTorrentToTopInQueue(hash, Settings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ public override void MarkItemAsImported(DownloadClientItem downloadClientItem)
|
|||
}
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
var priority = (RTorrentPriority)(remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority);
|
||||
var priority = (RTorrentPriority)(remoteBook.IsRecentBook() ? Settings.RecentTvPriority : Settings.OlderTvPriority);
|
||||
|
||||
_proxy.AddTorrentFromUrl(magnetLink, Settings.MusicCategory, priority, Settings.MusicDirectory, Settings);
|
||||
|
||||
|
|
@ -77,9 +77,9 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
return hash;
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
var priority = (RTorrentPriority)(remoteAlbum.IsRecentAlbum() ? Settings.RecentTvPriority : Settings.OlderTvPriority);
|
||||
var priority = (RTorrentPriority)(remoteBook.IsRecentBook() ? Settings.RecentTvPriority : Settings.OlderTvPriority);
|
||||
|
||||
_proxy.AddTorrentFromFile(filename, fileContent, Settings.MusicCategory, priority, Settings.MusicDirectory, Settings);
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash
|
|||
{
|
||||
_logger.Debug("rTorrent didn't add the torrent within {0} seconds: {1}.", tries * retryDelay / 1000, filename);
|
||||
|
||||
throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading torrent failed");
|
||||
throw new ReleaseDownloadException(remoteBook.Release, "Downloading torrent failed");
|
||||
}
|
||||
|
||||
return hash;
|
||||
|
|
|
|||
|
|
@ -52,20 +52,20 @@ public override void MarkItemAsImported(DownloadClientItem downloadClientItem)
|
|||
}
|
||||
}
|
||||
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink)
|
||||
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink)
|
||||
{
|
||||
_proxy.AddTorrentFromUrl(magnetLink, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteBook.SeedConfiguration, Settings);
|
||||
|
||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
_proxy.SetTorrentLabel(hash, Settings.MusicCategory, Settings);
|
||||
}
|
||||
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)UTorrentPriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)UTorrentPriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)UTorrentPriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)UTorrentPriority.First))
|
||||
{
|
||||
_proxy.MoveTorrentToTopInQueue(hash, Settings);
|
||||
}
|
||||
|
|
@ -75,20 +75,20 @@ protected override string AddFromMagnetLink(RemoteBook remoteAlbum, string hash,
|
|||
return hash;
|
||||
}
|
||||
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent)
|
||||
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent)
|
||||
{
|
||||
_proxy.AddTorrentFromFile(filename, fileContent, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteAlbum.SeedConfiguration, Settings);
|
||||
_proxy.SetTorrentSeedingConfiguration(hash, remoteBook.SeedConfiguration, Settings);
|
||||
|
||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
_proxy.SetTorrentLabel(hash, Settings.MusicCategory, Settings);
|
||||
}
|
||||
|
||||
var isRecentAlbum = remoteAlbum.IsRecentAlbum();
|
||||
var isRecentBook = remoteBook.IsRecentBook();
|
||||
|
||||
if ((isRecentAlbum && Settings.RecentTvPriority == (int)UTorrentPriority.First) ||
|
||||
(!isRecentAlbum && Settings.OlderTvPriority == (int)UTorrentPriority.First))
|
||||
if ((isRecentBook && Settings.RecentTvPriority == (int)UTorrentPriority.First) ||
|
||||
(!isRecentBook && Settings.OlderTvPriority == (int)UTorrentPriority.First))
|
||||
{
|
||||
_proxy.MoveTorrentToTopInQueue(hash, Settings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public abstract DownloadProtocol Protocol
|
|||
get;
|
||||
}
|
||||
|
||||
public abstract string Download(RemoteBook remoteAlbum);
|
||||
public abstract string Download(RemoteBook remoteBook);
|
||||
public abstract IEnumerable<DownloadClientItem> GetItems();
|
||||
public abstract void RemoveItem(string downloadId, bool deleteData);
|
||||
public abstract DownloadClientInfo GetStatus();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Download
|
|||
{
|
||||
public interface IDownloadService
|
||||
{
|
||||
void DownloadReport(RemoteBook remoteAlbum);
|
||||
void DownloadReport(RemoteBook remoteBook);
|
||||
}
|
||||
|
||||
public class DownloadService : IDownloadService
|
||||
|
|
@ -45,39 +45,39 @@ public DownloadService(IProvideDownloadClient downloadClientProvider,
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public void DownloadReport(RemoteBook remoteAlbum)
|
||||
public void DownloadReport(RemoteBook remoteBook)
|
||||
{
|
||||
Ensure.That(remoteAlbum.Author, () => remoteAlbum.Author).IsNotNull();
|
||||
Ensure.That(remoteAlbum.Books, () => remoteAlbum.Books).HasItems();
|
||||
Ensure.That(remoteBook.Author, () => remoteBook.Author).IsNotNull();
|
||||
Ensure.That(remoteBook.Books, () => remoteBook.Books).HasItems();
|
||||
|
||||
var downloadTitle = remoteAlbum.Release.Title;
|
||||
var downloadClient = _downloadClientProvider.GetDownloadClient(remoteAlbum.Release.DownloadProtocol);
|
||||
var downloadTitle = remoteBook.Release.Title;
|
||||
var downloadClient = _downloadClientProvider.GetDownloadClient(remoteBook.Release.DownloadProtocol);
|
||||
|
||||
if (downloadClient == null)
|
||||
{
|
||||
throw new DownloadClientUnavailableException($"{remoteAlbum.Release.DownloadProtocol} Download client isn't configured yet");
|
||||
throw new DownloadClientUnavailableException($"{remoteBook.Release.DownloadProtocol} Download client isn't configured yet");
|
||||
}
|
||||
|
||||
// Get the seed configuration for this release.
|
||||
remoteAlbum.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteAlbum);
|
||||
remoteBook.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteBook);
|
||||
|
||||
// Limit grabs to 2 per second.
|
||||
if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteAlbum.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
if (remoteBook.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteBook.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
{
|
||||
var url = new HttpUri(remoteAlbum.Release.DownloadUrl);
|
||||
var url = new HttpUri(remoteBook.Release.DownloadUrl);
|
||||
_rateLimitService.WaitAndPulse(url.Host, TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
||||
string downloadClientId;
|
||||
try
|
||||
{
|
||||
downloadClientId = downloadClient.Download(remoteAlbum);
|
||||
downloadClientId = downloadClient.Download(remoteBook);
|
||||
_downloadClientStatusService.RecordSuccess(downloadClient.Definition.Id);
|
||||
_indexerStatusService.RecordSuccess(remoteAlbum.Release.IndexerId);
|
||||
_indexerStatusService.RecordSuccess(remoteBook.Release.IndexerId);
|
||||
}
|
||||
catch (ReleaseUnavailableException)
|
||||
{
|
||||
_logger.Trace("Release {0} no longer available on indexer.", remoteAlbum);
|
||||
_logger.Trace("Release {0} no longer available on indexer.", remoteBook);
|
||||
throw;
|
||||
}
|
||||
catch (ReleaseDownloadException ex)
|
||||
|
|
@ -85,17 +85,17 @@ public void DownloadReport(RemoteBook remoteAlbum)
|
|||
var http429 = ex.InnerException as TooManyRequestsException;
|
||||
if (http429 != null)
|
||||
{
|
||||
_indexerStatusService.RecordFailure(remoteAlbum.Release.IndexerId, http429.RetryAfter);
|
||||
_indexerStatusService.RecordFailure(remoteBook.Release.IndexerId, http429.RetryAfter);
|
||||
}
|
||||
else
|
||||
{
|
||||
_indexerStatusService.RecordFailure(remoteAlbum.Release.IndexerId);
|
||||
_indexerStatusService.RecordFailure(remoteBook.Release.IndexerId);
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
var albumGrabbedEvent = new BookGrabbedEvent(remoteAlbum);
|
||||
var albumGrabbedEvent = new BookGrabbedEvent(remoteBook);
|
||||
albumGrabbedEvent.DownloadClient = downloadClient.Name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(downloadClientId))
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public interface IDownloadClient : IProvider
|
|||
{
|
||||
DownloadProtocol Protocol { get; }
|
||||
|
||||
string Download(RemoteBook remoteAlbum);
|
||||
string Download(RemoteBook remoteBook);
|
||||
IEnumerable<DownloadClientItem> GetItems();
|
||||
void RemoveItem(string downloadId, bool deleteData);
|
||||
DownloadClientInfo GetStatus();
|
||||
|
|
|
|||
|
|
@ -345,10 +345,10 @@ private static Func<PendingRelease, bool> MatchingReleasePredicate(ReleaseInfo r
|
|||
p.Release.Indexer == release.Indexer;
|
||||
}
|
||||
|
||||
private int GetDelay(RemoteBook remoteAlbum)
|
||||
private int GetDelay(RemoteBook remoteBook)
|
||||
{
|
||||
var delayProfile = _delayProfileService.AllForTags(remoteAlbum.Author.Tags).OrderBy(d => d.Order).First();
|
||||
var delay = delayProfile.GetProtocolDelay(remoteAlbum.Release.DownloadProtocol);
|
||||
var delayProfile = _delayProfileService.AllForTags(remoteBook.Author.Tags).OrderBy(d => d.Order).First();
|
||||
var delay = delayProfile.GetProtocolDelay(remoteBook.Release.DownloadProtocol);
|
||||
var minimumAge = _configService.MinimumAge;
|
||||
|
||||
return new[] { delay, minimumAge }.Max();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public ProcessedDecisions ProcessDecisions(List<DownloadDecision> decisions)
|
|||
|
||||
foreach (var report in prioritizedDecisions)
|
||||
{
|
||||
var remoteAlbum = report.RemoteBook;
|
||||
var remoteBook = report.RemoteBook;
|
||||
var downloadProtocol = report.RemoteBook.Release.DownloadProtocol;
|
||||
|
||||
//Skip if already grabbed
|
||||
|
|
@ -74,19 +74,19 @@ public ProcessedDecisions ProcessDecisions(List<DownloadDecision> decisions)
|
|||
|
||||
try
|
||||
{
|
||||
_downloadService.DownloadReport(remoteAlbum);
|
||||
_downloadService.DownloadReport(remoteBook);
|
||||
grabbed.Add(report);
|
||||
}
|
||||
catch (ReleaseUnavailableException)
|
||||
{
|
||||
_logger.Warn("Failed to download release from indexer, no longer available. " + remoteAlbum);
|
||||
_logger.Warn("Failed to download release from indexer, no longer available. " + remoteBook);
|
||||
rejected.Add(report);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is DownloadClientUnavailableException || ex is DownloadClientAuthenticationException)
|
||||
{
|
||||
_logger.Debug(ex, "Failed to send release to download client, storing until later. " + remoteAlbum);
|
||||
_logger.Debug(ex, "Failed to send release to download client, storing until later. " + remoteBook);
|
||||
PreparePending(pendingAddQueue, grabbed, pending, report, PendingReleaseReason.DownloadClientUnavailable);
|
||||
|
||||
if (downloadProtocol == DownloadProtocol.Usenet)
|
||||
|
|
@ -100,7 +100,7 @@ public ProcessedDecisions ProcessDecisions(List<DownloadDecision> decisions)
|
|||
}
|
||||
else
|
||||
{
|
||||
_logger.Warn(ex, "Couldn't add report to download queue. " + remoteAlbum);
|
||||
_logger.Warn(ex, "Couldn't add report to download queue. " + remoteBook);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,23 +38,23 @@ protected TorrentClientBase(ITorrentFileInfoReader torrentFileInfoReader,
|
|||
|
||||
public virtual bool PreferTorrentFile => false;
|
||||
|
||||
protected abstract string AddFromMagnetLink(RemoteBook remoteAlbum, string hash, string magnetLink);
|
||||
protected abstract string AddFromTorrentFile(RemoteBook remoteAlbum, string hash, string filename, byte[] fileContent);
|
||||
protected abstract string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink);
|
||||
protected abstract string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent);
|
||||
|
||||
public override string Download(RemoteBook remoteAlbum)
|
||||
public override string Download(RemoteBook remoteBook)
|
||||
{
|
||||
var torrentInfo = remoteAlbum.Release as TorrentInfo;
|
||||
var torrentInfo = remoteBook.Release as TorrentInfo;
|
||||
|
||||
string magnetUrl = null;
|
||||
string torrentUrl = null;
|
||||
|
||||
if (remoteAlbum.Release.DownloadUrl.IsNotNullOrWhiteSpace() && remoteAlbum.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
if (remoteBook.Release.DownloadUrl.IsNotNullOrWhiteSpace() && remoteBook.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
{
|
||||
magnetUrl = remoteAlbum.Release.DownloadUrl;
|
||||
magnetUrl = remoteBook.Release.DownloadUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
torrentUrl = remoteAlbum.Release.DownloadUrl;
|
||||
torrentUrl = remoteBook.Release.DownloadUrl;
|
||||
}
|
||||
|
||||
if (torrentInfo != null && !torrentInfo.MagnetUrl.IsNullOrWhiteSpace())
|
||||
|
|
@ -68,7 +68,7 @@ public override string Download(RemoteBook remoteAlbum)
|
|||
{
|
||||
try
|
||||
{
|
||||
return DownloadFromWebUrl(remoteAlbum, torrentUrl);
|
||||
return DownloadFromWebUrl(remoteBook, torrentUrl);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -85,11 +85,11 @@ public override string Download(RemoteBook remoteAlbum)
|
|||
{
|
||||
try
|
||||
{
|
||||
return DownloadFromMagnetUrl(remoteAlbum, magnetUrl);
|
||||
return DownloadFromMagnetUrl(remoteBook, magnetUrl);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
throw new ReleaseDownloadException(remoteAlbum.Release, "Magnet not supported by download client. ({0})", ex.Message);
|
||||
throw new ReleaseDownloadException(remoteBook.Release, "Magnet not supported by download client. ({0})", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,13 +99,13 @@ public override string Download(RemoteBook remoteAlbum)
|
|||
{
|
||||
try
|
||||
{
|
||||
return DownloadFromMagnetUrl(remoteAlbum, magnetUrl);
|
||||
return DownloadFromMagnetUrl(remoteBook, magnetUrl);
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
if (torrentUrl.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new ReleaseDownloadException(remoteAlbum.Release, "Magnet not supported by download client. ({0})", ex.Message);
|
||||
throw new ReleaseDownloadException(remoteBook.Release, "Magnet not supported by download client. ({0})", ex.Message);
|
||||
}
|
||||
|
||||
_logger.Debug("Magnet not supported by download client, trying torrent. ({0})", ex.Message);
|
||||
|
|
@ -114,14 +114,14 @@ public override string Download(RemoteBook remoteAlbum)
|
|||
|
||||
if (torrentUrl.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return DownloadFromWebUrl(remoteAlbum, torrentUrl);
|
||||
return DownloadFromWebUrl(remoteBook, torrentUrl);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string DownloadFromWebUrl(RemoteBook remoteAlbum, string torrentUrl)
|
||||
private string DownloadFromWebUrl(RemoteBook remoteBook, string torrentUrl)
|
||||
{
|
||||
byte[] torrentFile = null;
|
||||
|
||||
|
|
@ -145,10 +145,10 @@ private string DownloadFromWebUrl(RemoteBook remoteAlbum, string torrentUrl)
|
|||
{
|
||||
if (locationHeader.StartsWith("magnet:"))
|
||||
{
|
||||
return DownloadFromMagnetUrl(remoteAlbum, locationHeader);
|
||||
return DownloadFromMagnetUrl(remoteBook, locationHeader);
|
||||
}
|
||||
|
||||
return DownloadFromWebUrl(remoteAlbum, locationHeader);
|
||||
return DownloadFromWebUrl(remoteBook, locationHeader);
|
||||
}
|
||||
|
||||
throw new WebException("Remote website tried to redirect without providing a location.");
|
||||
|
|
@ -156,14 +156,14 @@ private string DownloadFromWebUrl(RemoteBook remoteAlbum, string torrentUrl)
|
|||
|
||||
torrentFile = response.ResponseData;
|
||||
|
||||
_logger.Debug("Downloading torrent for release '{0}' finished ({1} bytes from {2})", remoteAlbum.Release.Title, torrentFile.Length, torrentUrl);
|
||||
_logger.Debug("Downloading torrent for release '{0}' finished ({1} bytes from {2})", remoteBook.Release.Title, torrentFile.Length, torrentUrl);
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
if (ex.Response.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
_logger.Error(ex, "Downloading torrent file for book '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, torrentUrl);
|
||||
throw new ReleaseUnavailableException(remoteAlbum.Release, "Downloading torrent failed", ex);
|
||||
_logger.Error(ex, "Downloading torrent file for book '{0}' failed since it no longer exists ({1})", remoteBook.Release.Title, torrentUrl);
|
||||
throw new ReleaseUnavailableException(remoteBook.Release, "Downloading torrent failed", ex);
|
||||
}
|
||||
|
||||
if ((int)ex.Response.StatusCode == 429)
|
||||
|
|
@ -172,34 +172,34 @@ private string DownloadFromWebUrl(RemoteBook remoteAlbum, string torrentUrl)
|
|||
}
|
||||
else
|
||||
{
|
||||
_logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteAlbum.Release.Title, torrentUrl);
|
||||
_logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteBook.Release.Title, torrentUrl);
|
||||
}
|
||||
|
||||
throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading torrent failed", ex);
|
||||
throw new ReleaseDownloadException(remoteBook.Release, "Downloading torrent failed", ex);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
_logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteAlbum.Release.Title, torrentUrl);
|
||||
_logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteBook.Release.Title, torrentUrl);
|
||||
|
||||
throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading torrent failed", ex);
|
||||
throw new ReleaseDownloadException(remoteBook.Release, "Downloading torrent failed", ex);
|
||||
}
|
||||
|
||||
var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteAlbum.Release.Title));
|
||||
var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteBook.Release.Title));
|
||||
var hash = _torrentFileInfoReader.GetHashFromTorrentFile(torrentFile);
|
||||
var actualHash = AddFromTorrentFile(remoteAlbum, hash, filename, torrentFile);
|
||||
var actualHash = AddFromTorrentFile(remoteBook, hash, filename, torrentFile);
|
||||
|
||||
if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash)
|
||||
{
|
||||
_logger.Debug(
|
||||
"{0} did not return the expected InfoHash for '{1}', Readarr could potentially lose track of the download in progress.",
|
||||
Definition.Implementation,
|
||||
remoteAlbum.Release.DownloadUrl);
|
||||
remoteBook.Release.DownloadUrl);
|
||||
}
|
||||
|
||||
return actualHash;
|
||||
}
|
||||
|
||||
private string DownloadFromMagnetUrl(RemoteBook remoteAlbum, string magnetUrl)
|
||||
private string DownloadFromMagnetUrl(RemoteBook remoteBook, string magnetUrl)
|
||||
{
|
||||
string hash = null;
|
||||
string actualHash = null;
|
||||
|
|
@ -210,14 +210,14 @@ private string DownloadFromMagnetUrl(RemoteBook remoteAlbum, string magnetUrl)
|
|||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
_logger.Error(ex, "Failed to parse magnetlink for release '{0}': '{1}'", remoteAlbum.Release.Title, magnetUrl);
|
||||
_logger.Error(ex, "Failed to parse magnetlink for release '{0}': '{1}'", remoteBook.Release.Title, magnetUrl);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (hash != null)
|
||||
{
|
||||
actualHash = AddFromMagnetLink(remoteAlbum, hash, magnetUrl);
|
||||
actualHash = AddFromMagnetLink(remoteBook, hash, magnetUrl);
|
||||
}
|
||||
|
||||
if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash)
|
||||
|
|
@ -225,7 +225,7 @@ private string DownloadFromMagnetUrl(RemoteBook remoteAlbum, string magnetUrl)
|
|||
_logger.Debug(
|
||||
"{0} did not return the expected InfoHash for '{1}', Readarr could potentially lose track of the download in progress.",
|
||||
Definition.Implementation,
|
||||
remoteAlbum.Release.DownloadUrl);
|
||||
remoteBook.Release.DownloadUrl);
|
||||
}
|
||||
|
||||
return actualHash;
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@ public void UpdateAlbumCache(int bookId)
|
|||
|
||||
foreach (var item in updateCacheItems)
|
||||
{
|
||||
var parsedAlbumInfo = Parser.Parser.ParseBookTitle(item.DownloadItem.Title);
|
||||
var parsedBookInfo = Parser.Parser.ParseBookTitle(item.DownloadItem.Title);
|
||||
item.RemoteBook = null;
|
||||
|
||||
if (parsedAlbumInfo != null)
|
||||
if (parsedBookInfo != null)
|
||||
{
|
||||
item.RemoteBook = _parsingService.Map(parsedAlbumInfo);
|
||||
item.RemoteBook = _parsingService.Map(parsedBookInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do
|
|||
else
|
||||
{
|
||||
parsedBookInfo =
|
||||
Parser.Parser.ParseAlbumTitleWithSearchCriteria(firstHistoryItem.SourceTitle,
|
||||
Parser.Parser.ParseBookTitleWithSearchCriteria(firstHistoryItem.SourceTitle,
|
||||
historyAuthor,
|
||||
historyBooks);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ protected UsenetClientBase(IHttpClient httpClient,
|
|||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
|
||||
|
||||
protected abstract string AddFromNzbFile(RemoteBook remoteAlbum, string filename, byte[] fileContent);
|
||||
protected abstract string AddFromNzbFile(RemoteBook remoteBook, string filename, byte[] fileContent);
|
||||
|
||||
public override string Download(RemoteBook remoteAlbum)
|
||||
public override string Download(RemoteBook remoteBook)
|
||||
{
|
||||
var url = remoteAlbum.Release.DownloadUrl;
|
||||
var filename = FileNameBuilder.CleanFileName(remoteAlbum.Release.Title) + ".nzb";
|
||||
var url = remoteBook.Release.DownloadUrl;
|
||||
var filename = FileNameBuilder.CleanFileName(remoteBook.Release.Title) + ".nzb";
|
||||
|
||||
byte[] nzbData;
|
||||
|
||||
|
|
@ -47,21 +47,21 @@ public override string Download(RemoteBook remoteAlbum)
|
|||
var nzbDataRequest = new HttpRequest(url);
|
||||
|
||||
// TODO: Look into moving download request handling to indexer
|
||||
if (remoteAlbum.Release.BasicAuthString.IsNotNullOrWhiteSpace())
|
||||
if (remoteBook.Release.BasicAuthString.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
nzbDataRequest.Headers.Set("Authorization", "Basic " + remoteAlbum.Release.BasicAuthString);
|
||||
nzbDataRequest.Headers.Set("Authorization", "Basic " + remoteBook.Release.BasicAuthString);
|
||||
}
|
||||
|
||||
nzbData = _httpClient.Get(nzbDataRequest).ResponseData;
|
||||
|
||||
_logger.Debug("Downloaded nzb for release '{0}' finished ({1} bytes from {2})", remoteAlbum.Release.Title, nzbData.Length, url);
|
||||
_logger.Debug("Downloaded nzb for release '{0}' finished ({1} bytes from {2})", remoteBook.Release.Title, nzbData.Length, url);
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
if (ex.Response.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
_logger.Error(ex, "Downloading nzb file for book '{0}' failed since it no longer exists ({1})", remoteAlbum.Release.Title, url);
|
||||
throw new ReleaseUnavailableException(remoteAlbum.Release, "Downloading torrent failed", ex);
|
||||
_logger.Error(ex, "Downloading nzb file for book '{0}' failed since it no longer exists ({1})", remoteBook.Release.Title, url);
|
||||
throw new ReleaseUnavailableException(remoteBook.Release, "Downloading torrent failed", ex);
|
||||
}
|
||||
|
||||
if ((int)ex.Response.StatusCode == 429)
|
||||
|
|
@ -70,22 +70,22 @@ public override string Download(RemoteBook remoteAlbum)
|
|||
}
|
||||
else
|
||||
{
|
||||
_logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteAlbum.Release.Title, url);
|
||||
_logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteBook.Release.Title, url);
|
||||
}
|
||||
|
||||
throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading nzb failed", ex);
|
||||
throw new ReleaseDownloadException(remoteBook.Release, "Downloading nzb failed", ex);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
_logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteAlbum.Release.Title, url);
|
||||
_logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteBook.Release.Title, url);
|
||||
|
||||
throw new ReleaseDownloadException(remoteAlbum.Release, "Downloading nzb failed", ex);
|
||||
throw new ReleaseDownloadException(remoteBook.Release, "Downloading nzb failed", ex);
|
||||
}
|
||||
|
||||
_nzbValidationService.Validate(filename, nzbData);
|
||||
|
||||
_logger.Info("Adding report [{0}] to the queue.", remoteAlbum.Release.Title);
|
||||
return AddFromNzbFile(remoteAlbum, filename, nzbData);
|
||||
_logger.Info("Adding report [{0}] to the queue.", remoteBook.Release.Title);
|
||||
return AddFromNzbFile(remoteBook, filename, nzbData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ private void CreateAfterImport(Author author, BookFile bookFile)
|
|||
{
|
||||
foreach (var extraFileManager in _extraFileManagers)
|
||||
{
|
||||
extraFileManager.CreateAfterTrackImport(author, bookFile);
|
||||
extraFileManager.CreateAfterBookImport(author, bookFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public interface IManageExtraFiles
|
|||
{
|
||||
int Order { get; }
|
||||
IEnumerable<ExtraFile> CreateAfterAuthorScan(Author author, List<BookFile> bookFiles);
|
||||
IEnumerable<ExtraFile> CreateAfterTrackImport(Author author, BookFile bookFile);
|
||||
IEnumerable<ExtraFile> CreateAfterBookImport(Author author, BookFile bookFile);
|
||||
IEnumerable<ExtraFile> CreateAfterBookImport(Author author, Book book, string authorFolder, string bookFolder);
|
||||
IEnumerable<ExtraFile> MoveFilesAfterRename(Author author, List<BookFile> bookFiles);
|
||||
ExtraFile Import(Author author, BookFile bookFile, string path, string extension, bool readOnly);
|
||||
|
|
@ -42,7 +42,7 @@ public ExtraFileManager(IConfigService configService,
|
|||
|
||||
public abstract int Order { get; }
|
||||
public abstract IEnumerable<ExtraFile> CreateAfterAuthorScan(Author author, List<BookFile> bookFiles);
|
||||
public abstract IEnumerable<ExtraFile> CreateAfterTrackImport(Author author, BookFile bookFile);
|
||||
public abstract IEnumerable<ExtraFile> CreateAfterBookImport(Author author, BookFile bookFile);
|
||||
public abstract IEnumerable<ExtraFile> CreateAfterBookImport(Author author, Book book, string authorFolder, string albumFolder);
|
||||
public abstract IEnumerable<ExtraFile> MoveFilesAfterRename(Author author, List<BookFile> bookFiles);
|
||||
public abstract ExtraFile Import(Author author, BookFile bookFile, string path, string extension, bool readOnly);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ namespace NzbDrone.Core.Extras.Files
|
|||
public interface IExtraFileService<TExtraFile>
|
||||
where TExtraFile : ExtraFile, new()
|
||||
{
|
||||
List<TExtraFile> GetFilesByArtist(int authorId);
|
||||
List<TExtraFile> GetFilesByTrackFile(int trackFileId);
|
||||
List<TExtraFile> GetFilesByAuthor(int authorId);
|
||||
List<TExtraFile> GetFilesByBookFile(int bookFileId);
|
||||
TExtraFile FindByPath(string path);
|
||||
void Upsert(TExtraFile extraFile);
|
||||
void Upsert(List<TExtraFile> extraFiles);
|
||||
|
|
@ -49,14 +49,14 @@ public ExtraFileService(IExtraFileRepository<TExtraFile> repository,
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public List<TExtraFile> GetFilesByArtist(int authorId)
|
||||
public List<TExtraFile> GetFilesByAuthor(int authorId)
|
||||
{
|
||||
return _repository.GetFilesByAuthor(authorId);
|
||||
}
|
||||
|
||||
public List<TExtraFile> GetFilesByTrackFile(int trackFileId)
|
||||
public List<TExtraFile> GetFilesByBookFile(int bookFileId)
|
||||
{
|
||||
return _repository.GetFilesByBookFile(trackFileId);
|
||||
return _repository.GetFilesByBookFile(bookFileId);
|
||||
}
|
||||
|
||||
public TExtraFile FindByPath(string path)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public ImportExistingExtraFilesBase(IExtraFileService<TExtraFile> extraFileServi
|
|||
|
||||
public virtual ImportExistingExtraFileFilterResult<TExtraFile> FilterAndClean(Author author, List<string> filesOnDisk, List<string> importedFiles)
|
||||
{
|
||||
var authorFiles = _extraFileService.GetFilesByArtist(author.Id);
|
||||
var authorFiles = _extraFileService.GetFilesByAuthor(author.Id);
|
||||
|
||||
Clean(author, filesOnDisk, importedFiles, authorFiles);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,20 +54,20 @@ public override IEnumerable<ExtraFile> ProcessFiles(Author author, List<string>
|
|||
continue;
|
||||
}
|
||||
|
||||
if (metadata.Type == MetadataType.AlbumImage || metadata.Type == MetadataType.AlbumMetadata)
|
||||
if (metadata.Type == MetadataType.BookImage || metadata.Type == MetadataType.BookMetadata)
|
||||
{
|
||||
var localAlbum = _parsingService.GetLocalAlbum(possibleMetadataFile, author);
|
||||
|
||||
if (localAlbum == null)
|
||||
{
|
||||
_logger.Debug("Extra file folder has multiple Albums: {0}", possibleMetadataFile);
|
||||
_logger.Debug("Extra file folder has multiple Books: {0}", possibleMetadataFile);
|
||||
continue;
|
||||
}
|
||||
|
||||
metadata.BookId = localAlbum.Id;
|
||||
}
|
||||
|
||||
if (metadata.Type == MetadataType.TrackMetadata)
|
||||
if (metadata.Type == MetadataType.BookMetadata)
|
||||
{
|
||||
var localTrack = new LocalBook
|
||||
{
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue