You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/NzbDrone.Web/Controllers/CommandController.cs

67 lines
2.1 KiB

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers
{
public class CommandController : Controller
{
private readonly JobProvider _jobProvider;
private readonly SabProvider _sabProvider;
public CommandController(JobProvider jobProvider, SabProvider sabProvider)
{
_jobProvider = jobProvider;
_sabProvider = sabProvider;
}
public JsonResult RssSync()
{
_jobProvider.QueueJob(typeof(RssSyncJob));
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
public JsonResult BacklogSearch()
{
_jobProvider.QueueJob(typeof(BacklogSearchJob));
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
public JsonResult SyncEpisodesOnDisk(int seriesId)
{
//Syncs the episodes on disk for the specified series
_jobProvider.QueueJob(typeof(DiskScanJob), seriesId);
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
public JsonResult UpdateInfo(int seriesId)
{
//Syncs the episodes on disk for the specified series
_jobProvider.QueueJob(typeof(UpdateInfoJob), seriesId);
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
[HttpPost]
public JsonResult GetSabnzbdCategories(string host, int port, string apiKey, string username, string password)
{
try
{
return new JsonResult {Data = _sabProvider.GetCategories(host, port, apiKey, username, password)};
}
catch (Exception ex)
{
//Todo: Log the error
throw;
}
}
}
}