|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the source URL for the feed
|
|
|
|
|
/// </summary>
|
|
|
|
@ -22,6 +31,41 @@ namespace NzbDrone.Core.Providers
|
|
|
|
|
protected abstract string Name { get; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates direct link to download an NZB
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">RSS Feed item to generate the link for</param>
|
|
|
|
|
/// <returns>Download link URL</returns>
|
|
|
|
|
protected abstract string NzbDownloadUrl(SyndicationItem item);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Parses the RSS feed item and.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">RSS feed item to parse</param>
|
|
|
|
|
/// <returns>Detailed episode info</returns>
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches RSS feed and process each news item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|