From 17842d3fa13dccd90bfc313f3a6360654fa11064 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 30 Jul 2013 20:41:46 -0700 Subject: [PATCH] Added categories to newznab section --- NzbDrone.Core/Indexers/Newznab/Newznab.cs | 25 ++++++++++++++----- .../Indexers/Newznab/NewznabSettings.cs | 9 +++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/NzbDrone.Core/Indexers/Newznab/Newznab.cs index 89aeb7c27..8168d0740 100644 --- a/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Indexers.Newznab Enable = false, Name = "Nzbs.org", Implementation = GetType().Name, - Settings = GetSettings("http://nzbs.org") + Settings = GetSettings("http://nzbs.org", new List{ 5000 }) }); @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Indexers.Newznab Enable = false, Name = "Nzb.su", Implementation = GetType().Name, - Settings = GetSettings("https://nzb.su") + Settings = GetSettings("https://nzb.su", new List()) }); list.Add(new IndexerDefinition @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Indexers.Newznab Enable = false, Name = "Dognzb.cr", Implementation = GetType().Name, - Settings = GetSettings("https://dognzb.cr") + Settings = GetSettings("https://dognzb.cr", new List()) }); return list; @@ -51,16 +51,29 @@ namespace NzbDrone.Core.Indexers.Newznab } } - private string GetSettings(string url) + private string GetSettings(string url, List categories) { - return new NewznabSettings { Url = url }.ToJson(); + var settings = new NewznabSettings { Url = url }; + + if (categories.Any()) + { + settings.Categories = categories; + } + + return settings.ToJson(); } public override IEnumerable RecentFeed { get { - var url = String.Format("{0}/api?t=tvsearch&cat=5000", Settings.Url); + //Todo: We should be able to update settings on start + if (Name.Equals("nzbs.org")) + { + Settings.Categories = new List{ 5000 }; + } + + var url = String.Format("{0}/api?t=tvsearch&cat={1}", Settings.Url, String.Join(",", Settings.Categories)); if (!String.IsNullOrWhiteSpace(Settings.ApiKey)) { diff --git a/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs b/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs index 29a9c84bc..10291e2c6 100644 --- a/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs +++ b/NzbDrone.Core/Indexers/Newznab/NewznabSettings.cs @@ -1,16 +1,25 @@ using System; +using System.Collections; +using System.Collections.Generic; using NzbDrone.Core.Annotations; namespace NzbDrone.Core.Indexers.Newznab { public class NewznabSettings : IIndexerSetting { + public NewznabSettings() + { + Categories = new [] { 5030, 5040 }; + } + [FieldDefinition(0, Label = "URL")] public String Url { get; set; } [FieldDefinition(1, Label = "API Key")] public String ApiKey { get; set; } + public IEnumerable Categories { get; set; } + public bool IsValid { get