New: Show error message for pending queue items without episodes

Closes #5541
pull/5547/head
Mark McDowall 2 years ago
parent 48a82ad711
commit 5ca868b4b2

@ -164,50 +164,25 @@ namespace NzbDrone.Core.Download.Pending
foreach (var pendingRelease in pendingReleases)
{
foreach (var episode in pendingRelease.RemoteEpisode.Episodes)
if (pendingRelease.RemoteEpisode.Episodes.Empty())
{
var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteEpisode));
var noEpisodeItem = GetQueueItem(pendingRelease, nextRssSync, null);
if (ect < nextRssSync.Value)
{
ect = nextRssSync.Value;
}
else
{
ect = ect.AddMinutes(_configService.RssSyncInterval);
}
noEpisodeItem.ErrorMessage = "Unable to find matching episode(s)";
var timeleft = ect.Subtract(DateTime.UtcNow);
queued.Add(noEpisodeItem);
if (timeleft.TotalSeconds < 0)
{
timeleft = TimeSpan.Zero;
}
continue;
}
var queue = new Queue.Queue
{
Id = GetQueueId(pendingRelease, episode),
Series = pendingRelease.RemoteEpisode.Series,
Episode = episode,
Languages = pendingRelease.RemoteEpisode.Languages,
Quality = pendingRelease.RemoteEpisode.ParsedEpisodeInfo.Quality,
Title = pendingRelease.Title,
Size = pendingRelease.RemoteEpisode.Release.Size,
Sizeleft = pendingRelease.RemoteEpisode.Release.Size,
RemoteEpisode = pendingRelease.RemoteEpisode,
Timeleft = timeleft,
EstimatedCompletionTime = ect,
Status = pendingRelease.Reason.ToString(),
Protocol = pendingRelease.RemoteEpisode.Release.DownloadProtocol,
Indexer = pendingRelease.RemoteEpisode.Release.Indexer
};
queued.Add(queue);
foreach (var episode in pendingRelease.RemoteEpisode.Episodes)
{
queued.Add(GetQueueItem(pendingRelease, nextRssSync, episode));
}
}
// Return best quality release for each episode
var deduped = queued.GroupBy(q => q.Episode.Id).Select(g =>
var deduped = queued.Where(q => q.Episode != null).GroupBy(q => q.Episode.Id).Select(g =>
{
var series = g.First().Series;
@ -323,10 +298,20 @@ namespace NzbDrone.Core.Download.Pending
}
else if (ValidateParsedEpisodeInfo.ValidateForSeriesType(release.ParsedEpisodeInfo, series))
{
var remoteEpisode = _parsingService.Map(release.ParsedEpisodeInfo, series);
try
{
var remoteEpisode = _parsingService.Map(release.ParsedEpisodeInfo, series);
release.RemoteEpisode.MappedSeasonNumber = remoteEpisode.MappedSeasonNumber;
release.RemoteEpisode.Episodes = remoteEpisode.Episodes;
release.RemoteEpisode.MappedSeasonNumber = remoteEpisode.MappedSeasonNumber;
release.RemoteEpisode.Episodes = remoteEpisode.Episodes;
}
catch (InvalidOperationException ex)
{
_logger.Debug(ex, ex.Message);
release.RemoteEpisode.MappedSeasonNumber = release.ParsedEpisodeInfo.SeasonNumber;
release.RemoteEpisode.Episodes = new List<Episode>();
}
}
else
{
@ -343,6 +328,47 @@ namespace NzbDrone.Core.Download.Pending
return result;
}
private Queue.Queue GetQueueItem(PendingRelease pendingRelease, Lazy<DateTime> nextRssSync, Episode episode)
{
var ect = pendingRelease.Release.PublishDate.AddMinutes(GetDelay(pendingRelease.RemoteEpisode));
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;
}
var queue = new Queue.Queue
{
Id = GetQueueId(pendingRelease, episode),
Series = pendingRelease.RemoteEpisode.Series,
Episode = episode,
Languages = pendingRelease.RemoteEpisode.Languages,
Quality = pendingRelease.RemoteEpisode.ParsedEpisodeInfo.Quality,
Title = pendingRelease.Title,
Size = pendingRelease.RemoteEpisode.Release.Size,
Sizeleft = pendingRelease.RemoteEpisode.Release.Size,
RemoteEpisode = pendingRelease.RemoteEpisode,
Timeleft = timeleft,
EstimatedCompletionTime = ect,
Status = pendingRelease.Reason.ToString(),
Protocol = pendingRelease.RemoteEpisode.Release.DownloadProtocol,
Indexer = pendingRelease.RemoteEpisode.Release.Indexer
};
return queue;
}
private void Insert(DownloadDecision decision, PendingReleaseReason reason)
{
_repository.Insert(new PendingRelease
@ -433,7 +459,7 @@ namespace NzbDrone.Core.Download.Pending
private int GetQueueId(PendingRelease pendingRelease, Episode episode)
{
return HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", pendingRelease.Id, episode.Id));
return HashConverter.GetHashInt31(string.Format("pending-{0}-ep{1}", pendingRelease.Id, episode?.Id ?? 0));
}
private int PrioritizeDownloadProtocol(Series series, DownloadProtocol downloadProtocol)

Loading…
Cancel
Save