diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 5c17b6b09..1e6c86abf 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -117,45 +117,43 @@ public List GetPendingRemoteMovies(int movieId) foreach (var pendingRelease in GetPendingReleases()) { - //foreach (var episode in pendingRelease.RemoteEpisode.Episodes) - //{ - var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteMovie)); + var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteMovie)); - if (ect < nextRssSync.Value) - { - ect = nextRssSync.Value; - } - else - { - ect = ect.AddMinutes(_configService.RssSyncInterval); - } + if (ect < nextRssSync.Value) + { + ect = nextRssSync.Value; + } + else + { + ect = ect.AddMinutes(_configService.RssSyncInterval); + } - var queue = new Queue.Queue - { - Id = GetQueueId(pendingRelease, pendingRelease.RemoteMovie.Movie), - Series = null, - Episode = null, - Movie = pendingRelease.RemoteMovie.Movie, - Quality = pendingRelease.RemoteMovie.ParsedMovieInfo.Quality, - Title = pendingRelease.Title, - Size = pendingRelease.RemoteMovie.Release.Size, - Sizeleft = pendingRelease.RemoteMovie.Release.Size, - RemoteMovie = pendingRelease.RemoteMovie, - Timeleft = ect.Subtract(DateTime.UtcNow), - EstimatedCompletionTime = ect, - Status = "Pending", - Protocol = pendingRelease.RemoteMovie.Release.DownloadProtocol - }; - queued.Add(queue); - //} + var queue = new Queue.Queue + { + Id = GetQueueId(pendingRelease, pendingRelease.RemoteMovie.Movie), + Series = null, + Episode = null, + Movie = pendingRelease.RemoteMovie.Movie, + Quality = pendingRelease.RemoteMovie.ParsedMovieInfo?.Quality ?? new QualityModel(), + Title = pendingRelease.Title, + Size = pendingRelease.RemoteMovie.Release.Size, + Sizeleft = pendingRelease.RemoteMovie.Release.Size, + RemoteMovie = pendingRelease.RemoteMovie, + Timeleft = ect.Subtract(DateTime.UtcNow), + EstimatedCompletionTime = ect, + Status = "Pending", + Protocol = pendingRelease.RemoteMovie.Release.DownloadProtocol + }; + + queued.Add(queue); } //Return best quality release for each episode - var deduped = queued.GroupBy(q => q.Episode.Id).Select(g => + var deduped = queued.GroupBy(q => q.Movie.Id).Select(g => { - var series = g.First().Series; + var movies = g.First().Movie; - return g.OrderByDescending(e => e.Quality, new QualityModelComparer(series.Profile)) + return g.OrderByDescending(e => e.Quality, new QualityModelComparer(movies.Profile)) .ThenBy(q => PrioritizeDownloadProtocol(q.Movie, q.Protocol)) .First(); }); @@ -254,12 +252,12 @@ private int GetDelay(RemoteMovie remoteMovie) return new[] { delay, minimumAge }.Max(); } - private void RemoveGrabbed(RemoteMovie remoteEpisode) + private void RemoveGrabbed(RemoteMovie remoteMovie) { var pendingReleases = GetPendingReleases(); - var existingReports = pendingReleases.Where(r => r.RemoteMovie.Movie.Id == remoteEpisode.Movie.Id) + var existingReports = pendingReleases.Where(r => r.RemoteMovie.Movie.Id == remoteMovie.Movie.Id) .ToList(); if (existingReports.Empty()) @@ -267,11 +265,11 @@ private void RemoveGrabbed(RemoteMovie remoteEpisode) return; } - var profile = remoteEpisode.Movie.Profile.Value; + var profile = remoteMovie.Movie.Profile.Value; foreach (var existingReport in existingReports) { - var compare = new QualityModelComparer(profile).Compare(remoteEpisode.ParsedMovieInfo.Quality, + var compare = new QualityModelComparer(profile).Compare(remoteMovie.ParsedMovieInfo.Quality, existingReport.RemoteMovie.ParsedMovieInfo.Quality); //Only remove lower/equal quality pending releases