mirror of https://github.com/Radarr/Radarr
New: Added test button to SABnzbd.
New: Added test button to Prowl.
This commit is contained in:
parent
5ea626585f
commit
74105974dd
|
@ -39,7 +39,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|||
fakeConfig.SetupGet(c => c.SabTvCategory).Returns("tv");
|
||||
}
|
||||
|
||||
|
||||
private void WithFailResponse()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
|
@ -57,7 +56,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|||
Mocker.Resolve<SabProvider>().DownloadNzb(url, title).Should().BeTrue();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void newzbin_add_url_should_format_request_properly()
|
||||
{
|
||||
|
@ -122,7 +120,6 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|||
result.categories.Should().NotBeEmpty();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetHistory_should_return_a_list_with_items_when_the_history_has_items()
|
||||
{
|
||||
|
@ -162,5 +159,54 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
|
|||
Assert.Throws<ApplicationException>(() => Mocker.Resolve<SabProvider>().GetHistory(), "API Key Incorrect");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetVersion_should_return_the_version_using_passed_in_values()
|
||||
{
|
||||
var response = "{ \"version\": \"0.6.9\" }";
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=version&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(response);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SabProvider>().GetVersion("192.168.5.55", 2222, "5c770e3197e4fe763423ee7c392c25d1", "admin", "pass");
|
||||
|
||||
//Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Version.Should().Be("0.6.9");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetVersion_should_return_the_version_using_saved_values()
|
||||
{
|
||||
var response = "{ \"version\": \"0.6.9\" }";
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=version&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(response);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SabProvider>().GetVersion();
|
||||
|
||||
//Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Version.Should().Be("0.6.9");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_should_return_version_as_a_string()
|
||||
{
|
||||
var response = "{ \"version\": \"0.6.9\" }";
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=version&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(response);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SabProvider>().Test("192.168.5.55", 2222, "5c770e3197e4fe763423ee7c392c25d1", "admin", "pass");
|
||||
|
||||
//Assert
|
||||
result.Should().Be("0.6.9");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Model.Sabnzbd
|
||||
{
|
||||
public class SabVersionModel
|
||||
{
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
|
@ -263,6 +263,7 @@
|
|||
<Compile Include="Model\Sabnzbd\SabCategoryModel.cs" />
|
||||
<Compile Include="Model\Sabnzbd\SabModel.cs" />
|
||||
<Compile Include="Model\Sabnzbd\SabQueueItem.cs" />
|
||||
<Compile Include="Model\Sabnzbd\SabVersionModel.cs" />
|
||||
<Compile Include="Model\Twitter\TwitterAuthorizationModel.cs" />
|
||||
<Compile Include="Model\UpdatePackage.cs" />
|
||||
<Compile Include="Model\Xbmc\ActionType.cs" />
|
||||
|
|
|
@ -121,7 +121,6 @@ namespace NzbDrone.Core.Providers.DownloadClients
|
|||
return items ?? new List<SabHistoryItem>();
|
||||
}
|
||||
|
||||
|
||||
public virtual SabCategoryModel GetCategories(string host = null, int port = 0, string apiKey = null, string username = null, string password = null)
|
||||
{
|
||||
//Get saved values if any of these are defaults
|
||||
|
@ -155,6 +154,54 @@ namespace NzbDrone.Core.Providers.DownloadClients
|
|||
return categories;
|
||||
}
|
||||
|
||||
public virtual SabVersionModel GetVersion(string host = null, int port = 0, string apiKey = null, string username = null, string password = null)
|
||||
{
|
||||
//Get saved values if any of these are defaults
|
||||
if (host == null)
|
||||
host = _configProvider.SabHost;
|
||||
|
||||
if (port == 0)
|
||||
port = _configProvider.SabPort;
|
||||
|
||||
if (apiKey == null)
|
||||
apiKey = _configProvider.SabApiKey;
|
||||
|
||||
if (username == null)
|
||||
username = _configProvider.SabUsername;
|
||||
|
||||
if (password == null)
|
||||
password = _configProvider.SabPassword;
|
||||
|
||||
const string action = "mode=version&output=json";
|
||||
|
||||
var command = string.Format(@"http://{0}:{1}/api?{2}&apikey={3}&ma_username={4}&ma_password={5}",
|
||||
host, port, action, apiKey, username, password);
|
||||
|
||||
var response = _httpProvider.DownloadString(command);
|
||||
|
||||
if (String.IsNullOrWhiteSpace(response))
|
||||
return null;
|
||||
|
||||
var version = JsonConvert.DeserializeObject<SabVersionModel>(response);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
public virtual string Test(string host, int port, string apiKey, string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
var version = GetVersion(host, port, apiKey, username, password);
|
||||
return version.Version;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.DebugException("Failed to Test SABnzbd", ex);
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
private string GetSabRequest(string action)
|
||||
{
|
||||
return string.Format(@"http://{0}:{1}/api?{2}&apikey={3}&ma_username={4}&ma_password={5}",
|
||||
|
|
|
@ -17,10 +17,12 @@ namespace NzbDrone.Web.Controllers
|
|||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly GrowlProvider _growlProvider;
|
||||
private readonly SeasonProvider _seasonProvider;
|
||||
private readonly ProwlProvider _prowlProvider;
|
||||
|
||||
public CommandController(JobProvider jobProvider, SabProvider sabProvider,
|
||||
SmtpProvider smtpProvider, TwitterProvider twitterProvider,
|
||||
EpisodeProvider episodeProvider, GrowlProvider growlProvider, SeasonProvider seasonProvider)
|
||||
EpisodeProvider episodeProvider, GrowlProvider growlProvider,
|
||||
SeasonProvider seasonProvider, ProwlProvider prowlProvider)
|
||||
{
|
||||
_jobProvider = jobProvider;
|
||||
_sabProvider = sabProvider;
|
||||
|
@ -29,6 +31,7 @@ namespace NzbDrone.Web.Controllers
|
|||
_episodeProvider = episodeProvider;
|
||||
_growlProvider = growlProvider;
|
||||
_seasonProvider = seasonProvider;
|
||||
_prowlProvider = prowlProvider;
|
||||
}
|
||||
|
||||
public JsonResult RssSync()
|
||||
|
@ -126,5 +129,22 @@ namespace NzbDrone.Web.Controllers
|
|||
_episodeProvider.SetEpisodeIgnore(episodeId, ignored);
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
public JsonResult TestProwl(string apiKeys)
|
||||
{
|
||||
_prowlProvider.TestNotification(apiKeys);
|
||||
return JsonNotificationResult.Info("Good News!", "Test message has been sent to Prowl");
|
||||
}
|
||||
|
||||
public JsonResult TestSabnzbd(string host, int port, string apiKey, string username, string password)
|
||||
{
|
||||
//_prowlProvider.TestNotification(apiKeys);
|
||||
var version = _sabProvider.Test(host, port, apiKey, username, password);
|
||||
|
||||
if (String.IsNullOrWhiteSpace(version))
|
||||
return JsonNotificationResult.Oops("Failed to connect to SABnzbd, please check your settings");
|
||||
|
||||
return JsonNotificationResult.Info("Success!", "SABnzbd settings have been verified successfully! Version: " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ $('#SeparatorStyle').live('change', function () { createExamples(); });
|
|||
$('#NumberStyle').live('change', function () { createExamples(); });
|
||||
$('#MultiEpisodeStyle').live('change', function () { createExamples(); });
|
||||
|
||||
var testProwlUrl = '../Command/TestProwl';
|
||||
var testSabUrl = '../Command/TestSabnzbd';
|
||||
|
||||
|
||||
function createExamples() {
|
||||
createSingleEpisodeExample();
|
||||
createMultiEpisodeExample();
|
||||
|
@ -101,4 +105,32 @@ function createMultiEpisodeExample() {
|
|||
result = result.replace(/\s/g, '.');
|
||||
|
||||
$('#multiEpisodeExample').children('.result').text(result);
|
||||
}
|
||||
|
||||
function testProwl(event) {
|
||||
var apiKeys = $('#ProwlApiKeys').val();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: testProwlUrl,
|
||||
data: jQuery.param({ apiKeys: apiKeys })
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
function testSabnzbd(event) {
|
||||
var host = $('#SabHost').val();
|
||||
var port = $('#SabPort').val();
|
||||
var apiKey = $('#SabApiKey').val();
|
||||
var username = $('#SabUsername').val();
|
||||
var password = $('#SabPassword').val();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: testSabUrl,
|
||||
data: jQuery.param({ host: host, port: port, apiKey: apiKey, username: username, password: password })
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
}
|
|
@ -31,4 +31,9 @@
|
|||
<span class="small">@Html.DescriptionFor(m => m.ProwlPriority)</span>
|
||||
</label>
|
||||
@Html.DropDownListFor(m => m.ProwlPriority, Model.ProwlPrioritySelectList, new { @class = "inputClass selectClass" })
|
||||
|
||||
<label class="labelClass">Test Prowl
|
||||
<span class="small">Test Prowl by sending a message to your client(s)</span>
|
||||
</label>
|
||||
<input type="button" onclick="testProwl();" value="Test" class="inputClass" />
|
||||
</div>
|
|
@ -50,5 +50,8 @@
|
|||
</label>
|
||||
@Html.DropDownListFor(m => m.SabTvPriority, Model.PrioritySelectList, new { @class = "inputClass selectClass" })
|
||||
|
||||
|
||||
<label class="labelClass">Test SABnzbd
|
||||
<span class="small">Test SABnzbd settings</span>
|
||||
</label>
|
||||
<input type="button" onclick="testSabnzbd();" value="Test" class="inputClass" />
|
||||
</div>
|
Loading…
Reference in New Issue