2011-03-03 09:50:33 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using System.Xml.Linq;
|
2011-03-06 23:27:52 +01:00
|
|
|
|
using NLog;
|
2011-03-03 09:50:33 +01:00
|
|
|
|
using NzbDrone.Core;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class ApiController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly IPostProcessingProvider _postProcessingProvider;
|
2011-03-06 23:27:52 +01:00
|
|
|
|
private readonly IConfigProvider _configProvider;
|
2011-03-03 09:50:33 +01:00
|
|
|
|
|
2011-03-06 23:27:52 +01:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
public ApiController(IPostProcessingProvider postProcessingProvider, IConfigProvider 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|