1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-01-01 04:45:35 +00:00

Fix pending release service, also fix the deduper

This commit is contained in:
Devin Buhl 2017-03-17 20:24:03 -04:00
parent b02b066257
commit b137fc075a

View file

@ -117,45 +117,43 @@ public List<RemoteMovie> 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