1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02:00
Sonarr/NzbDrone.Web/Controllers/CommandController.cs

67 lines
2.1 KiB
C#
Raw Normal View History

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;
}
}
}
}