2014-12-19 00:26:42 +00:00
|
|
|
|
using System.Linq;
|
2013-10-24 05:13:04 +00:00
|
|
|
|
using NLog;
|
2013-10-24 22:12:39 +00:00
|
|
|
|
using NzbDrone.Core.Configuration;
|
2013-10-24 05:13:04 +00:00
|
|
|
|
using NzbDrone.Core.IndexerSearch;
|
|
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
2014-12-19 00:26:42 +00:00
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
2013-10-24 05:13:04 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2017-01-21 21:43:58 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-10-24 05:13:04 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Download
|
|
|
|
|
{
|
2014-12-19 00:26:42 +00:00
|
|
|
|
public class RedownloadFailedDownloadService : IHandleAsync<DownloadFailedEvent>
|
2013-10-24 05:13:04 +00:00
|
|
|
|
{
|
2013-10-24 22:12:39 +00:00
|
|
|
|
private readonly IConfigService _configService;
|
2017-03-09 00:00:00 +00:00
|
|
|
|
private readonly IMovieService _movieService;
|
2015-01-16 00:30:09 +00:00
|
|
|
|
private readonly IManageCommandQueue _commandQueueManager;
|
2013-10-24 05:13:04 +00:00
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
2015-01-16 00:30:09 +00:00
|
|
|
|
public RedownloadFailedDownloadService(IConfigService configService,
|
2017-03-09 00:00:00 +00:00
|
|
|
|
IMovieService movieService,
|
2015-01-16 00:30:09 +00:00
|
|
|
|
IManageCommandQueue commandQueueManager,
|
|
|
|
|
Logger logger)
|
2013-10-24 05:13:04 +00:00
|
|
|
|
{
|
2013-10-24 22:12:39 +00:00
|
|
|
|
_configService = configService;
|
2017-03-09 00:00:00 +00:00
|
|
|
|
_movieService = movieService;
|
2015-01-16 00:30:09 +00:00
|
|
|
|
_commandQueueManager = commandQueueManager;
|
2013-10-24 05:13:04 +00:00
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 00:26:42 +00:00
|
|
|
|
public void HandleAsync(DownloadFailedEvent message)
|
2013-10-24 05:13:04 +00:00
|
|
|
|
{
|
2013-10-24 22:12:39 +00:00
|
|
|
|
if (!_configService.AutoRedownloadFailed)
|
|
|
|
|
{
|
2014-03-13 20:12:42 +00:00
|
|
|
|
_logger.Debug("Auto redownloading failed episodes is disabled");
|
2013-10-24 22:12:39 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-10 13:15:27 +00:00
|
|
|
|
if (message.MovieId != 0)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("Failed download contains a movie, searching again.");
|
2017-01-21 21:43:58 +00:00
|
|
|
|
_commandQueueManager.Push(new MoviesSearchCommand { MovieIds = new List<int> { message.MovieId } });
|
2013-10-24 05:13:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|