Sonarr/NzbDrone.Core/Providers/ExternalNotification/Prowl.cs

81 lines
2.2 KiB
C#
Raw Normal View History

2011-11-03 02:44:22 +00:00
using System;
using NLog;
2013-02-24 06:48:52 +00:00
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
2011-11-03 02:44:22 +00:00
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using Prowlin;
namespace NzbDrone.Core.Providers.ExternalNotification
{
public class Prowl : ExternalNotificationBase
{
private readonly ProwlProvider _prowlProvider;
2013-02-24 06:48:52 +00:00
public Prowl(IConfigService configService, ProwlProvider prowlProvider)
: base(configService)
2011-11-03 02:44:22 +00:00
{
_prowlProvider = prowlProvider;
}
public override string Name
{
get { return "Prowl"; }
}
public override void OnGrab(string message)
{
try
{
2013-02-24 06:48:52 +00:00
if(_configService.GrowlNotifyOnGrab)
2011-11-03 02:44:22 +00:00
{
_logger.Trace("Sending Notification to Prowl");
const string title = "Episode Grabbed";
2013-02-24 06:48:52 +00:00
var apiKeys = _configService.ProwlApiKeys;
var priority = _configService.ProwlPriority;
2011-11-03 02:44:22 +00:00
_prowlProvider.SendNotification(title, message, apiKeys, (NotificationPriority)priority);
}
}
catch (Exception ex)
{
2011-11-10 05:05:57 +00:00
_logger.WarnException(ex.Message, ex);
2011-11-03 02:44:22 +00:00
}
}
public override void OnDownload(string message, Series series)
{
try
{
2013-02-24 06:48:52 +00:00
if (_configService.GrowlNotifyOnDownload)
2011-11-03 02:44:22 +00:00
{
_logger.Trace("Sending Notification to Prowl");
const string title = "Episode Downloaded";
2013-02-24 06:48:52 +00:00
var apiKeys = _configService.ProwlApiKeys;
var priority = _configService.ProwlPriority;
2011-11-03 02:44:22 +00:00
_prowlProvider.SendNotification(title, message, apiKeys, (NotificationPriority)priority);
}
}
catch (Exception ex)
{
2011-11-10 05:05:57 +00:00
_logger.WarnException(ex.Message, ex);
2011-11-03 02:44:22 +00:00
}
}
public override void OnRename(string message, Series series)
{
}
public override void AfterRename(string message, Series series)
{
}
2011-11-03 02:44:22 +00:00
}
}