1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 08:22:35 +01:00
Sonarr/NzbDrone.Core/Indexers/RssSyncService.cs

51 lines
1.7 KiB
C#
Raw Normal View History

2013-04-07 09:30:37 +02:00
using System;
using System.Collections.Generic;
2013-04-07 09:30:37 +02:00
using System.Linq;
using NLog;
using NzbDrone.Common.Messaging;
2013-04-07 09:30:37 +02:00
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
namespace NzbDrone.Core.Indexers
{
2013-04-23 08:06:05 +02:00
public interface IRssSyncService
2013-04-07 09:30:37 +02:00
{
void Sync();
}
public class RssSyncService : IRssSyncService, IExecute<RssSyncCommand>
2013-04-07 09:30:37 +02:00
{
private readonly IFetchAndParseRss _rssFetcherAndParser;
private readonly IMakeDownloadDecision _downloadDecisionMaker;
2013-06-19 04:08:29 +02:00
private readonly IDownloadApprovedReportsService _downloadApprovedReportsService;
2013-04-07 09:30:37 +02:00
private readonly Logger _logger;
2013-06-19 04:08:29 +02:00
public RssSyncService(IFetchAndParseRss rssFetcherAndParser,
IMakeDownloadDecision downloadDecisionMaker,
IDownloadApprovedReportsService downloadApprovedReportsService,
Logger logger)
2013-04-07 09:30:37 +02:00
{
_rssFetcherAndParser = rssFetcherAndParser;
_downloadDecisionMaker = downloadDecisionMaker;
2013-06-19 04:08:29 +02:00
_downloadApprovedReportsService = downloadApprovedReportsService;
2013-04-07 09:30:37 +02:00
_logger = logger;
}
public void Sync()
{
_logger.Info("Starting RSS Sync");
var reports = _rssFetcherAndParser.Fetch();
var decisions = _downloadDecisionMaker.GetRssDecision(reports);
2013-06-19 04:08:29 +02:00
var qualifiedReports = _downloadApprovedReportsService.DownloadApproved(decisions);
2013-04-07 09:30:37 +02:00
_logger.Info("RSS Sync Completed. Reports found: {0}, Fetches attempted: {1}", reports.Count, qualifiedReports.Count());
2013-04-07 09:30:37 +02:00
}
public void Execute(RssSyncCommand message)
{
Sync();
}
2013-04-07 09:30:37 +02:00
}
}