2011-03-03 08:50:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using System.Xml.Linq;
|
2011-03-06 22:27:52 +00:00
|
|
|
|
using NLog;
|
2011-03-03 08:50:33 +00:00
|
|
|
|
using NzbDrone.Core;
|
|
|
|
|
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-04-08 15:24:16 +00:00
|
|
|
|
private readonly PostProcessingProvider _postProcessingProvider;
|
2011-04-10 01:34:36 +00:00
|
|
|
|
private readonly ConfigProvider _configProvider;
|
2011-03-03 08:50:33 +00:00
|
|
|
|
|
2011-03-06 22:27:52 +00:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|