2010-09-23 03:19:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-05-14 07:49:57 +00:00
|
|
|
|
using System.IO;
|
2010-09-23 03:19:47 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web.Mvc;
|
2011-01-29 06:10:22 +00:00
|
|
|
|
using NLog;
|
2011-03-03 08:50:33 +00:00
|
|
|
|
using NzbDrone.Core.Helpers;
|
2011-02-11 01:22:29 +00:00
|
|
|
|
using NzbDrone.Core.Model;
|
2011-05-13 04:46:26 +00:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
2011-02-05 06:07:25 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-04-04 03:50:12 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-04-19 00:12:06 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Indexer;
|
2011-03-09 07:40:48 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-02-05 06:07:25 +00:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2010-09-24 05:21:45 +00:00
|
|
|
|
using NzbDrone.Web.Models;
|
2010-09-23 03:19:47 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
2010-10-08 03:35:04 +00:00
|
|
|
|
[HandleError]
|
2010-09-23 03:19:47 +00:00
|
|
|
|
public class SettingsController : Controller
|
|
|
|
|
{
|
2011-03-28 21:57:06 +00:00
|
|
|
|
private const string SETTINGS_SAVED = "Settings Saved.";
|
|
|
|
|
private const string SETTINGS_FAILED = "Error Saving Settings, please fix any errors";
|
2011-04-10 02:44:01 +00:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
private readonly ConfigProvider _configProvider;
|
|
|
|
|
private readonly IndexerProvider _indexerProvider;
|
|
|
|
|
private readonly QualityProvider _qualityProvider;
|
|
|
|
|
private readonly RootDirProvider _rootDirProvider;
|
2011-04-25 07:42:29 +00:00
|
|
|
|
private readonly AutoConfigureProvider _autoConfigureProvider;
|
2011-05-13 04:46:26 +00:00
|
|
|
|
private readonly NotificationProvider _notificationProvider;
|
2011-05-14 07:49:57 +00:00
|
|
|
|
private readonly DiskProvider _diskProvider;
|
2011-05-29 04:07:11 +00:00
|
|
|
|
private readonly SeriesProvider _seriesProvider;
|
2010-09-24 05:21:45 +00:00
|
|
|
|
|
2011-04-10 01:34:36 +00:00
|
|
|
|
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
|
2011-04-25 07:42:29 +00:00
|
|
|
|
QualityProvider qualityProvider, RootDirProvider rootDirProvider,
|
2011-05-14 07:49:57 +00:00
|
|
|
|
AutoConfigureProvider autoConfigureProvider, NotificationProvider notificationProvider,
|
2011-05-29 04:07:11 +00:00
|
|
|
|
DiskProvider diskProvider, SeriesProvider seriesProvider)
|
2010-09-24 05:21:45 +00:00
|
|
|
|
{
|
2010-09-28 04:25:41 +00:00
|
|
|
|
_configProvider = configProvider;
|
2011-01-29 06:10:22 +00:00
|
|
|
|
_indexerProvider = indexerProvider;
|
2011-02-03 02:49:52 +00:00
|
|
|
|
_qualityProvider = qualityProvider;
|
2011-03-09 07:40:48 +00:00
|
|
|
|
_rootDirProvider = rootDirProvider;
|
2011-04-25 07:42:29 +00:00
|
|
|
|
_autoConfigureProvider = autoConfigureProvider;
|
2011-05-13 04:46:26 +00:00
|
|
|
|
_notificationProvider = notificationProvider;
|
2011-05-14 07:49:57 +00:00
|
|
|
|
_diskProvider = diskProvider;
|
2011-05-29 04:07:11 +00:00
|
|
|
|
_seriesProvider = seriesProvider;
|
2010-09-24 05:21:45 +00:00
|
|
|
|
}
|
2010-09-23 03:19:47 +00:00
|
|
|
|
|
2011-05-16 06:27:02 +00:00
|
|
|
|
public ActionResult Test()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult TestPartial()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-29 06:10:22 +00:00
|
|
|
|
public ActionResult Index(string viewName)
|
2010-09-23 03:19:47 +00:00
|
|
|
|
{
|
2011-01-29 06:10:22 +00:00
|
|
|
|
if (viewName != null)
|
|
|
|
|
ViewData["viewName"] = viewName;
|
|
|
|
|
|
|
|
|
|
else
|
2011-03-09 07:40:48 +00:00
|
|
|
|
return RedirectToAction("General");
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-03-09 07:40:48 +00:00
|
|
|
|
return View("Index");
|
2011-01-29 06:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult General()
|
|
|
|
|
{
|
|
|
|
|
ViewData["viewName"] = "General";
|
2011-03-28 21:57:06 +00:00
|
|
|
|
|
2011-01-29 06:10:22 +00:00
|
|
|
|
return View("Index", new SettingsModel
|
|
|
|
|
{
|
2011-03-28 21:57:06 +00:00
|
|
|
|
Directories = _rootDirProvider.GetAll()
|
2011-01-29 06:10:22 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Indexers()
|
|
|
|
|
{
|
|
|
|
|
ViewData["viewName"] = "Indexers";
|
2011-04-19 23:46:21 +00:00
|
|
|
|
|
2011-02-11 01:22:29 +00:00
|
|
|
|
return View("Index", new IndexerSettingsModel
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
2011-04-25 19:02:29 +00:00
|
|
|
|
NzbMatrixUsername = _configProvider.NzbMatrixUsername,
|
|
|
|
|
NzbMatrixApiKey = _configProvider.NzbMatrixApiKey,
|
2011-04-19 00:12:06 +00:00
|
|
|
|
|
2011-04-22 17:09:06 +00:00
|
|
|
|
NzbsrusUId = _configProvider.NzbsrusUId,
|
|
|
|
|
NzbsrusHash = _configProvider.NzbsrusHash,
|
2011-04-19 00:12:06 +00:00
|
|
|
|
|
2011-04-22 17:09:06 +00:00
|
|
|
|
NzbsOrgHash = _configProvider.NzbsOrgHash,
|
|
|
|
|
NzbsOrgUId = _configProvider.NzbsOrgUId,
|
2011-04-19 00:12:06 +00:00
|
|
|
|
|
2011-04-19 23:46:21 +00:00
|
|
|
|
NewzbinUsername = _configProvider.NewzbinUsername,
|
|
|
|
|
NewzbinPassword = _configProvider.NewzbinPassword,
|
2011-04-19 00:12:06 +00:00
|
|
|
|
|
2011-05-20 04:21:18 +00:00
|
|
|
|
NzbsOrgEnabled = _indexerProvider.GetSettings(typeof(NzbsOrg)).Enable,
|
|
|
|
|
NzbMatrixEnabled = _indexerProvider.GetSettings(typeof(NzbMatrix)).Enable,
|
|
|
|
|
NzbsRUsEnabled = _indexerProvider.GetSettings(typeof(NzbsRUs)).Enable,
|
|
|
|
|
NewzbinEnabled = _indexerProvider.GetSettings(typeof(Newzbin)).Enable
|
2011-01-29 06:10:22 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-18 03:39:26 +00:00
|
|
|
|
public ActionResult Sabnzbd()
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
2011-05-18 03:39:26 +00:00
|
|
|
|
ViewData["viewName"] = "Sabnzbd";
|
2011-02-11 01:22:29 +00:00
|
|
|
|
|
2011-05-18 03:39:26 +00:00
|
|
|
|
var model = new SabnzbdSettingsModel
|
2011-02-11 01:22:29 +00:00
|
|
|
|
{
|
2011-04-25 19:02:29 +00:00
|
|
|
|
SabHost = _configProvider.SabHost,
|
2011-05-16 07:32:01 +00:00
|
|
|
|
SabPort =_configProvider.SabPort,
|
2011-04-25 19:02:29 +00:00
|
|
|
|
SabApiKey = _configProvider.SabApiKey,
|
|
|
|
|
SabUsername = _configProvider.SabUsername,
|
|
|
|
|
SabPassword = _configProvider.SabPassword,
|
|
|
|
|
SabTvCategory = _configProvider.SabTvCategory,
|
2011-05-16 07:32:01 +00:00
|
|
|
|
SabTvPriority = _configProvider.SabTvPriority,
|
2011-02-11 01:22:29 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return View("Index", model);
|
2011-01-29 06:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-03 02:49:52 +00:00
|
|
|
|
public ActionResult Quality()
|
|
|
|
|
{
|
2011-02-03 18:28:14 +00:00
|
|
|
|
ViewData["viewName"] = "Quality";
|
2011-02-03 02:49:52 +00:00
|
|
|
|
|
2011-02-05 06:07:25 +00:00
|
|
|
|
var qualityTypes = new List<QualityTypes>();
|
2011-02-03 02:49:52 +00:00
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
2011-02-05 06:07:25 +00:00
|
|
|
|
{
|
|
|
|
|
qualityTypes.Add(qual);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-06 02:52:49 +00:00
|
|
|
|
ViewData["Qualities"] = qualityTypes;
|
|
|
|
|
|
|
|
|
|
var profiles = _qualityProvider.GetAllProfiles().ToList();
|
2011-05-18 03:39:26 +00:00
|
|
|
|
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile);
|
2011-05-29 08:59:25 +00:00
|
|
|
|
var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name");
|
2011-02-05 06:07:25 +00:00
|
|
|
|
|
|
|
|
|
var model = new QualityModel
|
2011-04-10 02:44:01 +00:00
|
|
|
|
{
|
|
|
|
|
Profiles = profiles,
|
|
|
|
|
DefaultQualityProfileId = defaultQualityQualityProfileId,
|
2011-05-29 08:59:25 +00:00
|
|
|
|
QualityProfileSelectList = qualityProfileSelectList
|
2011-04-10 02:44:01 +00:00
|
|
|
|
};
|
2011-02-03 02:49:52 +00:00
|
|
|
|
|
|
|
|
|
return View("Index", model);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 07:32:36 +00:00
|
|
|
|
public ActionResult Notifications()
|
|
|
|
|
{
|
|
|
|
|
ViewData["viewName"] = "Notifications";
|
|
|
|
|
|
|
|
|
|
var model = new NotificationSettingsModel
|
2011-04-10 02:44:01 +00:00
|
|
|
|
{
|
|
|
|
|
XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)),
|
2011-04-25 19:02:29 +00:00
|
|
|
|
XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)),
|
|
|
|
|
XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)),
|
|
|
|
|
XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)),
|
|
|
|
|
XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)),
|
2011-04-10 02:44:01 +00:00
|
|
|
|
XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)),
|
2011-04-25 19:02:29 +00:00
|
|
|
|
XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)),
|
|
|
|
|
XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)),
|
|
|
|
|
XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)),
|
|
|
|
|
XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)),
|
|
|
|
|
XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)),
|
2011-04-10 02:44:01 +00:00
|
|
|
|
XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true),
|
|
|
|
|
XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true),
|
|
|
|
|
XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true)
|
|
|
|
|
};
|
2011-03-07 07:32:36 +00:00
|
|
|
|
|
|
|
|
|
return View("Index", model);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-26 04:07:22 +00:00
|
|
|
|
public ActionResult EpisodeSorting()
|
|
|
|
|
{
|
|
|
|
|
ViewData["viewName"] = "EpisodeSorting";
|
|
|
|
|
|
|
|
|
|
var model = new EpisodeSortingModel();
|
|
|
|
|
|
2011-05-18 23:10:25 +00:00
|
|
|
|
model.SeriesName = _configProvider.SeriesName;
|
|
|
|
|
model.EpisodeName = _configProvider.EpisodeName;
|
|
|
|
|
model.ReplaceSpaces = _configProvider.ReplaceSpaces;
|
|
|
|
|
model.AppendQuality = _configProvider.AppendQuality;
|
2011-04-01 06:36:34 +00:00
|
|
|
|
model.SeasonFolders = _configProvider.UseSeasonFolder;
|
2011-05-18 23:10:25 +00:00
|
|
|
|
model.SeasonFolderFormat = _configProvider.SeasonFolderFormat;
|
|
|
|
|
model.SeparatorStyle = _configProvider.SeparatorStyle;
|
|
|
|
|
model.NumberStyle = _configProvider.NumberStyle;
|
|
|
|
|
model.MultiEpisodeStyle = _configProvider.MultiEpisodeStyle;
|
2011-02-26 04:07:22 +00:00
|
|
|
|
|
|
|
|
|
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
|
|
|
|
|
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
|
|
|
|
|
model.MultiEpisodeStyles = new SelectList(EpisodeSortingHelper.GetMultiEpisodeStyles(), "Id", "Name");
|
|
|
|
|
|
|
|
|
|
return View("Index", model);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 04:07:11 +00:00
|
|
|
|
public ViewResult AddProfile()
|
2011-02-05 18:27:14 +00:00
|
|
|
|
{
|
2011-02-06 07:13:17 +00:00
|
|
|
|
var qualityTypes = new List<QualityTypes>();
|
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
2011-02-06 07:13:17 +00:00
|
|
|
|
{
|
|
|
|
|
qualityTypes.Add(qual);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 22:44:05 +00:00
|
|
|
|
ViewData["Qualities"] = qualityTypes;
|
2011-02-06 07:13:17 +00:00
|
|
|
|
|
2011-04-22 00:30:19 +00:00
|
|
|
|
var qualityProfile = new QualityProfile
|
|
|
|
|
{
|
|
|
|
|
Name = "New Profile",
|
2011-04-22 17:09:06 +00:00
|
|
|
|
Allowed = new List<QualityTypes> { QualityTypes.Unknown },
|
2011-04-22 00:30:19 +00:00
|
|
|
|
Cutoff = QualityTypes.Unknown,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var id = _qualityProvider.Add(qualityProfile);
|
|
|
|
|
qualityProfile.QualityProfileId = id;
|
|
|
|
|
|
|
|
|
|
ViewData["ProfileId"] = id;
|
|
|
|
|
|
2011-05-29 04:07:11 +00:00
|
|
|
|
return View("QualityProfileItem", qualityProfile);
|
2011-04-22 00:30:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult GetQualityProfileView(QualityProfile profile)
|
|
|
|
|
{
|
|
|
|
|
var qualityTypes = new List<QualityTypes>();
|
|
|
|
|
|
|
|
|
|
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
|
|
|
|
{
|
|
|
|
|
qualityTypes.Add(qual);
|
|
|
|
|
}
|
2011-05-29 08:59:25 +00:00
|
|
|
|
|
2011-04-22 00:30:19 +00:00
|
|
|
|
ViewData["Qualities"] = qualityTypes;
|
|
|
|
|
ViewData["ProfileId"] = profile.QualityProfileId;
|
|
|
|
|
|
2011-05-29 04:07:11 +00:00
|
|
|
|
return PartialView("QualityProfileItem", profile);
|
2011-02-05 18:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-09 07:40:48 +00:00
|
|
|
|
public ViewResult AddRootDir()
|
|
|
|
|
{
|
2011-04-27 15:34:53 +00:00
|
|
|
|
var rootDir = new RootDir { Path = String.Empty };
|
|
|
|
|
|
|
|
|
|
var id = _rootDirProvider.Add(rootDir);
|
|
|
|
|
rootDir.Id = id;
|
|
|
|
|
|
|
|
|
|
ViewData["RootDirId"] = id;
|
|
|
|
|
|
|
|
|
|
return View("RootDir", rootDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult GetRootDirView(RootDir rootDir)
|
|
|
|
|
{
|
|
|
|
|
ViewData["RootDirId"] = rootDir.Id;
|
|
|
|
|
|
|
|
|
|
return PartialView("RootDir", rootDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult DeleteRootDir(int rootDirId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_rootDirProvider.Remove(rootDirId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return new JsonResult { Data = "failed" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new JsonResult { Data = "ok" };
|
2011-03-09 07:40:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-29 06:10:22 +00:00
|
|
|
|
public ActionResult SubMenu()
|
|
|
|
|
{
|
|
|
|
|
return PartialView();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-12 06:10:38 +00:00
|
|
|
|
public QualityModel GetUpdatedProfileList()
|
|
|
|
|
{
|
|
|
|
|
var profiles = _qualityProvider.GetAllProfiles().ToList();
|
2011-04-10 02:44:01 +00:00
|
|
|
|
var defaultQualityQualityProfileId =
|
|
|
|
|
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
|
2011-02-17 17:45:02 +00:00
|
|
|
|
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
|
2011-02-16 04:44:19 +00:00
|
|
|
|
|
2011-05-29 08:59:25 +00:00
|
|
|
|
return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList };
|
2011-02-12 06:10:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-22 00:30:19 +00:00
|
|
|
|
public JsonResult DeleteQualityProfile(int profileId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2011-05-29 04:07:11 +00:00
|
|
|
|
if (_seriesProvider.GetAllSeries().Where(s => s.QualityProfileId == profileId).Count() != 0)
|
|
|
|
|
return new JsonResult { Data = "Unable to delete Profile, it is still in use." };
|
|
|
|
|
|
2011-04-22 00:30:19 +00:00
|
|
|
|
_qualityProvider.Delete(profileId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return new JsonResult { Data = "failed" };
|
|
|
|
|
}
|
2011-04-22 17:09:06 +00:00
|
|
|
|
|
2011-04-22 00:30:19 +00:00
|
|
|
|
return new JsonResult { Data = "ok" };
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-11 06:46:26 +00:00
|
|
|
|
public JsonResult AutoConfigureSab()
|
2011-04-25 07:42:29 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2011-05-11 06:46:26 +00:00
|
|
|
|
var info = _autoConfigureProvider.AutoConfigureSab();
|
|
|
|
|
return Json(info, JsonRequestBehavior.AllowGet);
|
2011-04-25 07:42:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return new JsonResult { Data = "failed" };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-14 07:49:57 +00:00
|
|
|
|
public JsonResult JsonAutoCompletePath(string term)
|
|
|
|
|
{
|
|
|
|
|
var windowsSep = term.LastIndexOf('\\');
|
|
|
|
|
|
|
|
|
|
if (windowsSep > -1)
|
|
|
|
|
{
|
|
|
|
|
var start = term.Substring(windowsSep + 1);
|
|
|
|
|
var dirs = _diskProvider.GetDirectories(term.Substring(0, windowsSep + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10);
|
|
|
|
|
return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var index = term.LastIndexOf('/');
|
|
|
|
|
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
var start = term.Substring(index + 1);
|
|
|
|
|
var dirs = _diskProvider.GetDirectories(term.Substring(0, index + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10);
|
|
|
|
|
return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Json(new JsonResult(), JsonRequestBehavior.AllowGet);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-29 06:10:22 +00:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SaveGeneral(SettingsModel data)
|
|
|
|
|
{
|
2011-05-13 04:46:26 +00:00
|
|
|
|
var basicNotification = new BasicNotification();
|
|
|
|
|
basicNotification.Type = BasicNotificationType.Info;
|
|
|
|
|
basicNotification.AutoDismiss = true;
|
|
|
|
|
|
2011-04-27 15:34:53 +00:00
|
|
|
|
try
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
2011-03-09 07:40:48 +00:00
|
|
|
|
foreach (var dir in data.Directories)
|
|
|
|
|
{
|
2011-04-27 15:34:53 +00:00
|
|
|
|
_rootDirProvider.Update(dir);
|
2011-03-09 07:40:48 +00:00
|
|
|
|
}
|
2011-04-27 15:34:53 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.Debug("Failed to save Root Dirs");
|
|
|
|
|
Logger.DebugException(ex.Message, ex);
|
2011-05-13 04:46:26 +00:00
|
|
|
|
|
|
|
|
|
basicNotification.Title = SETTINGS_FAILED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-04-27 15:34:53 +00:00
|
|
|
|
return Content(SETTINGS_FAILED);
|
2011-01-29 06:10:22 +00:00
|
|
|
|
}
|
2011-02-11 01:22:29 +00:00
|
|
|
|
|
2011-05-16 07:32:01 +00:00
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_SAVED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
|
|
|
|
|
2011-04-27 15:34:53 +00:00
|
|
|
|
return Content(SETTINGS_SAVED);
|
2010-09-24 05:21:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
2011-02-11 01:22:29 +00:00
|
|
|
|
public ActionResult SaveIndexers(IndexerSettingsModel data)
|
2010-09-24 05:21:45 +00:00
|
|
|
|
{
|
2011-05-13 04:46:26 +00:00
|
|
|
|
var basicNotification = new BasicNotification();
|
|
|
|
|
basicNotification.Type = BasicNotificationType.Info;
|
|
|
|
|
basicNotification.AutoDismiss = true;
|
|
|
|
|
|
2011-02-15 01:20:17 +00:00
|
|
|
|
if (ModelState.IsValid)
|
2010-09-24 05:21:45 +00:00
|
|
|
|
{
|
2011-05-20 04:21:18 +00:00
|
|
|
|
var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrg));
|
2011-04-19 23:46:21 +00:00
|
|
|
|
nzbsOrgSettings.Enable = data.NzbsOrgEnabled;
|
|
|
|
|
_indexerProvider.SaveSettings(nzbsOrgSettings);
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-05-20 04:21:18 +00:00
|
|
|
|
var nzbMatrixSettings = _indexerProvider.GetSettings(typeof(NzbMatrix));
|
2011-04-19 23:46:21 +00:00
|
|
|
|
nzbMatrixSettings.Enable = data.NzbMatrixEnabled;
|
|
|
|
|
_indexerProvider.SaveSettings(nzbMatrixSettings);
|
|
|
|
|
|
2011-05-20 04:21:18 +00:00
|
|
|
|
var nzbsRUsSettings = _indexerProvider.GetSettings(typeof(NzbsRUs));
|
2011-04-19 23:46:21 +00:00
|
|
|
|
nzbsRUsSettings.Enable = data.NzbsRUsEnabled;
|
|
|
|
|
_indexerProvider.SaveSettings(nzbsRUsSettings);
|
|
|
|
|
|
2011-05-20 04:21:18 +00:00
|
|
|
|
var newzbinSettings = _indexerProvider.GetSettings(typeof(Newzbin));
|
2011-04-19 23:46:21 +00:00
|
|
|
|
newzbinSettings.Enable = data.NewzbinEnabled;
|
|
|
|
|
_indexerProvider.SaveSettings(newzbinSettings);
|
2011-01-31 01:30:59 +00:00
|
|
|
|
|
2011-04-19 00:12:06 +00:00
|
|
|
|
_configProvider.NzbsOrgUId = data.NzbsOrgUId;
|
2011-04-22 17:09:06 +00:00
|
|
|
|
_configProvider.NzbsOrgHash = data.NzbsOrgHash;
|
2011-04-19 00:12:06 +00:00
|
|
|
|
|
2011-04-19 23:46:21 +00:00
|
|
|
|
_configProvider.NzbMatrixUsername = data.NzbMatrixUsername;
|
|
|
|
|
_configProvider.NzbMatrixApiKey = data.NzbMatrixApiKey;
|
|
|
|
|
|
|
|
|
|
_configProvider.NzbsrusUId = data.NzbsrusUId;
|
2011-04-22 17:09:06 +00:00
|
|
|
|
_configProvider.NzbsrusHash = data.NzbsrusHash;
|
2011-04-19 23:46:21 +00:00
|
|
|
|
|
|
|
|
|
_configProvider.NewzbinUsername = data.NewzbinUsername;
|
|
|
|
|
_configProvider.NewzbinPassword = data.NewzbinPassword;
|
2011-04-19 00:12:06 +00:00
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_SAVED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_SAVED);
|
2011-01-29 06:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_FAILED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_FAILED);
|
2010-09-23 03:19:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-29 06:10:22 +00:00
|
|
|
|
[HttpPost]
|
2011-05-18 03:39:26 +00:00
|
|
|
|
public ActionResult SaveSabnzbd(SabnzbdSettingsModel data)
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
2011-05-13 04:46:26 +00:00
|
|
|
|
var basicNotification = new BasicNotification();
|
|
|
|
|
basicNotification.Type = BasicNotificationType.Info;
|
|
|
|
|
basicNotification.AutoDismiss = true;
|
|
|
|
|
|
2011-02-11 01:22:29 +00:00
|
|
|
|
if (ModelState.IsValid)
|
2011-01-29 06:10:22 +00:00
|
|
|
|
{
|
2011-03-31 01:42:27 +00:00
|
|
|
|
_configProvider.SabHost = data.SabHost;
|
2011-05-16 07:32:01 +00:00
|
|
|
|
_configProvider.SabPort = data.SabPort;
|
2011-03-31 01:42:27 +00:00
|
|
|
|
_configProvider.SabApiKey = data.SabApiKey;
|
|
|
|
|
_configProvider.SabPassword = data.SabPassword;
|
|
|
|
|
_configProvider.SabTvCategory = data.SabTvCategory;
|
|
|
|
|
_configProvider.SabUsername = data.SabUsername;
|
2011-05-16 07:32:01 +00:00
|
|
|
|
_configProvider.SabTvPriority = data.SabTvPriority;
|
2011-01-29 06:10:22 +00:00
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_SAVED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-11 01:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_FAILED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_FAILED);
|
2011-01-29 06:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-04 02:58:02 +00:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SaveQuality(QualityModel data)
|
|
|
|
|
{
|
2011-05-13 04:46:26 +00:00
|
|
|
|
var basicNotification = new BasicNotification();
|
|
|
|
|
basicNotification.Type = BasicNotificationType.Info;
|
|
|
|
|
basicNotification.AutoDismiss = true;
|
|
|
|
|
|
2011-02-15 01:20:17 +00:00
|
|
|
|
if (ModelState.IsValid)
|
2011-02-04 02:58:02 +00:00
|
|
|
|
{
|
2011-05-18 03:39:26 +00:00
|
|
|
|
_configProvider.DefaultQualityProfile = data.DefaultQualityProfileId;
|
2011-02-15 01:20:17 +00:00
|
|
|
|
|
|
|
|
|
//Saves only the Default Quality, skips User Profiles since none exist
|
2011-05-29 04:07:11 +00:00
|
|
|
|
if (data.Profiles == null)
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-15 01:20:17 +00:00
|
|
|
|
|
2011-05-29 04:07:11 +00:00
|
|
|
|
foreach (var profile in data.Profiles)
|
2011-02-15 01:20:17 +00:00
|
|
|
|
{
|
2011-05-29 04:07:11 +00:00
|
|
|
|
Logger.Debug(String.Format("Updating Profile: {0}", profile));
|
2011-02-06 07:13:17 +00:00
|
|
|
|
|
2011-02-15 01:20:17 +00:00
|
|
|
|
profile.Allowed = new List<QualityTypes>();
|
2011-05-29 08:59:25 +00:00
|
|
|
|
|
2011-05-29 21:25:00 +00:00
|
|
|
|
//Remove the extra comma from the end
|
|
|
|
|
profile.AllowedString = profile.AllowedString.Trim(',');
|
2011-05-29 08:59:25 +00:00
|
|
|
|
|
2011-02-15 01:20:17 +00:00
|
|
|
|
foreach (var quality in profile.AllowedString.Split(','))
|
2011-02-15 00:45:31 +00:00
|
|
|
|
{
|
2011-04-19 00:12:06 +00:00
|
|
|
|
var qType = (QualityTypes)Enum.Parse(typeof(QualityTypes), quality);
|
2011-02-15 01:20:17 +00:00
|
|
|
|
profile.Allowed.Add(qType);
|
|
|
|
|
}
|
2011-02-15 00:45:31 +00:00
|
|
|
|
|
2011-02-15 01:20:17 +00:00
|
|
|
|
//If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit
|
|
|
|
|
if (!profile.Allowed.Contains(profile.Cutoff))
|
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
|
//profile.Cutoff = profile.Allowed.Last();
|
2011-02-06 07:13:17 +00:00
|
|
|
|
|
2011-04-22 17:09:06 +00:00
|
|
|
|
_qualityProvider.Update(profile);
|
2011-02-06 07:13:17 +00:00
|
|
|
|
}
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_SAVED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-04-22 00:30:19 +00:00
|
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-04 02:58:02 +00:00
|
|
|
|
}
|
2011-02-05 06:07:25 +00:00
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_FAILED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_FAILED);
|
2011-02-11 01:22:29 +00:00
|
|
|
|
}
|
2011-02-26 04:07:22 +00:00
|
|
|
|
|
2011-03-07 07:32:36 +00:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SaveNotifications(NotificationSettingsModel data)
|
|
|
|
|
{
|
2011-05-13 04:46:26 +00:00
|
|
|
|
var basicNotification = new BasicNotification();
|
|
|
|
|
basicNotification.Type = BasicNotificationType.Info;
|
|
|
|
|
basicNotification.AutoDismiss = true;
|
|
|
|
|
|
2011-03-07 07:32:36 +00:00
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
_configProvider.SetValue("XbmcEnabled", data.XbmcEnabled.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcNotifyOnGrab", data.XbmcNotifyOnGrab.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcNotifyOnDownload", data.XbmcNotifyOnDownload.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcNotifyOnRename", data.XbmcNotifyOnRename.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcNotificationImage", data.XbmcNotificationImage.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcDisplayTime", data.XbmcDisplayTime.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcUpdateOnDownload", data.XbmcUpdateOnDownload.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcUpdateOnRename", data.XbmcUpdateOnRename.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcFullUpdate", data.XbmcFullUpdate.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcCleanOnDownload", data.XbmcCleanOnDownload.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcCleanOnRename", data.XbmcCleanOnRename.ToString());
|
|
|
|
|
_configProvider.SetValue("XbmcHosts", data.XbmcHosts);
|
|
|
|
|
_configProvider.SetValue("XbmcUsername", data.XbmcUsername);
|
|
|
|
|
_configProvider.SetValue("XbmcPassword", data.XbmcPassword);
|
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_SAVED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_SAVED);
|
2011-03-07 07:32:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_FAILED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_FAILED);
|
2011-03-07 07:32:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-26 04:07:22 +00:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
|
|
|
|
|
{
|
2011-05-13 04:46:26 +00:00
|
|
|
|
var basicNotification = new BasicNotification();
|
|
|
|
|
basicNotification.Type = BasicNotificationType.Info;
|
|
|
|
|
basicNotification.AutoDismiss = true;
|
|
|
|
|
|
2011-02-26 04:07:22 +00:00
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
2011-05-18 23:10:25 +00:00
|
|
|
|
_configProvider.SeriesName = data.SeriesName;
|
|
|
|
|
_configProvider.EpisodeName = data.EpisodeName;
|
|
|
|
|
_configProvider.ReplaceSpaces = data.ReplaceSpaces;
|
|
|
|
|
_configProvider.AppendQuality = data.AppendQuality;
|
|
|
|
|
_configProvider.UseSeasonFolder = data.SeasonFolders;
|
|
|
|
|
_configProvider.SeasonFolderFormat = data.SeasonFolderFormat;
|
|
|
|
|
_configProvider.SeparatorStyle = data.SeparatorStyle;
|
|
|
|
|
_configProvider.NumberStyle = data.NumberStyle;
|
|
|
|
|
_configProvider.MultiEpisodeStyle = data.MultiEpisodeStyle;
|
2011-02-26 04:07:22 +00:00
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_SAVED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-26 04:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-13 04:46:26 +00:00
|
|
|
|
basicNotification.Title = SETTINGS_FAILED;
|
|
|
|
|
_notificationProvider.Register(basicNotification);
|
2011-03-28 21:57:06 +00:00
|
|
|
|
return Content(SETTINGS_FAILED);
|
2011-02-26 04:07:22 +00:00
|
|
|
|
}
|
2010-09-23 03:19:47 +00:00
|
|
|
|
}
|
2011-04-10 02:44:01 +00:00
|
|
|
|
}
|