|
|
@ -4,24 +4,24 @@ using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.IndexerSearch;
|
|
|
|
using NzbDrone.Core.IndexerSearch;
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
using NzbDrone.Core.Music;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Download
|
|
|
|
namespace NzbDrone.Core.Download
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class RedownloadFailedDownloadService : IHandleAsync<DownloadFailedEvent>
|
|
|
|
public class RedownloadFailedDownloadService : IHandleAsync<DownloadFailedEvent>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
private readonly IEpisodeService _episodeService;
|
|
|
|
private readonly IAlbumService _albumService;
|
|
|
|
private readonly IManageCommandQueue _commandQueueManager;
|
|
|
|
private readonly IManageCommandQueue _commandQueueManager;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
|
|
public RedownloadFailedDownloadService(IConfigService configService,
|
|
|
|
public RedownloadFailedDownloadService(IConfigService configService,
|
|
|
|
IEpisodeService episodeService,
|
|
|
|
IAlbumService albumService,
|
|
|
|
IManageCommandQueue commandQueueManager,
|
|
|
|
IManageCommandQueue commandQueueManager,
|
|
|
|
Logger logger)
|
|
|
|
Logger logger)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_configService = configService;
|
|
|
|
_configService = configService;
|
|
|
|
_episodeService = episodeService;
|
|
|
|
_albumService = albumService;
|
|
|
|
_commandQueueManager = commandQueueManager;
|
|
|
|
_commandQueueManager = commandQueueManager;
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -30,38 +30,36 @@ namespace NzbDrone.Core.Download
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!_configService.AutoRedownloadFailed)
|
|
|
|
if (!_configService.AutoRedownloadFailed)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Debug("Auto redownloading failed episodes is disabled");
|
|
|
|
_logger.Debug("Auto redownloading failed albums is disabled");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (message.EpisodeIds.Count == 1)
|
|
|
|
if (message.AlbumIds.Count == 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Debug("Failed download only contains one episode, searching again");
|
|
|
|
_logger.Debug("Failed download only contains one album, searching again");
|
|
|
|
|
|
|
|
|
|
|
|
_commandQueueManager.Push(new EpisodeSearchCommand(message.EpisodeIds));
|
|
|
|
_commandQueueManager.Push(new AlbumSearchCommand(message.AlbumIds));
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var seasonNumber = _episodeService.GetEpisode(message.EpisodeIds.First()).SeasonNumber;
|
|
|
|
var albumsInArtist = _albumService.GetAlbumsByArtist(message.ArtistId);
|
|
|
|
var episodesInSeason = _episodeService.GetEpisodesBySeason(message.SeriesId, seasonNumber);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (message.EpisodeIds.Count == episodesInSeason.Count)
|
|
|
|
if (message.AlbumIds.Count == albumsInArtist.Count)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Debug("Failed download was entire season, searching again");
|
|
|
|
_logger.Debug("Failed download was entire artist, searching again");
|
|
|
|
|
|
|
|
|
|
|
|
_commandQueueManager.Push(new SeasonSearchCommand
|
|
|
|
_commandQueueManager.Push(new ArtistSearchCommand
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SeriesId = message.SeriesId,
|
|
|
|
ArtistId = message.ArtistId
|
|
|
|
SeasonNumber = seasonNumber
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Failed download contains multiple episodes, probably a double episode, searching again");
|
|
|
|
_logger.Debug("Failed download contains multiple albums, searching again");
|
|
|
|
|
|
|
|
|
|
|
|
_commandQueueManager.Push(new EpisodeSearchCommand(message.EpisodeIds));
|
|
|
|
_commandQueueManager.Push(new AlbumSearchCommand(message.AlbumIds));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|