Merge fdd4a6c632
into 0b88976ce0
This commit is contained in:
commit
33785706ca
|
@ -5,6 +5,7 @@ using Moq;
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -62,6 +63,60 @@ namespace NzbDrone.Core.Test.ProviderTests
|
|||
Mocker.GetMock<ExternalNotificationProvider>()
|
||||
.Setup(c => c.OnGrab(It.IsAny<string>()));
|
||||
|
||||
Mocker.GetMock<ConfigProvider>()
|
||||
.Setup(c => c.DownloadClient)
|
||||
.Returns(DownloadClientType.Sabnzbd);
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_report_should_download_nzb_add_to_history_mark_as_grabbed()
|
||||
{
|
||||
WithStrictMocker();
|
||||
var parseResult = Builder<EpisodeParseResult>.CreateNew()
|
||||
.With(c => c.Quality = new Quality(QualityTypes.DVD, false))
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.EpisodeId = 12)
|
||||
.TheNext(1).With(s => s.EpisodeId = 99)
|
||||
.All().With(s => s.SeriesId = 5)
|
||||
.Build();
|
||||
|
||||
|
||||
const string sabTitle = "My fake sab title";
|
||||
Mocker.GetMock<BlackholeProvider>()
|
||||
.Setup(s => s.DownloadNzb(It.IsAny<EpisodeParseResult>(), sabTitle))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<SabProvider>()
|
||||
.Setup(s => s.GetSabTitle(parseResult))
|
||||
.Returns(sabTitle);
|
||||
|
||||
Mocker.GetMock<HistoryProvider>()
|
||||
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 12 && h.SeriesId == 5)));
|
||||
Mocker.GetMock<HistoryProvider>()
|
||||
.Setup(s => s.Add(It.Is<History>(h => h.EpisodeId == 99 && h.SeriesId == 5)));
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.MarkEpisodeAsFetched(12));
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.MarkEpisodeAsFetched(99));
|
||||
|
||||
Mocker.GetMock<ExternalNotificationProvider>()
|
||||
.Setup(c => c.OnGrab(It.IsAny<string>()));
|
||||
|
||||
Mocker.GetMock<ConfigProvider>()
|
||||
.Setup(c => c.DownloadClient)
|
||||
.Returns(DownloadClientType.Blackhole);
|
||||
|
||||
Mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
namespace NzbDrone.Core.Model
|
||||
{
|
||||
public enum DownloadClientType
|
||||
{
|
||||
Sabnzbd = 0,
|
||||
Blackhole = 1
|
||||
}
|
||||
}
|
|
@ -228,6 +228,7 @@
|
|||
<Compile Include="Helpers\SortHelper.cs" />
|
||||
<Compile Include="Helpers\SabnzbdQueueTimeConverter.cs" />
|
||||
<Compile Include="Jobs\CheckpointJob.cs" />
|
||||
<Compile Include="Model\DownloadClientType.cs" />
|
||||
<Compile Include="Providers\AnalyticsProvider.cs" />
|
||||
<Compile Include="Instrumentation\LogDbContext.cs" />
|
||||
<Compile Include="Instrumentation\LogProvider.cs" />
|
||||
|
@ -258,6 +259,7 @@
|
|||
<Compile Include="Model\Xbmc\ErrorResult.cs" />
|
||||
<Compile Include="Model\Xbmc\IconType.cs" />
|
||||
<Compile Include="Providers\BackupProvider.cs" />
|
||||
<Compile Include="Providers\BlackholeProvider.cs" />
|
||||
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
|
||||
<Compile Include="Providers\Converting\HandbrakeProvider.cs" />
|
||||
<Compile Include="Providers\Indexer\Newznab.cs" />
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class BlackholeProvider
|
||||
{
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public BlackholeProvider(ConfigProvider configProvider, HttpProvider httpProvider,
|
||||
DiskProvider diskProvider)
|
||||
{
|
||||
_configProvider = configProvider;
|
||||
_httpProvider = httpProvider;
|
||||
_diskProvider = diskProvider;
|
||||
}
|
||||
|
||||
public BlackholeProvider()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool DownloadNzb(EpisodeParseResult parseResult, string title)
|
||||
{
|
||||
try
|
||||
{
|
||||
var filename = Path.Combine(_configProvider.BlackholeDirectory, title, ".nzb");
|
||||
|
||||
if(_diskProvider.FileExists(filename))
|
||||
{
|
||||
//Return true so a lesser quality is not returned.
|
||||
Logger.Info("NZB already exists on disk: {0)", filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
Logger.Trace("Downloading NZB from: {0} to: {1}", parseResult.NzbUrl, filename);
|
||||
_httpProvider.DownloadFile(parseResult.NzbUrl, filename);
|
||||
|
||||
Logger.Trace("NZB Download succeeded, saved to: {0}", filename);
|
||||
return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Logger.WarnException("Failed to download NZB: " + parseResult.NzbUrl, ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -409,6 +409,19 @@ namespace NzbDrone.Core.Providers.Core
|
|||
set { SetValue("AutoIgnorePreviouslyDownloadedEpisodes", value); }
|
||||
}
|
||||
|
||||
public virtual DownloadClientType DownloadClient
|
||||
{
|
||||
get { return (DownloadClientType)GetValueInt("DownloadClient"); }
|
||||
|
||||
set { SetValue("DownloadClient", (int)value); }
|
||||
}
|
||||
|
||||
public virtual string BlackholeDirectory
|
||||
{
|
||||
get { return GetValue("BlackholeDirectory", String.Empty); }
|
||||
set { SetValue("BlackholeDirectory", value); }
|
||||
}
|
||||
|
||||
public string UGuid
|
||||
{
|
||||
get { return GetValue("UGuid", Guid.NewGuid().ToString(), persist: true); }
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
|
@ -12,17 +13,22 @@ namespace NzbDrone.Core.Providers
|
|||
private readonly HistoryProvider _historyProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly BlackholeProvider _blackholeProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public DownloadProvider(SabProvider sabProvider, HistoryProvider historyProvider,
|
||||
EpisodeProvider episodeProvider, ExternalNotificationProvider externalNotificationProvider)
|
||||
EpisodeProvider episodeProvider, ExternalNotificationProvider externalNotificationProvider,
|
||||
ConfigProvider configProvider, BlackholeProvider blackholeProvider)
|
||||
{
|
||||
_sabProvider = sabProvider;
|
||||
_historyProvider = historyProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_configProvider = configProvider;
|
||||
_blackholeProvider = blackholeProvider;
|
||||
}
|
||||
|
||||
public DownloadProvider()
|
||||
|
@ -31,14 +37,22 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
public virtual bool DownloadReport(EpisodeParseResult parseResult)
|
||||
{
|
||||
if (_sabProvider.IsInQueue(parseResult))
|
||||
{
|
||||
Logger.Warn("Episode {0} is already in sab's queue. skipping.", parseResult);
|
||||
return false;
|
||||
}
|
||||
|
||||
var sabTitle = _sabProvider.GetSabTitle(parseResult);
|
||||
var addSuccess = _sabProvider.AddByUrl(parseResult.NzbUrl, sabTitle);
|
||||
bool addSuccess = false;
|
||||
|
||||
if (_configProvider.DownloadClient == DownloadClientType.Blackhole)
|
||||
addSuccess = _blackholeProvider.DownloadNzb(parseResult, sabTitle);
|
||||
|
||||
if (_configProvider.DownloadClient == DownloadClientType.Sabnzbd)
|
||||
{
|
||||
if(_sabProvider.IsInQueue(parseResult))
|
||||
{
|
||||
Logger.Warn("Episode {0} is already in sab's queue. skipping.", parseResult);
|
||||
return false;
|
||||
}
|
||||
|
||||
addSuccess = _sabProvider.AddByUrl(parseResult.NzbUrl, sabTitle);
|
||||
}
|
||||
|
||||
if (addSuccess)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ using NLog;
|
|||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Providers.ExternalNotification;
|
||||
|
@ -90,12 +91,17 @@ namespace NzbDrone.Web.Controllers
|
|||
});
|
||||
}
|
||||
|
||||
public ActionResult Sabnzbd()
|
||||
public ActionResult DownloadClient()
|
||||
{
|
||||
var tvCategory = _configProvider.SabTvCategory;
|
||||
var tvCategorySelectList = new SelectList(new[] { tvCategory });
|
||||
|
||||
var model = new SabnzbdSettingsModel
|
||||
var downloadClientTypes = new List<KeyValuePair<int, string>>();
|
||||
|
||||
foreach (DownloadClientType downloadClientType in Enum.GetValues(typeof(DownloadClientType)))
|
||||
downloadClientTypes.Add(new KeyValuePair<int, string>((int)downloadClientType, downloadClientType.ToString()));
|
||||
|
||||
var model = new DownloadClientSettingsModel
|
||||
{
|
||||
SabHost = _configProvider.SabHost,
|
||||
SabPort = _configProvider.SabPort,
|
||||
|
@ -104,8 +110,11 @@ namespace NzbDrone.Web.Controllers
|
|||
SabPassword = _configProvider.SabPassword,
|
||||
SabTvCategory = tvCategory,
|
||||
SabTvPriority = _configProvider.SabTvPriority,
|
||||
SabDropDirectory = _configProvider.SabDropDirectory,
|
||||
SabTvCategorySelectList = tvCategorySelectList
|
||||
DownloadClientDropDirectory = _configProvider.SabDropDirectory,
|
||||
SabTvCategorySelectList = tvCategorySelectList,
|
||||
DownloadClient = (int)_configProvider.DownloadClient,
|
||||
BlackholeDirectory = _configProvider.BlackholeDirectory,
|
||||
DownloadClientSelectList = new SelectList(downloadClientTypes, "Key", "Value")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
|
@ -373,11 +382,10 @@ namespace NzbDrone.Web.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult SaveSabnzbd(SabnzbdSettingsModel data)
|
||||
public JsonResult SaveDownloadClient(DownloadClientSettingsModel data)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
||||
_configProvider.SabHost = data.SabHost;
|
||||
_configProvider.SabPort = data.SabPort;
|
||||
_configProvider.SabApiKey = data.SabApiKey;
|
||||
|
@ -385,8 +393,9 @@ namespace NzbDrone.Web.Controllers
|
|||
_configProvider.SabTvCategory = data.SabTvCategory;
|
||||
_configProvider.SabUsername = data.SabUsername;
|
||||
_configProvider.SabTvPriority = data.SabTvPriority;
|
||||
_configProvider.SabDropDirectory = data.SabDropDirectory;
|
||||
|
||||
_configProvider.SabDropDirectory = data.DownloadClientDropDirectory;
|
||||
_configProvider.BlackholeDirectory = data.BlackholeDirectory;
|
||||
_configProvider.DownloadClient = (DownloadClientType)data.DownloadClient;
|
||||
|
||||
return GetSuccessResult();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ using NzbDrone.Core.Model.Sabnzbd;
|
|||
|
||||
namespace NzbDrone.Web.Models
|
||||
{
|
||||
public class SabnzbdSettingsModel
|
||||
public class DownloadClientSettingsModel
|
||||
{
|
||||
public SelectList PrioritySelectList =
|
||||
new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Top"});
|
||||
|
@ -53,11 +53,21 @@ namespace NzbDrone.Web.Models
|
|||
[Description("Priority to use when sending NZBs to SABnzbd")]
|
||||
public SabPriorityType SabTvPriority { get; set; }
|
||||
|
||||
[DisplayName("SABnzbd TV Directory")]
|
||||
[Description("The directory where SABnzbd downloads TV shows to (NzbDrone will sort them for you)")]
|
||||
[DisplayName("Download Client TV Directory")]
|
||||
[Description("The directory where your download client downloads TV shows to (NzbDrone will sort them for you)")]
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string SabDropDirectory { get; set; }
|
||||
public string DownloadClientDropDirectory { get; set; }
|
||||
|
||||
[DisplayName("Blackhole Directory")]
|
||||
[Description("The directory where your download client will pickup NZB files")]
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string BlackholeDirectory { get; set; }
|
||||
|
||||
[DisplayName("Download Client")]
|
||||
[Description("What method do you download NZBs with?")]
|
||||
public int DownloadClient { get; set; }
|
||||
|
||||
public SelectList SabTvCategorySelectList { get; set; }
|
||||
public SelectList DownloadClientSelectList { get; set; }
|
||||
}
|
||||
}
|
|
@ -235,7 +235,7 @@
|
|||
<Compile Include="Models\JsonNotificationResult.cs" />
|
||||
<Compile Include="Models\PendingProcessingModel.cs" />
|
||||
<Compile Include="Models\ProwlPrioritySelectListModel.cs" />
|
||||
<Compile Include="Models\SabnzbdSettingsModel.cs" />
|
||||
<Compile Include="Models\DownloadClientSettingsModel.cs" />
|
||||
<Compile Include="Models\EpisodeNamingModel.cs" />
|
||||
<Compile Include="Models\HistoryModel.cs" />
|
||||
<Compile Include="Models\IndexerSettingsModel.cs" />
|
||||
|
@ -532,6 +532,12 @@
|
|||
<ItemGroup>
|
||||
<Content Include="Views\Series\SeriesItem.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Settings\DownloadClient.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Settings\Blackhole.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
@using NzbDrone.Web.Helpers;
|
||||
@model NzbDrone.Web.Models.DownloadClientSettingsModel
|
||||
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<div class="downloadClient">
|
||||
<label class="labelClass">@Html.LabelFor(m => m.BlackholeDirectory)
|
||||
<span class="small">@Html.DescriptionFor(m => m.BlackholeDirectory)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.BlackholeDirectory, new { @class = "inputClass folderLookup" })
|
||||
</div>
|
|
@ -0,0 +1,127 @@
|
|||
@using NzbDrone.Web.Helpers;
|
||||
@model NzbDrone.Web.Models.DownloadClientSettingsModel
|
||||
@{ Layout = "~/Views/Shared/_ReferenceLayout.cshtml"; }
|
||||
@section HeaderContent{
|
||||
@Html.IncludeCss("Settings.css")
|
||||
<style>
|
||||
.downloadClient
|
||||
{
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.downloadClient h4
|
||||
{
|
||||
font-weight: bold;
|
||||
margin-bottom: 0px;
|
||||
padding-left: 5px;
|
||||
padding-top: 3px;
|
||||
}
|
||||
|
||||
#save_button
|
||||
{
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#downloadClient-top
|
||||
{
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
<div id="stylized">
|
||||
@using (Html.BeginForm("SaveDownloadClient", "Settings", FormMethod.Post, new { id = "DownloadClientForm", name = "DownloadClientForm", @class = "settingsForm" }))
|
||||
{
|
||||
<div id="downloadClient-top" class="settingsForm">
|
||||
<label class="labelClass">@Html.LabelFor(m => m.DownloadClient)
|
||||
<span class="small">@Html.DescriptionFor(m => m.DownloadClient)</span>
|
||||
</label>
|
||||
@Html.DropDownListFor(m => m.DownloadClient, Model.DownloadClientSelectList, new { @class = "inputClass selectClass" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.DownloadClientDropDirectory)
|
||||
<span class="small">@Html.DescriptionFor(m => m.DownloadClientDropDirectory)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.DownloadClientDropDirectory, new { @class = "inputClass folderLookup" })
|
||||
</div>
|
||||
|
||||
<div class="jquery-accordion" id="downloadClientAccordion">
|
||||
<h3>
|
||||
<a href="#">Sabnzbd</a></h3>
|
||||
@{Html.RenderPartial("Sabnzbd", Model);}
|
||||
<h3>
|
||||
<a href="#">Blackhole</a></h3>
|
||||
@{Html.RenderPartial("Blackhole", Model);}
|
||||
</div>
|
||||
|
||||
<button type="submit" class="save_button" disabled="disabled">
|
||||
Save</button>
|
||||
}
|
||||
</div>
|
||||
<div id="result" class="hiddenResult">
|
||||
</div>
|
||||
@section Scripts{
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('#downloadClientAccordion').accordion("activate", false);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var autoConfigureSabUrl = '@Url.Action("AutoConfigureSab", "Settings")';
|
||||
|
||||
function autoConfigureSab() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: autoConfigureSabUrl,
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could not autoconfigure SABnzbd for you");
|
||||
},
|
||||
success: autoConfigureSuccess
|
||||
});
|
||||
|
||||
function autoConfigureSuccess(data) {
|
||||
$('#SabHost').val(data.Host);
|
||||
$('#SabPort').val(data.Port);
|
||||
$('#SabApiKey').val(data.ApiKey);
|
||||
}
|
||||
}
|
||||
var sabCategoryUrl = '../Command/GetSabnzbdCategories';
|
||||
|
||||
$('#SabTvCategory').focus(function () {
|
||||
var host = $('#SabHost').val();
|
||||
var port = $('#SabPort').val();
|
||||
var apiKey = $('#SabApiKey').val();
|
||||
var username = $('#SabUsername').val();
|
||||
var password = $('#SabPassword').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: sabCategoryUrl,
|
||||
data: jQuery.param({ host: host, port: port, apiKey: apiKey, username: username, password: password }),
|
||||
error: function (req, status, error) {
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
$('#SabTvCategory').append($('<option />').val('tv').text('Please check your SABnzbd Settings'));
|
||||
},
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
//Get the current value
|
||||
var currentlySelected = $('#SabTvCategory').val();
|
||||
|
||||
//Remove all existing options
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
//Add the new ones
|
||||
$.each(data.categories, function () {
|
||||
$('#SabTvCategory').append($('<option />').val(this.toString()).text(this.toString()));
|
||||
});
|
||||
|
||||
//Attempt to reset to the preiously selected value (change to lower-case)
|
||||
$("#SabTvCategory").val(currentlySelected.toLowerCase());
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
<li>@Html.ActionLink("Naming", "Naming", "Settings")</li>
|
||||
<li>@Html.ActionLink("Indexers", "Indexers", "Settings")</li>
|
||||
<li>@Html.ActionLink("Quality", "Quality", "Settings")</li>
|
||||
<li>@Html.ActionLink("SABnzbd", "Sabnzbd", "Settings")</li>
|
||||
<li>@Html.ActionLink("Download Client", "DownloadClient", "Settings")</li>
|
||||
<li>@Html.ActionLink("Notifications", "Notifications", "Settings")</li>
|
||||
<li>@Html.ActionLink("System", "System", "Settings")</li>
|
||||
<li>@Html.ActionLink("Misc", "Misc", "Settings")</li>
|
||||
|
|
|
@ -1,124 +1,52 @@
|
|||
@using NzbDrone.Web.Helpers;
|
||||
@model NzbDrone.Web.Models.SabnzbdSettingsModel
|
||||
@{ Layout = "~/Views/Shared/_ReferenceLayout.cshtml"; }
|
||||
@section HeaderContent{
|
||||
@Html.IncludeCss("Settings.css")
|
||||
@model NzbDrone.Web.Models.DownloadClientSettingsModel
|
||||
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
<div id="stylized">
|
||||
@using (Html.BeginForm("SaveSabnzbd", "Settings", FormMethod.Post, new { id = "SabForm", name = "SabForm", @class = "settingsForm" }))
|
||||
{
|
||||
<label class="labelClass">
|
||||
Auto-Configure <span class="small">If access to SABnzbd doesn't require a username +
|
||||
password and is on the same system as NzbDrone, you can auto-configure it</span>
|
||||
</label>
|
||||
<input type="button" onclick="autoConfigureSab(); return false;" value="Auto-Configure"
|
||||
class="inputClass" />
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabHost)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabHost)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabHost, new { @class = "inputClass" })
|
||||
<div class="downloadClient">
|
||||
<label class="labelClass">
|
||||
Auto-Configure <span class="small">If access to SABnzbd doesn't require a username +
|
||||
password and is on the same system as NzbDrone, you can auto-configure it</span>
|
||||
</label>
|
||||
<input type="button" onclick="autoConfigureSab(); return false;" value="Auto-Configure"
|
||||
class="inputClass" />
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabPort)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabPort)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabPort, new { @class = "inputClass" })
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabHost)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabHost)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabHost, new { @class = "inputClass" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabApiKey)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabApiKey)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabApiKey, new { @class = "inputClass" })
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabPort)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabPort)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabPort, new { @class = "inputClass" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabUsername)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabUsername)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabUsername, new { @class = "inputClass" })
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabApiKey)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabApiKey)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabApiKey, new { @class = "inputClass" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabPassword)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabPassword)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabPassword, new { @class = "inputClass", type = "password" })
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabUsername)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabUsername)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabUsername, new { @class = "inputClass" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabTvCategory)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabTvCategory)</span>
|
||||
</label>
|
||||
@Html.DropDownListFor(m => m.SabTvCategory, Model.SabTvCategorySelectList, new { @class = "inputClass selectClass" })
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabPassword)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabPassword)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabPassword, new { @class = "inputClass", type = "password" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabTvPriority)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabTvPriority)</span>
|
||||
</label>
|
||||
@Html.DropDownListFor(m => m.SabTvPriority, Model.PrioritySelectList, new { @class = "inputClass selectClass" })
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabTvCategory)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabTvCategory)</span>
|
||||
</label>
|
||||
@Html.DropDownListFor(m => m.SabTvCategory, Model.SabTvCategorySelectList, new { @class = "inputClass selectClass" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabDropDirectory)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabDropDirectory)</span>
|
||||
</label>
|
||||
@Html.TextBoxFor(m => m.SabDropDirectory, new { @class = "inputClass folderLookup" })
|
||||
<label class="labelClass">@Html.LabelFor(m => m.SabTvPriority)
|
||||
<span class="small">@Html.DescriptionFor(m => m.SabTvPriority)</span>
|
||||
</label>
|
||||
@Html.DropDownListFor(m => m.SabTvPriority, Model.PrioritySelectList, new { @class = "inputClass selectClass" })
|
||||
|
||||
<button type="submit" class="save_button" disabled="disabled">
|
||||
Save</button>
|
||||
}
|
||||
</div>
|
||||
<div id="result" class="hiddenResult">
|
||||
</div>
|
||||
@section Scripts{
|
||||
|
||||
<script type="text/javascript">
|
||||
var autoConfigureSabUrl = '@Url.Action("AutoConfigureSab", "Settings")';
|
||||
|
||||
function autoConfigureSab() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: autoConfigureSabUrl,
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could not autoconfigure SABnzbd for you");
|
||||
},
|
||||
success: autoConfigureSuccess
|
||||
});
|
||||
|
||||
function autoConfigureSuccess(data) {
|
||||
$('#SabHost').val(data.Host);
|
||||
$('#SabPort').val(data.Port);
|
||||
$('#SabApiKey').val(data.ApiKey);
|
||||
}
|
||||
}
|
||||
var sabCategoryUrl = '../Command/GetSabnzbdCategories';
|
||||
|
||||
$('#SabTvCategory').focus(function () {
|
||||
var host = $('#SabHost').val();
|
||||
var port = $('#SabPort').val();
|
||||
var apiKey = $('#SabApiKey').val();
|
||||
var username = $('#SabUsername').val();
|
||||
var password = $('#SabPassword').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: sabCategoryUrl,
|
||||
data: jQuery.param({ host: host, port: port, apiKey: apiKey, username: username, password: password }),
|
||||
error: function (req, status, error) {
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
$('#SabTvCategory').append($('<option />').val('tv').text('Please check your SABnzbd Settings'));
|
||||
},
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
//Get the current value
|
||||
var currentlySelected = $('#SabTvCategory').val();
|
||||
|
||||
//Remove all existing options
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
//Add the new ones
|
||||
$.each(data.categories, function () {
|
||||
$('#SabTvCategory').append($('<option />').val(this.toString()).text(this.toString()));
|
||||
});
|
||||
|
||||
//Attempt to reset to the preiously selected value (change to lower-case)
|
||||
$("#SabTvCategory").val(currentlySelected.toLowerCase());
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue