diff --git a/NzbDrone.Core/Providers/FeedProviderBase.cs b/NzbDrone.Core/Providers/FeedProviderBase.cs
index cda12260d..2ff52f1c7 100644
--- a/NzbDrone.Core/Providers/FeedProviderBase.cs
+++ b/NzbDrone.Core/Providers/FeedProviderBase.cs
@@ -1,16 +1,25 @@
-using System;
-using System.ServiceModel.Syndication;
+using System.ServiceModel.Syndication;
using System.Xml;
using NLog;
using NzbDrone.Core.Model;
-using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
abstract class FeedProviderBase
{
+ private readonly ISeriesProvider _seriesProvider;
+ private readonly ISeasonProvider _seasonProvider;
+ private readonly IEpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+ protected FeedProviderBase(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider)
+ {
+ _seriesProvider = seriesProvider;
+ _seasonProvider = seasonProvider;
+ _episodeProvider = episodeProvider;
+ }
+
+
///
/// Gets the source URL for the feed
///
@@ -22,6 +31,41 @@ namespace NzbDrone.Core.Providers
protected abstract string Name { get; }
+ ///
+ /// Generates direct link to download an NZB
+ ///
+ /// RSS Feed item to generate the link for
+ /// Download link URL
+ protected abstract string NzbDownloadUrl(SyndicationItem item);
+
+
+ ///
+ /// Parses the RSS feed item and.
+ ///
+ /// RSS feed item to parse
+ /// Detailed episode info
+ protected EpisodeParseResult ParseFeed(SyndicationItem item)
+ {
+ var episodeParseResult = Parser.ParseEpisodeInfo(item.Title.ToString());
+ var seriesInfo = _seriesProvider.FindSeries(episodeParseResult.SeriesTitle);
+
+ if (seriesInfo != null)
+ {
+ episodeParseResult.SeriesId = seriesInfo.SeriesId;
+ episodeParseResult.SeriesTitle = seriesInfo.Title;
+ return episodeParseResult;
+ }
+
+ Logger.Debug("Unable to map {0} to any of series in database", episodeParseResult.SeriesTitle);
+ return null;
+
+ }
+
+
+
+ ///
+ /// Fetches RSS feed and process each news item.
+ ///
public void Fetch()
{
Logger.Info("Fetching feeds from " + Name);
@@ -36,49 +80,34 @@ namespace NzbDrone.Core.Providers
}
}
-
Logger.Info("Finished processing feeds from " + Name);
}
- private void ProcessItem(SyndicationItem item)
+ private void ProcessItem(SyndicationItem feedItem)
{
- var parseResult = ParseFeed(item);
- }
+ var parseResult = ParseFeed(feedItem);
-
- public void DownloadIfWanted(NzbInfoModel nzb, Indexer indexer)
- {
- if (nzb.IsPassworded())
+ if (!_seriesProvider.IsMonitored(parseResult.SeriesId))
{
- Logger.Debug("Skipping Passworded Report {0}", nzb.Title);
- return;
+ Logger.Debug("{0} is present in the DB but not tracked. skipping.", parseResult.SeriesTitle);
}
- var episodeParseResults = Parser.ParseEpisodeInfo(nzb.Title);
-
- if (episodeParseResults.Episodes.Count > 0)
+ if (!_seriesProvider.QualityWanted(parseResult.SeriesId, parseResult.Quality))
{
- //ProcessStandardItem(nzb, indexer, episodeParseResults);
- return;
+ Logger.Debug("Post doesn't meet the quality requirements [{0}]. skipping.", parseResult.Quality);
}
- //Handles Full Season NZBs
- var seasonParseResult = Parser.ParseSeasonInfo(nzb.Title);
-
- if (seasonParseResult != null)
+ if (_seasonProvider.IsIgnored(parseResult.SeriesId, parseResult.SeasonNumber))
{
- //ProcessFullSeasonItem(nzb, indexer, seasonParseResult);
- return;
+ Logger.Debug("Season {0} is currently set to ignore. skipping.", parseResult.SeasonNumber);
}
- Logger.Debug("Unsupported Title: {0}", nzb.Title);
-
- }
+ if (!_episodeProvider.IsNeeded(parseResult))
+ {
+ Logger.Debug("Episode {0} is not needed. skipping.", parseResult);
+ }
- protected EpisodeParseResult ParseFeed(SyndicationItem item)
- {
- return Parser.ParseEpisodeInfo(item.Title.ToString());
}
}
diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs
index 767eabcc1..330bc8706 100644
--- a/NzbDrone.Core/Providers/SeriesProvider.cs
+++ b/NzbDrone.Core/Providers/SeriesProvider.cs
@@ -111,9 +111,9 @@ namespace NzbDrone.Core.Providers
_sonioRepo.Add(repoSeries);
}
- public Series FindSeries(string cleanTitle)
+ public Series FindSeries(string title)
{
- return _sonioRepo.Single(s => s.CleanTitle == cleanTitle);
+ return _sonioRepo.Single(s => s.CleanTitle == Parser.NormalizeTitle(title));
}
public void UpdateSeries(Series series)