Nzbget added to UI

#ND-145 fixed
This commit is contained in:
Mark McDowall 2013-01-23 23:31:41 -08:00
parent bf2c811a09
commit 54c29ada12
11 changed files with 167 additions and 11 deletions

View File

@ -558,7 +558,7 @@ namespace NzbDrone.Core.Providers.Core
public virtual String NzbgetHost
{
get { return GetValue("NzbgetHost", "nzbget"); }
get { return GetValue("NzbgetHost", "localhost"); }
set { SetValue("NzbgetHost", value); }
}

View File

@ -131,15 +131,15 @@ namespace NzbDrone.Core.Providers.DownloadClients
Params = null
};
var url = String.Format(@"http://{0}:{1}/jsonrpc", host, port);
var response = _httpProvider.PostCommand(url, username, password, JsonConvert.SerializeObject(command));
var address = String.Format(@"{0}:{1}", host, port);
var response = _httpProvider.PostCommand(address, username, password, JsonConvert.SerializeObject(command));
CheckForError(response);
return JsonConvert.DeserializeObject<VersionModel>(response);
}
public virtual string Test(string host, int port, string apiKey, string username, string password)
public virtual string Test(string host, int port, string username, string password)
{
try
{
@ -156,7 +156,7 @@ namespace NzbDrone.Core.Providers.DownloadClients
private string PostCommand(string command)
{
var url = String.Format(@"http://{0}:{1}/jsonrpc",
var url = String.Format(@"{0}:{1}",
_configProvider.NzbgetHost,
_configProvider.NzbgetPort);

View File

@ -19,13 +19,15 @@ namespace NzbDrone.Core.Providers
private readonly BlackholeProvider _blackholeProvider;
private readonly SignalRProvider _signalRProvider;
private readonly PneumaticProvider _pneumaticProvider;
private readonly NzbgetProvider _nzbgetProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public DownloadProvider(SabProvider sabProvider, HistoryProvider historyProvider,
EpisodeProvider episodeProvider, ExternalNotificationProvider externalNotificationProvider,
ConfigProvider configProvider, BlackholeProvider blackholeProvider,
SignalRProvider signalRProvider, PneumaticProvider pneumaticProvider)
SignalRProvider signalRProvider, PneumaticProvider pneumaticProvider,
NzbgetProvider nzbgetProvider)
{
_sabProvider = sabProvider;
_historyProvider = historyProvider;
@ -35,6 +37,7 @@ namespace NzbDrone.Core.Providers
_blackholeProvider = blackholeProvider;
_signalRProvider = signalRProvider;
_pneumaticProvider = pneumaticProvider;
_nzbgetProvider = nzbgetProvider;
}
public DownloadProvider()
@ -90,6 +93,9 @@ namespace NzbDrone.Core.Providers
case DownloadClientType.Pneumatic:
return _pneumaticProvider;
case DownloadClientType.Nzbget:
return _nzbgetProvider;
default:
return _sabProvider;
}

View File

@ -21,6 +21,7 @@ namespace NzbDrone.Web.Controllers
private readonly ProwlProvider _prowlProvider;
private readonly XbmcProvider _xbmcProvider;
private readonly PlexProvider _plexProvider;
private readonly NzbgetProvider _nzbgetProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
@ -28,7 +29,8 @@ namespace NzbDrone.Web.Controllers
SmtpProvider smtpProvider, TwitterProvider twitterProvider,
EpisodeProvider episodeProvider, GrowlProvider growlProvider,
SeasonProvider seasonProvider, ProwlProvider prowlProvider,
XbmcProvider xbmcProvider, PlexProvider plexProvider)
XbmcProvider xbmcProvider, PlexProvider plexProvider,
NzbgetProvider nzbgetProvider)
{
_jobProvider = jobProvider;
_sabProvider = sabProvider;
@ -40,6 +42,7 @@ namespace NzbDrone.Web.Controllers
_prowlProvider = prowlProvider;
_xbmcProvider = xbmcProvider;
_plexProvider = plexProvider;
_nzbgetProvider = nzbgetProvider;
}
public JsonResult RssSync()
@ -174,6 +177,17 @@ namespace NzbDrone.Web.Controllers
return JsonNotificationResult.Info("Success!", "SABnzbd settings have been verified successfully! Version: " + version);
}
public JsonResult TestNzbget(string host, int port, string username, string password)
{
//_prowlProvider.TestNotification(apiKeys);
var version = _nzbgetProvider.Test(host, port, username, password);
if (String.IsNullOrWhiteSpace(version))
return JsonNotificationResult.Oops("Failed to connect to Nzbget, please check your settings");
return JsonNotificationResult.Info("Success!", "Nzbget settings have been verified successfully! Version: " + version);
}
public JsonResult TestXbmcNotification(string hosts)
{
try

View File

@ -8,6 +8,7 @@ using NzbDrone.Common.Model;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
@ -145,9 +146,25 @@ namespace NzbDrone.Web.Controllers
BlackholeDirectory = _configProvider.BlackholeDirectory,
DownloadClientSelectList = new SelectList(downloadClientTypes, "Key", "Value"),
PneumaticDirectory = _configProvider.PneumaticDirectory,
UseSceneName = _configProvider.DownloadClientUseSceneName
UseSceneName = _configProvider.DownloadClientUseSceneName,
NzbgetHost = _configProvider.NzbgetHost,
NzbgetPort = _configProvider.NzbgetPort,
NzbgetUsername = _configProvider.NzbgetUsername,
NzbgetPassword = _configProvider.NzbgetPassword,
NzbgetTvCategory = _configProvider.NzbgetTvCategory,
NzbgetBacklogTvPriority = (Int32)_configProvider.NzbgetBacklogTvPriority,
NzbgetRecentTvPriority = (Int32)_configProvider.NzbgetRecentTvPriority
};
model.NzbgetPrioritySelectList = new SelectList(new List<dynamic>
{
new { Key = "Very Low", Value = "-100" },
new { Key = "Low", Value = "-50" },
new { Key = "Normal", Value = "0" },
new { Key = "High", Value = "-50" },
new { Key = "Very High", Value = "100" }
}, "Value", "Key");
return View(model);
}
@ -460,6 +477,13 @@ namespace NzbDrone.Web.Controllers
_configProvider.DownloadClient = (DownloadClientType)data.DownloadClient;
_configProvider.PneumaticDirectory = data.PneumaticDirectory;
_configProvider.DownloadClientUseSceneName = data.UseSceneName;
_configProvider.NzbgetHost = data.NzbgetHost;
_configProvider.NzbgetPort = data.NzbgetPort;
_configProvider.NzbgetUsername = data.NzbgetUsername;
_configProvider.NzbgetPassword = data.NzbgetPassword;
_configProvider.NzbgetTvCategory = data.NzbgetTvCategory;
_configProvider.NzbgetBacklogTvPriority = (PriorityType)data.NzbgetBacklogTvPriority;
_configProvider.NzbgetRecentTvPriority = (PriorityType)data.NzbgetRecentTvPriority;
return GetSuccessResult();
}

View File

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Model.Sabnzbd;
using NzbDrone.Web.Helpers.Validation;
@ -10,9 +12,11 @@ namespace NzbDrone.Web.Models
{
public class DownloadClientSettingsModel
{
public SelectList PrioritySelectList =
public SelectList SabPrioritySelectList =
new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Force"});
public SelectList NzbgetPrioritySelectList { get; set; }
[DataType(DataType.Text)]
[DisplayName("SABnzbd Host")]
[Description("Hostname or IP Address running SABnzbd")]
@ -85,6 +89,46 @@ namespace NzbDrone.Web.Models
[Description("Use Scene name when adding NZB to queue?")]
public Boolean UseSceneName { get; set; }
[DataType(DataType.Text)]
[DisplayName("Nzbget Host")]
[Description("Hostname or IP Address running Nzbget")]
[RequiredIf("DownloadClient", (int)DownloadClientType.Nzbget, ErrorMessage = "Required when Download Client is Nzbget")]
public String NzbgetHost { get; set; }
[DataType(DataType.Text)]
[DisplayName("Nzbget Port")]
[Description("Port for Nzbget web interface")]
[RequiredIf("DownloadClient", (int)DownloadClientType.Nzbget, ErrorMessage = "Required when Download Client is Nzbget")]
public int NzbgetPort { get; set; }
[DataType(DataType.Text)]
[DisplayName("Nzbget Username")]
[Description("Username for Nzbget")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbgetUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("Nzbget Password")]
[Description("Password for Nzbget")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbgetPassword { get; set; }
[DataType(DataType.Text)]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[DisplayName("Nzbget TV Category")]
[Description("Category to use when sending NZBs to Nzbget")]
public String NzbgetTvCategory { get; set; }
[Required(ErrorMessage = "Please select a valid priority")]
[DisplayName("Nzbget Backlog Priority")]
[Description("Priority to use when sending episodes older than 7 days to Nzbget")]
public Int32 NzbgetBacklogTvPriority { get; set; }
[Required(ErrorMessage = "Please select a valid priority")]
[DisplayName("Nzbget Recent Priority")]
[Description("Priority to use when sending episodes newer than 7 days to Nzbget")]
public Int32 NzbgetRecentTvPriority { get; set; }
public SelectList SabTvCategorySelectList { get; set; }
public SelectList DownloadClientSelectList { get; set; }
}

View File

@ -305,6 +305,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Views\System\Index.cshtml" />
<Content Include="Views\System\Logs.cshtml" />
<Content Include="Views\Settings\Nzbget.cshtml" />
<None Include="_bin_deployableAssemblies\x86\sqlcese40.dll" />
<None Include="_bin_deployableAssemblies\x86\sqlceqp40.dll" />
<None Include="_bin_deployableAssemblies\x86\sqlceme40.dll" />

View File

@ -8,6 +8,7 @@ $('#MultiEpisodeStyle').live('change', function () { createExamples(); });
var testProwlUrl = '../Command/TestProwl';
var testSabUrl = '../Command/TestSabnzbd';
var testNzbgetUrl = '../Command/TestNzbget';
var testEmailUrl = '../Command/TestEmail';
var testXbmcNotificationUrl = '../Command/TestXbmcNotification';
var testXbmcJsonApiUrl = '../Command/TestXbmcJsonApi';
@ -145,6 +146,19 @@ function testSabnzbd(event) {
event.preventDefault();
}
function testNzbget() {
var host = $('#NzbgetHost').val();
var port = $('#NzbgetPort').val();
var username = $('#NzbgetUsername').val();
var password = $('#NzbgetPassword').val();
$.ajax({
type: "GET",
url: testNzbgetUrl,
data: jQuery.param({ host: host, port: port, username: username, password: password })
});
}
//Twitter
getAuthorizationUrl = '../Command/GetTwitterAuthorization';
verifyAuthorizationUrl = '../Command/VerifyTwitterAuthorization';

View File

@ -59,6 +59,9 @@
<h3><a href="#">Pneumatic</a></h3>
@{Html.RenderPartial("Pneumatic", Model);}
<h3><a href="#">Nzbget</a></h3>
@{Html.RenderPartial("Nzbget", Model);}
</div>
<button type="submit" class="save_button" disabled="disabled">

View File

@ -0,0 +1,50 @@
@using NzbDrone.Web.Helpers;
@model NzbDrone.Web.Models.DownloadClientSettingsModel
@{
Layout = null;
}
<div class="downloadClient">
<label class="labelClass">@Html.LabelFor(m => m.NzbgetHost)
<span class="small">@Html.DescriptionFor(m => m.NzbgetHost)</span>
<span class="small">@Html.ValidationMessageFor(m => m.NzbgetHost)</span>
</label>
@Html.TextBoxFor(m => m.NzbgetHost, new { @class = "inputClass" })
<label class="labelClass">@Html.LabelFor(m => m.NzbgetPort)
<span class="small">@Html.DescriptionFor(m => m.NzbgetPort)</span>
<span class="small">@Html.ValidationMessageFor(m => m.NzbgetPort)</span>
</label>
@Html.TextBoxFor(m => m.NzbgetPort, new { @class = "inputClass" })
<label class="labelClass">@Html.LabelFor(m => m.NzbgetUsername)
<span class="small">@Html.DescriptionFor(m => m.NzbgetUsername)</span>
</label>
@Html.TextBoxFor(m => m.NzbgetUsername, new { @class = "inputClass" })
<label class="labelClass">@Html.LabelFor(m => m.NzbgetPassword)
<span class="small">@Html.DescriptionFor(m => m.NzbgetPassword)</span>
</label>
@Html.TextBoxFor(m => m.NzbgetPassword, new { @class = "inputClass", type = "password" })
<label class="labelClass">@Html.LabelFor(m => m.NzbgetTvCategory)
<span class="small">@Html.DescriptionFor(m => m.NzbgetTvCategory)</span>
</label>
@Html.TextBoxFor(m => m.NzbgetTvCategory, new { @class = "inputClass" })
<label class="labelClass">@Html.LabelFor(m => m.NzbgetBacklogTvPriority)
<span class="small">@Html.DescriptionFor(m => m.NzbgetBacklogTvPriority)</span>
</label>
@Html.DropDownListFor(m => m.NzbgetBacklogTvPriority, Model.NzbgetPrioritySelectList, new { @class = "inputClass selectClass" })
<label class="labelClass">@Html.LabelFor(m => m.NzbgetRecentTvPriority)
<span class="small">@Html.DescriptionFor(m => m.NzbgetRecentTvPriority)</span>
</label>
@Html.DropDownListFor(m => m.NzbgetRecentTvPriority, Model.NzbgetPrioritySelectList, new { @class = "inputClass selectClass" })
<label class="labelClass">Test Nzbget
<span class="small">Test Nzbget settings</span>
</label>
<input type="button" onclick="testNzbget();" value="Test" class="inputClass" />
</div>

View File

@ -48,12 +48,12 @@
<label class="labelClass">@Html.LabelFor(m => m.SabBacklogTvPriority)
<span class="small">@Html.DescriptionFor(m => m.SabBacklogTvPriority)</span>
</label>
@Html.DropDownListFor(m => m.SabBacklogTvPriority, Model.PrioritySelectList, new { @class = "inputClass selectClass" })
@Html.DropDownListFor(m => m.SabBacklogTvPriority, Model.SabPrioritySelectList, new { @class = "inputClass selectClass" })
<label class="labelClass">@Html.LabelFor(m => m.SabRecentTvPriority)
<span class="small">@Html.DescriptionFor(m => m.SabRecentTvPriority)</span>
</label>
@Html.DropDownListFor(m => m.SabRecentTvPriority, Model.PrioritySelectList, new { @class = "inputClass selectClass" })
@Html.DropDownListFor(m => m.SabRecentTvPriority, Model.SabPrioritySelectList, new { @class = "inputClass selectClass" })
<label class="labelClass">Test SABnzbd
<span class="small">Test SABnzbd settings</span>