|
|
|
@ -1,23 +1,18 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.DecisionEngine;
|
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Parser;
|
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public interface ISyncRss
|
|
|
|
|
public interface IRssSyncService
|
|
|
|
|
{
|
|
|
|
|
void Sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class RssSyncService : ISyncRss
|
|
|
|
|
public class RssSyncService : IRssSyncService
|
|
|
|
|
{
|
|
|
|
|
private readonly IFetchAndParseRss _rssFetcherAndParser;
|
|
|
|
|
private readonly IMakeDownloadDecision _downloadDecisionMaker;
|
|
|
|
@ -40,6 +35,8 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
var parseResults = _rssFetcherAndParser.Fetch();
|
|
|
|
|
var decisions = _downloadDecisionMaker.GetRssDecision(parseResults);
|
|
|
|
|
|
|
|
|
|
//TODO: this will download multiple of same episode if they show up in RSS. need to
|
|
|
|
|
|
|
|
|
|
var qualifiedReports = decisions
|
|
|
|
|
.Where(c => c.Approved)
|
|
|
|
|
.Select(c => c.Episode)
|
|
|
|
@ -48,6 +45,7 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
.ThenBy(c => c.Report.Age);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var episodeParseResult in qualifiedReports)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
@ -60,44 +58,7 @@ namespace NzbDrone.Core.Indexers
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Info("RSS Sync Completed. Reports found {0}, Fetches attempted {1}", parseResults.Count, qualifiedReports);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface IFetchAndParseRss
|
|
|
|
|
{
|
|
|
|
|
List<ReportInfo> Fetch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class FetchAndParseRssService : IFetchAndParseRss
|
|
|
|
|
{
|
|
|
|
|
private readonly IIndexerService _indexerService;
|
|
|
|
|
private readonly IFetchFeedFromIndexers _feedFetcher;
|
|
|
|
|
|
|
|
|
|
public FetchAndParseRssService(IIndexerService indexerService, IFetchFeedFromIndexers feedFetcher)
|
|
|
|
|
{
|
|
|
|
|
_indexerService = indexerService;
|
|
|
|
|
_feedFetcher = feedFetcher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportInfo> Fetch()
|
|
|
|
|
{
|
|
|
|
|
var result = new List<ReportInfo>();
|
|
|
|
|
|
|
|
|
|
var indexers = _indexerService.GetAvailableIndexers();
|
|
|
|
|
|
|
|
|
|
Parallel.ForEach(indexers, indexer =>
|
|
|
|
|
{
|
|
|
|
|
var indexerFeed = _feedFetcher.FetchRss(indexer);
|
|
|
|
|
|
|
|
|
|
lock (result)
|
|
|
|
|
{
|
|
|
|
|
result.AddRange(indexerFeed);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
_logger.Info("RSS Sync Completed. Reports found: {0}, Fetches attempted: {1}", parseResults.Count, qualifiedReports.Count());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|