mirror of https://github.com/lidarr/Lidarr
parent
a728f44a1e
commit
4c2f17f1cf
|
@ -37,7 +37,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||||
|
|
||||||
results.Should().NotBeEmpty();
|
results.Should().NotBeEmpty();
|
||||||
Mocker.GetMock<IMakeDownloadDecision>()
|
Mocker.GetMock<IMakeDownloadDecision>()
|
||||||
.Verify(v => v.GetRssDecision(It.Is<List<ReleaseInfo>>(d => d.Count == 0)), Times.Never());
|
.Verify(v => v.GetRssDecision(It.Is<List<ReleaseInfo>>(d => d.Count == 0), It.IsAny<bool>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace NzbDrone.Core.DecisionEngine
|
||||||
{
|
{
|
||||||
public interface IMakeDownloadDecision
|
public interface IMakeDownloadDecision
|
||||||
{
|
{
|
||||||
List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports);
|
List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports, bool pushedRelease = false);
|
||||||
List<DownloadDecision> GetSearchDecision(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteriaBase);
|
List<DownloadDecision> GetSearchDecision(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteriaBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,17 +41,17 @@ namespace NzbDrone.Core.DecisionEngine
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports)
|
public List<DownloadDecision> GetRssDecision(List<ReleaseInfo> reports, bool pushedRelease = false)
|
||||||
{
|
{
|
||||||
return GetAlbumDecisions(reports).ToList();
|
return GetAlbumDecisions(reports).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DownloadDecision> GetSearchDecision(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteriaBase)
|
public List<DownloadDecision> GetSearchDecision(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteriaBase)
|
||||||
{
|
{
|
||||||
return GetAlbumDecisions(reports, searchCriteriaBase).ToList();
|
return GetAlbumDecisions(reports, false, searchCriteriaBase).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<DownloadDecision> GetAlbumDecisions(List<ReleaseInfo> reports, SearchCriteriaBase searchCriteria = null)
|
private IEnumerable<DownloadDecision> GetAlbumDecisions(List<ReleaseInfo> reports, bool pushedRelease = false, SearchCriteriaBase searchCriteria = null)
|
||||||
{
|
{
|
||||||
if (reports.Any())
|
if (reports.Any())
|
||||||
{
|
{
|
||||||
|
@ -169,6 +169,26 @@ namespace NzbDrone.Core.DecisionEngine
|
||||||
|
|
||||||
if (decision != null)
|
if (decision != null)
|
||||||
{
|
{
|
||||||
|
var source = pushedRelease ? ReleaseSourceType.ReleasePush : ReleaseSourceType.Rss;
|
||||||
|
|
||||||
|
if (searchCriteria != null)
|
||||||
|
{
|
||||||
|
if (searchCriteria.InteractiveSearch)
|
||||||
|
{
|
||||||
|
source = ReleaseSourceType.InteractiveSearch;
|
||||||
|
}
|
||||||
|
else if (searchCriteria.UserInvokedSearch)
|
||||||
|
{
|
||||||
|
source = ReleaseSourceType.UserInvokedSearch;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
source = ReleaseSourceType.Search;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
decision.RemoteAlbum.ReleaseSource = source;
|
||||||
|
|
||||||
if (decision.Rejections.Any())
|
if (decision.Rejections.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug("Release rejected for the following reasons: {0}", string.Join(", ", decision.Rejections));
|
_logger.Debug("Release rejected for the following reasons: {0}", string.Join(", ", decision.Rejections));
|
||||||
|
|
|
@ -12,8 +12,14 @@ namespace NzbDrone.Core.Download.Pending
|
||||||
public ParsedAlbumInfo ParsedAlbumInfo { get; set; }
|
public ParsedAlbumInfo ParsedAlbumInfo { get; set; }
|
||||||
public ReleaseInfo Release { get; set; }
|
public ReleaseInfo Release { get; set; }
|
||||||
public PendingReleaseReason Reason { get; set; }
|
public PendingReleaseReason Reason { get; set; }
|
||||||
|
public PendingReleaseAdditionalInfo AdditionalInfo { get; set; }
|
||||||
|
|
||||||
// Not persisted
|
// Not persisted
|
||||||
public RemoteAlbum RemoteAlbum { get; set; }
|
public RemoteAlbum RemoteAlbum { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PendingReleaseAdditionalInfo
|
||||||
|
{
|
||||||
|
public ReleaseSourceType ReleaseSource { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,6 +320,7 @@ namespace NzbDrone.Core.Download.Pending
|
||||||
{
|
{
|
||||||
Artist = artist,
|
Artist = artist,
|
||||||
Albums = albums,
|
Albums = albums,
|
||||||
|
ReleaseSource = release.AdditionalInfo?.ReleaseSource ?? ReleaseSourceType.Unknown,
|
||||||
ParsedAlbumInfo = release.ParsedAlbumInfo,
|
ParsedAlbumInfo = release.ParsedAlbumInfo,
|
||||||
Release = release.Release
|
Release = release.Release
|
||||||
};
|
};
|
||||||
|
@ -342,7 +343,11 @@ namespace NzbDrone.Core.Download.Pending
|
||||||
Release = decision.RemoteAlbum.Release,
|
Release = decision.RemoteAlbum.Release,
|
||||||
Title = decision.RemoteAlbum.Release.Title,
|
Title = decision.RemoteAlbum.Release.Title,
|
||||||
Added = DateTime.UtcNow,
|
Added = DateTime.UtcNow,
|
||||||
Reason = reason
|
Reason = reason,
|
||||||
|
AdditionalInfo = new PendingReleaseAdditionalInfo
|
||||||
|
{
|
||||||
|
ReleaseSource = decision.RemoteAlbum.ReleaseSource
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_eventAggregator.PublishEvent(new PendingReleasesUpdatedEvent());
|
_eventAggregator.PublishEvent(new PendingReleasesUpdatedEvent());
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace NzbDrone.Core.History
|
||||||
public class EntityHistory : ModelBase
|
public class EntityHistory : ModelBase
|
||||||
{
|
{
|
||||||
public const string DOWNLOAD_CLIENT = "downloadClient";
|
public const string DOWNLOAD_CLIENT = "downloadClient";
|
||||||
|
public const string RELEASE_SOURCE = "releaseSource";
|
||||||
|
|
||||||
public EntityHistory()
|
public EntityHistory()
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,15 +165,14 @@ namespace NzbDrone.Core.History
|
||||||
history.Data.Add("Protocol", ((int)message.Album.Release.DownloadProtocol).ToString());
|
history.Data.Add("Protocol", ((int)message.Album.Release.DownloadProtocol).ToString());
|
||||||
history.Data.Add("DownloadForced", (!message.Album.DownloadAllowed).ToString());
|
history.Data.Add("DownloadForced", (!message.Album.DownloadAllowed).ToString());
|
||||||
history.Data.Add("CustomFormatScore", message.Album.CustomFormatScore.ToString());
|
history.Data.Add("CustomFormatScore", message.Album.CustomFormatScore.ToString());
|
||||||
|
history.Data.Add("ReleaseSource", message.Album.ReleaseSource.ToString());
|
||||||
|
|
||||||
if (!message.Album.ParsedAlbumInfo.ReleaseHash.IsNullOrWhiteSpace())
|
if (!message.Album.ParsedAlbumInfo.ReleaseHash.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
history.Data.Add("ReleaseHash", message.Album.ParsedAlbumInfo.ReleaseHash);
|
history.Data.Add("ReleaseHash", message.Album.ParsedAlbumInfo.ReleaseHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
var torrentRelease = message.Album.Release as TorrentInfo;
|
if (message.Album.Release is TorrentInfo torrentRelease)
|
||||||
|
|
||||||
if (torrentRelease != null)
|
|
||||||
{
|
{
|
||||||
history.Data.Add("TorrentInfoHash", torrentRelease.InfoHash);
|
history.Data.Add("TorrentInfoHash", torrentRelease.InfoHash);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace NzbDrone.Core.Parser.Model
|
||||||
public TorrentSeedConfiguration SeedConfiguration { get; set; }
|
public TorrentSeedConfiguration SeedConfiguration { get; set; }
|
||||||
public List<CustomFormat> CustomFormats { get; set; }
|
public List<CustomFormat> CustomFormats { get; set; }
|
||||||
public int CustomFormatScore { get; set; }
|
public int CustomFormatScore { get; set; }
|
||||||
|
public ReleaseSourceType ReleaseSource { get; set; }
|
||||||
|
|
||||||
public RemoteAlbum()
|
public RemoteAlbum()
|
||||||
{
|
{
|
||||||
|
@ -34,4 +35,14 @@ namespace NzbDrone.Core.Parser.Model
|
||||||
return Release.Title;
|
return Release.Title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ReleaseSourceType
|
||||||
|
{
|
||||||
|
Unknown = 0,
|
||||||
|
Rss = 1,
|
||||||
|
Search = 2,
|
||||||
|
UserInvokedSearch = 3,
|
||||||
|
InteractiveSearch = 4,
|
||||||
|
ReleasePush = 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue