Added categories to newznab section

This commit is contained in:
Mark McDowall 2013-07-30 20:41:46 -07:00
parent f9fe119af2
commit 17842d3fa1
2 changed files with 28 additions and 6 deletions

View File

@ -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<Int32>{ 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<Int32>())
});
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<Int32>())
});
return list;
@ -51,16 +51,29 @@ namespace NzbDrone.Core.Indexers.Newznab
}
}
private string GetSettings(string url)
private string GetSettings(string url, List<int> 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<string> 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<int>{ 5000 };
}
var url = String.Format("{0}/api?t=tvsearch&cat={1}", Settings.Url, String.Join(",", Settings.Categories));
if (!String.IsNullOrWhiteSpace(Settings.ApiKey))
{

View File

@ -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<Int32> Categories { get; set; }
public bool IsValid
{
get