2011-08-06 04:04:35 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
2011-08-26 19:45:59 +02:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-08-06 04:04:35 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Jobs;
|
2011-08-26 19:45:59 +02:00
|
|
|
|
using NzbDrone.Web.Models;
|
2011-08-06 04:04:35 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class CommandController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly JobProvider _jobProvider;
|
2011-08-26 19:45:59 +02:00
|
|
|
|
private readonly SabProvider _sabProvider;
|
2011-08-06 04:04:35 +02:00
|
|
|
|
|
2011-08-26 19:45:59 +02:00
|
|
|
|
public CommandController(JobProvider jobProvider, SabProvider sabProvider)
|
2011-08-06 04:04:35 +02:00
|
|
|
|
{
|
|
|
|
|
_jobProvider = jobProvider;
|
2011-08-26 19:45:59 +02:00
|
|
|
|
_sabProvider = sabProvider;
|
2011-08-06 04:04:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult RssSync()
|
|
|
|
|
{
|
|
|
|
|
_jobProvider.QueueJob(typeof(RssSyncJob));
|
2011-08-23 05:52:08 +02:00
|
|
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
2011-08-06 04:04:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-22 01:33:54 +02:00
|
|
|
|
public JsonResult BacklogSearch()
|
|
|
|
|
{
|
|
|
|
|
_jobProvider.QueueJob(typeof(BacklogSearchJob));
|
|
|
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-06 04:04:35 +02:00
|
|
|
|
public JsonResult SyncEpisodesOnDisk(int seriesId)
|
|
|
|
|
{
|
|
|
|
|
//Syncs the episodes on disk for the specified series
|
|
|
|
|
_jobProvider.QueueJob(typeof(DiskScanJob), seriesId);
|
|
|
|
|
|
2011-08-23 05:52:08 +02:00
|
|
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
2011-08-06 04:04:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult UpdateInfo(int seriesId)
|
|
|
|
|
{
|
|
|
|
|
//Syncs the episodes on disk for the specified series
|
|
|
|
|
_jobProvider.QueueJob(typeof(UpdateInfoJob), seriesId);
|
|
|
|
|
|
2011-08-23 05:52:08 +02:00
|
|
|
|
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
2011-08-06 04:04:35 +02:00
|
|
|
|
}
|
2011-08-26 19:45:59 +02:00
|
|
|
|
|
|
|
|
|
[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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-06 04:04:35 +02:00
|
|
|
|
}
|
|
|
|
|
}
|