mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
Blacklisting will trigger episode search
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.IndexerSearch;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public interface IRedownloadFailedDownloads
|
||||
{
|
||||
void Redownload(int seriesId, List<int> episodeIds);
|
||||
}
|
||||
|
||||
public class RedownloadFailedDownloadService : IRedownloadFailedDownloads
|
||||
{
|
||||
private readonly IEpisodeService _episodeService;
|
||||
private readonly ICommandExecutor _commandExecutor;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public RedownloadFailedDownloadService(IEpisodeService episodeService, ICommandExecutor commandExecutor, Logger logger)
|
||||
{
|
||||
_episodeService = episodeService;
|
||||
_commandExecutor = commandExecutor;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Redownload(int seriesId, List<int> episodeIds)
|
||||
{
|
||||
if (episodeIds.Count == 1)
|
||||
{
|
||||
_logger.Trace("Failed download only contains one episode, searching again");
|
||||
|
||||
_commandExecutor.PublishCommandAsync(new EpisodeSearchCommand
|
||||
{
|
||||
EpisodeIds = episodeIds.ToList()
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var seasonNumber = _episodeService.GetEpisode(episodeIds.First()).SeasonNumber;
|
||||
var episodesInSeason = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber);
|
||||
|
||||
if (episodeIds.Count == episodesInSeason.Count)
|
||||
{
|
||||
_logger.Trace("Failed download was entire season, searching again");
|
||||
|
||||
_commandExecutor.PublishCommandAsync(new SeasonSearchCommand
|
||||
{
|
||||
SeriesId = seriesId,
|
||||
SeasonNumber = seasonNumber
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Trace("Failed download contains multiple episodes, probably a double episode, searching again");
|
||||
|
||||
_commandExecutor.PublishCommandAsync(new EpisodeSearchCommand
|
||||
{
|
||||
EpisodeIds = episodeIds.ToList()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user