2011-04-10 02:44:01 +00:00
|
|
|
|
using System.Web.Mvc;
|
2011-03-06 22:27:52 +00:00
|
|
|
|
using NLog;
|
2011-03-03 08:50:33 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2011-04-04 03:50:12 +00:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-03-03 08:50:33 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class ApiController : Controller
|
|
|
|
|
{
|
2011-03-06 22:27:52 +00:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
2011-04-10 02:44:01 +00:00
|
|
|
|
private readonly ConfigProvider _configProvider;
|
|
|
|
|
private readonly PostProcessingProvider _postProcessingProvider;
|
2011-03-06 22:27:52 +00:00
|
|
|
|
|
2011-04-10 01:34:36 +00:00
|
|
|
|
public ApiController(PostProcessingProvider postProcessingProvider, ConfigProvider configProvider)
|
2011-03-03 08:50:33 +00:00
|
|
|
|
{
|
|
|
|
|
_postProcessingProvider = postProcessingProvider;
|
2011-03-06 22:27:52 +00:00
|
|
|
|
_configProvider = configProvider;
|
2011-03-03 08:50:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-06 22:27:52 +00:00
|
|
|
|
public ActionResult ProcessEpisode(string apiKey, string dir, string nzbName, string category)
|
2011-03-03 08:50:33 +00:00
|
|
|
|
{
|
2011-03-31 01:42:27 +00:00
|
|
|
|
if (apiKey != _configProvider.ApiKey)
|
2011-03-06 22:27:52 +00:00
|
|
|
|
{
|
|
|
|
|
Logger.Warn("API Key from Post Processing Script is Invalid");
|
|
|
|
|
return Content("Invalid API Key");
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-31 01:42:27 +00:00
|
|
|
|
if (_configProvider.SabTvCategory == category)
|
2011-03-06 22:27:52 +00:00
|
|
|
|
{
|
|
|
|
|
_postProcessingProvider.ProcessEpisode(dir, nzbName);
|
|
|
|
|
return Content("ok");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Content("Category doesn't match what was configured for SAB TV Category...");
|
2011-03-03 08:50:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-10 02:44:01 +00:00
|
|
|
|
}
|