1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-23 02:05:27 +02:00
Sonarr/NzbDrone.Core/Indexers/RssSyncService.cs

50 lines
1.6 KiB
C#
Raw Normal View History

2013-07-19 06:47:55 +03:00
using System.Linq;
2013-04-07 10:30:37 +03:00
using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
2013-09-11 09:33:47 +03:00
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Messaging.Commands;
2013-04-07 10:30:37 +03:00
namespace NzbDrone.Core.Indexers
{
2013-04-23 09:06:05 +03:00
public interface IRssSyncService
2013-04-07 10:30:37 +03:00
{
void Sync();
}
public class RssSyncService : IRssSyncService, IExecute<RssSyncCommand>
2013-04-07 10:30:37 +03:00
{
private readonly IFetchAndParseRss _rssFetcherAndParser;
private readonly IMakeDownloadDecision _downloadDecisionMaker;
private readonly IDownloadApprovedReports _downloadApprovedReports;
2013-04-07 10:30:37 +03:00
private readonly Logger _logger;
2013-06-19 05:08:29 +03:00
public RssSyncService(IFetchAndParseRss rssFetcherAndParser,
IMakeDownloadDecision downloadDecisionMaker,
IDownloadApprovedReports downloadApprovedReports,
2013-06-19 05:08:29 +03:00
Logger logger)
2013-04-07 10:30:37 +03:00
{
_rssFetcherAndParser = rssFetcherAndParser;
_downloadDecisionMaker = downloadDecisionMaker;
_downloadApprovedReports = downloadApprovedReports;
2013-04-07 10:30:37 +03:00
_logger = logger;
}
public void Sync()
{
2013-09-11 09:33:47 +03:00
_logger.ProgressInfo("Starting RSS Sync");
2013-04-07 10:30:37 +03:00
var reports = _rssFetcherAndParser.Fetch();
var decisions = _downloadDecisionMaker.GetRssDecision(reports);
var downloaded = _downloadApprovedReports.DownloadApproved(decisions);
2013-04-07 10:30:37 +03:00
2013-09-11 09:33:47 +03:00
_logger.ProgressInfo("RSS Sync Completed. Reports found: {0}, Reports downloaded: {1}", reports.Count, downloaded.Count());
2013-04-07 10:30:37 +03:00
}
public void Execute(RssSyncCommand message)
{
Sync();
}
2013-04-07 10:30:37 +03:00
}
}