2011-04-29 06:06:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-07-09 18:19:33 +00:00
|
|
|
|
using NzbDrone.Core.Repository;
|
2011-04-29 06:06:13 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.ExternalNotification
|
|
|
|
|
{
|
|
|
|
|
public class XbmcNotificationProvider : ExternalNotificationProviderBase
|
|
|
|
|
{
|
|
|
|
|
private readonly XbmcProvider _xbmcProvider;
|
|
|
|
|
|
|
|
|
|
public XbmcNotificationProvider(ConfigProvider configProvider, XbmcProvider xbmcProvider,
|
2011-05-08 21:49:15 +00:00
|
|
|
|
ExternalNotificationProvider externalNotificationProvider)
|
|
|
|
|
: base(configProvider, externalNotificationProvider)
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
|
|
|
|
_xbmcProvider = xbmcProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "XBMC"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnGrab(string message)
|
|
|
|
|
{
|
2011-05-08 21:49:15 +00:00
|
|
|
|
const string header = "NzbDrone [TV] - Grabbed";
|
2011-04-29 06:06:13 +00:00
|
|
|
|
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
2011-05-08 21:49:15 +00:00
|
|
|
|
_logger.Trace("Sending Notification to XBMC");
|
2011-04-29 06:06:13 +00:00
|
|
|
|
_xbmcProvider.Notify(header, message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_logger.Trace("XBMC NotifyOnGrab is not enabled");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Trace("XBMC Notifier is not enabled");
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-09 18:19:33 +00:00
|
|
|
|
public override void OnDownload(string message, Series series)
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
2011-05-08 21:49:15 +00:00
|
|
|
|
const string header = "NzbDrone [TV] - Downloaded";
|
2011-04-29 06:06:13 +00:00
|
|
|
|
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
2011-05-08 21:49:15 +00:00
|
|
|
|
_logger.Trace("Sending Notification to XBMC");
|
2011-04-29 06:06:13 +00:00
|
|
|
|
_xbmcProvider.Notify(header, message);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Sending Update Request to XBMC");
|
2011-07-09 18:19:33 +00:00
|
|
|
|
_xbmcProvider.Update(series);
|
2011-04-29 06:06:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Sending Clean DB Request to XBMC");
|
|
|
|
|
_xbmcProvider.Clean();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Trace("XBMC Notifier is not enabled");
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-09 18:19:33 +00:00
|
|
|
|
public override void OnRename(string message, Series series)
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
2011-05-08 21:49:15 +00:00
|
|
|
|
const string header = "NzbDrone [TV] - Renamed";
|
2011-04-29 06:06:13 +00:00
|
|
|
|
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
2011-05-08 21:49:15 +00:00
|
|
|
|
_logger.Trace("Sending Notification to XBMC");
|
2011-04-29 06:06:13 +00:00
|
|
|
|
_xbmcProvider.Notify(header, message);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Sending Update Request to XBMC");
|
2011-07-09 18:19:33 +00:00
|
|
|
|
_xbmcProvider.Update(series);
|
2011-04-29 06:06:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-17 02:27:10 +00:00
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false)))
|
2011-04-29 06:06:13 +00:00
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Sending Clean DB Request to XBMC");
|
|
|
|
|
_xbmcProvider.Clean();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|