Fixed: Allow downloading any search result (#525)

* Allow downloading any search result

Ones that couldn't be parsed get a red icon

* Not required - initialized to false

* Add a warning the the queue page for manual downloads
This commit is contained in:
ta264 2018-11-11 05:38:38 +00:00 committed by Qstick
commit c98b86b413
12 changed files with 62 additions and 17 deletions

View file

@ -46,7 +46,6 @@ namespace Lidarr.Api.V1.Indexers
GetResourceAll = GetReleases;
Post["/"] = x => DownloadRelease(this.Bind<ReleaseResource>());
PostValidator.RuleFor(s => s.DownloadAllowed).Equal(true);
PostValidator.RuleFor(s => s.IndexerId).ValidId();
PostValidator.RuleFor(s => s.Guid).NotEmpty();

View file

@ -30,6 +30,7 @@ namespace Lidarr.Api.V1.Queue
public DownloadProtocol Protocol { get; set; }
public string DownloadClient { get; set; }
public string Indexer { get; set; }
public bool DownloadForced { get; set; }
}
public static class QueueResourceMapper
@ -58,7 +59,8 @@ namespace Lidarr.Api.V1.Queue
DownloadId = model.DownloadId,
Protocol = model.Protocol,
DownloadClient = model.DownloadClient,
Indexer = model.Indexer
Indexer = model.Indexer,
DownloadForced = model.DownloadForced
};
}

View file

@ -62,6 +62,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Cutoff = Language.Spanish
}).Build();
remoteAlbum.DownloadAllowed = true;
return remoteAlbum;
}

View file

@ -94,10 +94,20 @@ namespace NzbDrone.Core.DecisionEngine
if (remoteAlbum.Artist == null)
{
decision = new DownloadDecision(remoteAlbum, new Rejection("Unknown Artist"));
// shove in the searched artist in case of forced download in interactive search
if (searchCriteria != null)
{
remoteAlbum.Artist = searchCriteria.Artist;
remoteAlbum.Albums = searchCriteria.Albums;
}
}
else if (remoteAlbum.Albums.Empty())
{
decision = new DownloadDecision(remoteAlbum, new Rejection("Unable to parse albums from release name"));
if (searchCriteria != null)
{
remoteAlbum.Albums = searchCriteria.Albums;
}
}
else
{

View file

@ -21,13 +21,13 @@ namespace NzbDrone.Core.DecisionEngine
public List<DownloadDecision> PrioritizeDecisions(List<DownloadDecision> decisions)
{
return decisions.Where(c => c.RemoteAlbum.Artist != null)
return decisions.Where(c => c.RemoteAlbum.DownloadAllowed)
.GroupBy(c => c.RemoteAlbum.Artist.Id, (artistId, downloadDecisions) =>
{
return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_delayProfileService));
})
.SelectMany(c => c)
.Union(decisions.Where(c => c.RemoteAlbum.Artist == null))
.Union(decisions.Where(c => !c.RemoteAlbum.DownloadAllowed))
.ToList();
}
}

View file

@ -162,6 +162,7 @@ namespace NzbDrone.Core.History
history.Data.Add("DownloadUrl", message.Album.Release.DownloadUrl);
history.Data.Add("Guid", message.Album.Release.Guid);
history.Data.Add("Protocol", ((int)message.Album.Release.DownloadProtocol).ToString());
history.Data.Add("DownloadForced", (!message.Album.DownloadAllowed).ToString());
if (!message.Album.ParsedAlbumInfo.ReleaseHash.IsNullOrWhiteSpace())
{

View file

@ -28,5 +28,6 @@ namespace NzbDrone.Core.Queue
public string DownloadClient { get; set; }
public string Indexer { get; set; }
public string ErrorMessage { get; set; }
public bool DownloadForced { get; set; }
}
}

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Crypto;
using NzbDrone.Core.Download.TrackedDownloads;
using NzbDrone.Core.History;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Music;
@ -19,10 +20,13 @@ namespace NzbDrone.Core.Queue
{
private readonly IEventAggregator _eventAggregator;
private static List<Queue> _queue = new List<Queue>();
private readonly IHistoryService _historyService;
public QueueService(IEventAggregator eventAggregator)
public QueueService(IEventAggregator eventAggregator,
IHistoryService historyService)
{
_eventAggregator = eventAggregator;
_historyService = historyService;
}
public List<Queue> GetQueue()
@ -65,6 +69,13 @@ namespace NzbDrone.Core.Queue
private Queue MapAlbum(TrackedDownload trackedDownload, Album album)
{
bool downloadForced = false;
var history = _historyService.Find(trackedDownload.DownloadItem.DownloadId, HistoryEventType.Grabbed).FirstOrDefault();
if (history != null && history.Data.ContainsKey("downloadForced"))
{
downloadForced = bool.Parse(history.Data["downloadForced"]);
}
var queue = new Queue
{
Id = HashConverter.GetHashInt31(string.Format("trackedDownload-{0}-album{1}", trackedDownload.DownloadItem.DownloadId, album.Id)),
@ -83,7 +94,8 @@ namespace NzbDrone.Core.Queue
DownloadId = trackedDownload.DownloadItem.DownloadId,
Protocol = trackedDownload.Protocol,
DownloadClient = trackedDownload.DownloadItem.DownloadClient,
Indexer = trackedDownload.Indexer
Indexer = trackedDownload.Indexer,
DownloadForced = downloadForced
};
if (queue.Timeleft.HasValue)