From 16234d6b7911254e23d0870b85684d8d2e02fd6b Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 4 Apr 2011 00:21:07 -0700 Subject: [PATCH] Added nzbs.org using the provider model. --- NzbDrone.5.1.ReSharper | 2 +- NzbDrone.Core/NzbDrone.Core.csproj | 4 +-- .../Providers/{ => Feed}/FeedProviderBase.cs | 20 ++++++----- .../Providers/Feed/NzbsOrgFeedProvider.cs | 35 +++++++++++++++++++ .../Providers/PostProcessingProvider.cs | 6 ++-- 5 files changed, 52 insertions(+), 15 deletions(-) rename NzbDrone.Core/Providers/{ => Feed}/FeedProviderBase.cs (84%) create mode 100644 NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs diff --git a/NzbDrone.5.1.ReSharper b/NzbDrone.5.1.ReSharper index 3f5dfa8c2..f86d34090 100644 --- a/NzbDrone.5.1.ReSharper +++ b/NzbDrone.5.1.ReSharper @@ -129,7 +129,7 @@ - + diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 191738098..1ef76a287 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -173,8 +173,9 @@ - + + @@ -275,7 +276,6 @@ - diff --git a/NzbDrone.Core/Providers/FeedProviderBase.cs b/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs similarity index 84% rename from NzbDrone.Core/Providers/FeedProviderBase.cs rename to NzbDrone.Core/Providers/Feed/FeedProviderBase.cs index 2ff52f1c7..1d826901c 100644 --- a/NzbDrone.Core/Providers/FeedProviderBase.cs +++ b/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs @@ -2,21 +2,24 @@ using System.Xml; using NLog; using NzbDrone.Core.Model; +using NzbDrone.Core.Providers.Core; -namespace NzbDrone.Core.Providers +namespace NzbDrone.Core.Providers.Feed { abstract class FeedProviderBase { - private readonly ISeriesProvider _seriesProvider; - private readonly ISeasonProvider _seasonProvider; - private readonly IEpisodeProvider _episodeProvider; - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + protected readonly ISeriesProvider _seriesProvider; + protected readonly ISeasonProvider _seasonProvider; + protected readonly IEpisodeProvider _episodeProvider; + protected readonly IConfigProvider _configProvider; + protected static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - protected FeedProviderBase(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider) + protected FeedProviderBase(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IConfigProvider configProvider) { _seriesProvider = seriesProvider; _seasonProvider = seasonProvider; _episodeProvider = episodeProvider; + _configProvider = configProvider; } @@ -72,6 +75,7 @@ namespace NzbDrone.Core.Providers foreach (var url in URL) { + Logger.Debug("Downloading RSS " + url); var feed = SyndicationFeed.Load(XmlReader.Create(url)).Items; foreach (var item in feed) @@ -85,6 +89,8 @@ namespace NzbDrone.Core.Providers private void ProcessItem(SyndicationItem feedItem) { + Logger.Info("Processing RSS feed item " + feedItem.Title); + var parseResult = ParseFeed(feedItem); if (!_seriesProvider.IsMonitored(parseResult.SeriesId)) @@ -106,8 +112,6 @@ namespace NzbDrone.Core.Providers { Logger.Debug("Episode {0} is not needed. skipping.", parseResult); } - - } } diff --git a/NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs b/NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs new file mode 100644 index 000000000..74ace542f --- /dev/null +++ b/NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceModel.Syndication; +using System.Text; +using NzbDrone.Core.Providers.Core; + +namespace NzbDrone.Core.Providers.Feed +{ + class NzbsOrgFeedProvider : FeedProviderBase + { + public NzbsOrgFeedProvider(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IConfigProvider configProvider) + : base(seriesProvider, seasonProvider, episodeProvider, configProvider) + { + } + + protected override string[] URL + { + get + { + return new[] { string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}", _configProvider.NzbsOrgUId, _configProvider.NzbsOrgHash) }; + } + } + + protected override string Name + { + get { return "Nzbs.Org"; } + } + + protected override string NzbDownloadUrl(SyndicationItem item) + { + return item.Id.Replace("action=view", "action=getnzb"); + } + } +} diff --git a/NzbDrone.Core/Providers/PostProcessingProvider.cs b/NzbDrone.Core/Providers/PostProcessingProvider.cs index 4490ca3cb..7eed8f415 100644 --- a/NzbDrone.Core/Providers/PostProcessingProvider.cs +++ b/NzbDrone.Core/Providers/PostProcessingProvider.cs @@ -12,16 +12,14 @@ namespace NzbDrone.Core.Providers public class PostProcessingProvider : IPostProcessingProvider { private readonly ISeriesProvider _seriesProvider; - private readonly IConfigProvider _configProvider; private readonly IMediaFileProvider _mediaFileProvider; private readonly IRenameProvider _renameProvider; - public PostProcessingProvider(ISeriesProvider seriesProvider, IConfigProvider configProvider, + public PostProcessingProvider(ISeriesProvider seriesProvider, IMediaFileProvider mediaFileProvider, IRenameProvider renameProvider) { _seriesProvider = seriesProvider; - _configProvider = configProvider; - _mediaFileProvider = mediaFileProvider; + _mediaFileProvider = mediaFileProvider; _renameProvider = renameProvider; }