Radarr/NzbDrone.Core/Providers/ExternalNotificationProvide...

98 lines
3.4 KiB
C#
Raw Normal View History

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