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