2011-03-06 21:45:35 +01:00
|
|
|
|
using System;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Core.Helpers;
|
|
|
|
|
using NzbDrone.Core.Model;
|
2011-04-04 05:50:12 +02:00
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-03-06 21:45:35 +01:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
|
|
|
{
|
2011-04-08 18:24:17 +02:00
|
|
|
|
public class ExternalNotificationProvider
|
2011-03-06 21:45:35 +01:00
|
|
|
|
{
|
2011-04-10 04:44:01 +02:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
2011-04-10 03:34:36 +02:00
|
|
|
|
private readonly ConfigProvider _configProvider;
|
2011-04-08 17:15:51 +02:00
|
|
|
|
private readonly XbmcProvider _xbmcProvider;
|
2011-03-06 21:45:35 +01:00
|
|
|
|
|
2011-04-10 03:34:36 +02:00
|
|
|
|
public ExternalNotificationProvider(ConfigProvider configProvider, XbmcProvider xbmcProvider)
|
2011-03-06 21:45:35 +01:00
|
|
|
|
{
|
|
|
|
|
_configProvider = configProvider;
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider = xbmcProvider;
|
2011-03-06 21:45:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 18:24:17 +02:00
|
|
|
|
public virtual void OnGrab(string message)
|
2011-03-06 21:45:35 +01:00
|
|
|
|
{
|
|
|
|
|
var header = "NzbDrone [TV] - Grabbed";
|
|
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)))
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)))
|
|
|
|
|
{
|
|
|
|
|
Logger.Trace("Sending Notifcation to XBMC");
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider.Notify(header, message);
|
2011-03-06 21:45:35 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Logger.Trace("XBMC NotifyOnGrab is not enabled");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.Trace("XBMC Notifier is not enabled");
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 18:24:17 +02:00
|
|
|
|
public virtual void OnDownload(EpisodeRenameModel erm)
|
2011-03-06 21:45:35 +01:00
|
|
|
|
{
|
|
|
|
|
var header = "NzbDrone [TV] - Downloaded";
|
|
|
|
|
var message = EpisodeRenameHelper.GetNewName(erm);
|
|
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)))
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)))
|
|
|
|
|
{
|
|
|
|
|
Logger.Trace("Sending Notifcation to XBMC");
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider.Notify(header, message);
|
2011-03-06 21:45:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload", false, true)))
|
|
|
|
|
{
|
|
|
|
|
Logger.Trace("Sending Update Request to XBMC");
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider.Update(erm.EpisodeFile.SeriesId);
|
2011-03-06 21:45:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)))
|
|
|
|
|
{
|
|
|
|
|
Logger.Trace("Sending Clean DB Request to XBMC");
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider.Clean();
|
2011-03-06 21:45:35 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.Trace("XBMC Notifier is not enabled");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 18:24:17 +02:00
|
|
|
|
public virtual void OnRename(EpisodeRenameModel erm)
|
2011-03-06 21:45:35 +01:00
|
|
|
|
{
|
|
|
|
|
var header = "NzbDrone [TV] - Renamed";
|
|
|
|
|
var message = EpisodeRenameHelper.GetNewName(erm);
|
|
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)))
|
|
|
|
|
{
|
|
|
|
|
Logger.Trace("Sending Notifcation to XBMC");
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider.Notify(header, message);
|
2011-03-06 21:45:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)))
|
|
|
|
|
{
|
|
|
|
|
Logger.Trace("Sending Update Request to XBMC");
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider.Update(erm.EpisodeFile.SeriesId);
|
2011-03-06 21:45:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)))
|
|
|
|
|
{
|
|
|
|
|
Logger.Trace("Sending Clean DB Request to XBMC");
|
2011-03-06 22:40:38 +01:00
|
|
|
|
_xbmcProvider.Clean();
|
2011-03-06 21:45:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-10 04:44:01 +02:00
|
|
|
|
}
|