mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-19 17:32:38 +01:00
New: Show error message for pending queue items without movies
(cherry picked from commit 5ca868b4b2d34ba65ba3d40144ed889ccf55343d) Closes #8320
This commit is contained in:
parent
2d05708fa9
commit
b3517c14de
@ -184,61 +184,22 @@ public List<RemoteMovie> GetPendingRemoteMovies(int movieId)
|
||||
|
||||
foreach (var pendingRelease in pendingReleases)
|
||||
{
|
||||
if (pendingRelease.RemoteMovie != null)
|
||||
if (pendingRelease.RemoteMovie.Movie == null)
|
||||
{
|
||||
var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteMovie));
|
||||
var noMovieItem = GetQueueItem(pendingRelease, nextRssSync, null);
|
||||
|
||||
if (ect < nextRssSync.Value)
|
||||
{
|
||||
ect = nextRssSync.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ect = ect.AddMinutes(_configService.RssSyncInterval);
|
||||
}
|
||||
noMovieItem.ErrorMessage = "Unable to find matching movie(s)";
|
||||
|
||||
var timeleft = ect.Subtract(DateTime.UtcNow);
|
||||
queued.Add(noMovieItem);
|
||||
|
||||
if (timeleft.TotalSeconds < 0)
|
||||
{
|
||||
timeleft = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
string downloadClientName = null;
|
||||
var indexer = _indexerFactory.Find(pendingRelease.Release.IndexerId);
|
||||
|
||||
if (indexer is { DownloadClientId: > 0 })
|
||||
{
|
||||
var downloadClient = _downloadClientFactory.Find(indexer.DownloadClientId);
|
||||
|
||||
downloadClientName = downloadClient?.Name;
|
||||
}
|
||||
|
||||
var queue = new Queue.Queue
|
||||
{
|
||||
Id = GetQueueId(pendingRelease, pendingRelease.RemoteMovie.Movie),
|
||||
Movie = pendingRelease.RemoteMovie.Movie,
|
||||
Quality = pendingRelease.RemoteMovie.ParsedMovieInfo?.Quality ?? new QualityModel(),
|
||||
Languages = pendingRelease.RemoteMovie.Languages,
|
||||
Title = pendingRelease.Title,
|
||||
Size = pendingRelease.RemoteMovie.Release.Size,
|
||||
Sizeleft = pendingRelease.RemoteMovie.Release.Size,
|
||||
RemoteMovie = pendingRelease.RemoteMovie,
|
||||
Timeleft = timeleft,
|
||||
EstimatedCompletionTime = ect,
|
||||
Added = pendingRelease.Added,
|
||||
Status = pendingRelease.Reason.ToString(),
|
||||
Protocol = pendingRelease.RemoteMovie.Release.DownloadProtocol,
|
||||
Indexer = pendingRelease.RemoteMovie.Release.Indexer,
|
||||
DownloadClient = downloadClientName
|
||||
};
|
||||
|
||||
queued.Add(queue);
|
||||
continue;
|
||||
}
|
||||
|
||||
queued.Add(GetQueueItem(pendingRelease, nextRssSync, pendingRelease.RemoteMovie.Movie));
|
||||
}
|
||||
|
||||
// Return best quality release for each movie
|
||||
var deduped = queued.GroupBy(q => q.Movie.Id).Select(g =>
|
||||
var deduped = queued.Where(q => q.Movie != null).GroupBy(q => q.Movie.Id).Select(g =>
|
||||
{
|
||||
var movies = g.First().Movie;
|
||||
|
||||
@ -309,7 +270,7 @@ private List<PendingRelease> IncludeRemoteMovies(List<PendingRelease> releases,
|
||||
{
|
||||
var movie = movieMap.GetValueOrDefault(release.MovieId);
|
||||
|
||||
// Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up)
|
||||
// Just in case the movie was removed, but wasn't cleaned up yet (housekeeper will clean it up)
|
||||
if (movie == null)
|
||||
{
|
||||
return null;
|
||||
@ -339,6 +300,58 @@ private List<PendingRelease> IncludeRemoteMovies(List<PendingRelease> releases,
|
||||
return result;
|
||||
}
|
||||
|
||||
private Queue.Queue GetQueueItem(PendingRelease pendingRelease, Lazy<DateTime> nextRssSync, Movie movie)
|
||||
{
|
||||
var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteMovie));
|
||||
|
||||
if (ect < nextRssSync.Value)
|
||||
{
|
||||
ect = nextRssSync.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ect = ect.AddMinutes(_configService.RssSyncInterval);
|
||||
}
|
||||
|
||||
var timeleft = ect.Subtract(DateTime.UtcNow);
|
||||
|
||||
if (timeleft.TotalSeconds < 0)
|
||||
{
|
||||
timeleft = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
string downloadClientName = null;
|
||||
var indexer = _indexerFactory.Find(pendingRelease.Release.IndexerId);
|
||||
|
||||
if (indexer is { DownloadClientId: > 0 })
|
||||
{
|
||||
var downloadClient = _downloadClientFactory.Find(indexer.DownloadClientId);
|
||||
|
||||
downloadClientName = downloadClient?.Name;
|
||||
}
|
||||
|
||||
var queue = new Queue.Queue
|
||||
{
|
||||
Id = GetQueueId(pendingRelease, movie),
|
||||
Movie = movie,
|
||||
Quality = pendingRelease.RemoteMovie.ParsedMovieInfo?.Quality ?? new QualityModel(),
|
||||
Languages = pendingRelease.RemoteMovie.Languages,
|
||||
Title = pendingRelease.Title,
|
||||
Size = pendingRelease.RemoteMovie.Release.Size,
|
||||
Sizeleft = pendingRelease.RemoteMovie.Release.Size,
|
||||
RemoteMovie = pendingRelease.RemoteMovie,
|
||||
Timeleft = timeleft,
|
||||
EstimatedCompletionTime = ect,
|
||||
Added = pendingRelease.Added,
|
||||
Status = pendingRelease.Reason.ToString(),
|
||||
Protocol = pendingRelease.RemoteMovie.Release.DownloadProtocol,
|
||||
Indexer = pendingRelease.RemoteMovie.Release.Indexer,
|
||||
DownloadClient = downloadClientName
|
||||
};
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
private void Insert(DownloadDecision decision, PendingReleaseReason reason)
|
||||
{
|
||||
var release = new PendingRelease
|
||||
@ -441,7 +454,7 @@ private PendingRelease FindPendingRelease(int queueId)
|
||||
|
||||
private int GetQueueId(PendingRelease pendingRelease, Movie movie)
|
||||
{
|
||||
return HashConverter.GetHashInt31(string.Format("pending-{0}-movie{1}", pendingRelease.Id, movie.Id));
|
||||
return HashConverter.GetHashInt31(string.Format("pending-{0}-movie{1}", pendingRelease.Id, movie?.Id ?? 0));
|
||||
}
|
||||
|
||||
private int PrioritizeDownloadProtocol(Movie movie, DownloadProtocol downloadProtocol)
|
||||
|
Loading…
Reference in New Issue
Block a user