1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-16 16:04:08 +01:00
Radarr/NzbDrone.Core/Download/DownloadService.cs

44 lines
1.4 KiB
C#
Raw Normal View History

using NLog;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Parser.Model;
2013-04-01 08:22:16 +02:00
namespace NzbDrone.Core.Download
{
public interface IDownloadService
{
2013-08-18 01:27:18 +02:00
void DownloadReport(RemoteEpisode remoteEpisode);
2013-04-01 08:22:16 +02:00
}
public class DownloadService : IDownloadService
{
private readonly IProvideDownloadClient _downloadClientProvider;
private readonly IMessageAggregator _messageAggregator;
2013-04-01 08:22:16 +02:00
private readonly Logger _logger;
2013-05-20 01:17:32 +02:00
public DownloadService(IProvideDownloadClient downloadClientProvider,
IMessageAggregator messageAggregator, Logger logger)
2013-04-01 08:22:16 +02:00
{
_downloadClientProvider = downloadClientProvider;
_messageAggregator = messageAggregator;
2013-04-01 08:22:16 +02:00
_logger = logger;
}
2013-08-18 01:27:18 +02:00
public void DownloadReport(RemoteEpisode remoteEpisode)
2013-04-01 08:22:16 +02:00
{
var downloadTitle = remoteEpisode.Report.Title;
var downloadClient = _downloadClientProvider.GetDownloadClient();
2013-04-01 08:22:16 +02:00
if (!downloadClient.IsConfigured)
{
_logger.Warn("Download client {0} isn't configured yet.", downloadClient.GetType().Name);
2013-08-18 01:27:18 +02:00
return;
}
2013-08-18 01:27:18 +02:00
downloadClient.DownloadNzb(remoteEpisode);
2013-04-01 08:22:16 +02:00
2013-08-18 01:27:18 +02:00
_logger.Info("Report sent to download client. {0}", downloadTitle);
_messageAggregator.PublishEvent(new EpisodeGrabbedEvent(remoteEpisode));
2013-04-01 08:22:16 +02:00
}
}
}