mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
ExternalNotifications enabled (Xbmc only right now).
- Grab, Download, Rename Notification Settings for Xbmc uses definitions.
This commit is contained in:
parent
0ed898b6db
commit
ee4b6c9442
13 changed files with 211 additions and 175 deletions
|
@ -6,16 +6,14 @@ using NzbDrone.Core.Repository;
|
|||
|
||||
namespace NzbDrone.Core.Providers.ExternalNotification
|
||||
{
|
||||
public abstract class ExternalNotificationProviderBase
|
||||
public abstract class ExternalNotificationBase
|
||||
{
|
||||
protected readonly Logger _logger;
|
||||
protected readonly ConfigProvider _configProvider;
|
||||
protected readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
|
||||
protected ExternalNotificationProviderBase(ConfigProvider configProvider, ExternalNotificationProvider externalNotificationProvider)
|
||||
protected ExternalNotificationBase(ConfigProvider configProvider)
|
||||
{
|
||||
_configProvider = configProvider;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_logger = LogManager.GetLogger(GetType().ToString());
|
||||
}
|
||||
|
||||
|
@ -24,35 +22,6 @@ namespace NzbDrone.Core.Providers.ExternalNotification
|
|||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
public ExternalNotificationSetting Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return _externalNotificationProvider.GetSettings(GetType());
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Notify(ExternalNotificationType type, string message, int seriesId = 0)
|
||||
{
|
||||
if (type == ExternalNotificationType.Grab)
|
||||
OnGrab(message);
|
||||
|
||||
else if (type == ExternalNotificationType.Download)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var series = new Series();
|
||||
OnDownload(message, series);
|
||||
}
|
||||
|
||||
|
||||
else if (type == ExternalNotificationType.Rename)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var series = new Series();
|
||||
OnRename(message, series);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the on grab action
|
||||
/// </summary>
|
66
NzbDrone.Core/Providers/ExternalNotification/Xbmc.cs
Normal file
66
NzbDrone.Core/Providers/ExternalNotification/Xbmc.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Providers.ExternalNotification
|
||||
{
|
||||
public class Xbmc : ExternalNotificationBase
|
||||
{
|
||||
private readonly XbmcProvider _xbmcProvider;
|
||||
|
||||
public Xbmc(ConfigProvider configProvider, XbmcProvider xbmcProvider)
|
||||
: base(configProvider)
|
||||
{
|
||||
_xbmcProvider = xbmcProvider;
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "XBMC"; }
|
||||
}
|
||||
|
||||
public override void OnGrab(string message)
|
||||
{
|
||||
const string header = "NzbDrone [TV] - Grabbed";
|
||||
|
||||
if (_configProvider.XbmcNotifyOnGrab)
|
||||
{
|
||||
_logger.Trace("Sending Notification to XBMC");
|
||||
_xbmcProvider.Notify(header, message);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDownload(string message, Series series)
|
||||
{
|
||||
const string header = "NzbDrone [TV] - Downloaded";
|
||||
|
||||
if (_configProvider.XbmcNotifyOnDownload)
|
||||
{
|
||||
_logger.Trace("Sending Notification to XBMC");
|
||||
_xbmcProvider.Notify(header, message);
|
||||
}
|
||||
|
||||
UpdateAndClean(series);
|
||||
}
|
||||
|
||||
public override void OnRename(string message, Series series)
|
||||
{
|
||||
UpdateAndClean(series);
|
||||
}
|
||||
|
||||
private void UpdateAndClean(Series series)
|
||||
{
|
||||
if (_configProvider.XbmcUpdateLibrary)
|
||||
{
|
||||
_logger.Trace("Sending Update Request to XBMC");
|
||||
_xbmcProvider.Update(series);
|
||||
}
|
||||
|
||||
if (_configProvider.XbmcCleanLibrary)
|
||||
{
|
||||
_logger.Trace("Sending Clean DB Request to XBMC");
|
||||
_xbmcProvider.Clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Providers.ExternalNotification
|
||||
{
|
||||
public class XbmcNotificationProvider : ExternalNotificationProviderBase
|
||||
{
|
||||
private readonly XbmcProvider _xbmcProvider;
|
||||
|
||||
public XbmcNotificationProvider(ConfigProvider configProvider, XbmcProvider xbmcProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider)
|
||||
: base(configProvider, externalNotificationProvider)
|
||||
{
|
||||
_xbmcProvider = xbmcProvider;
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "XBMC"; }
|
||||
}
|
||||
|
||||
public override void OnGrab(string message)
|
||||
{
|
||||
const string header = "NzbDrone [TV] - Grabbed";
|
||||
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)))
|
||||
{
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false)))
|
||||
{
|
||||
_logger.Trace("Sending Notification to XBMC");
|
||||
_xbmcProvider.Notify(header, message);
|
||||
return;
|
||||
}
|
||||
_logger.Trace("XBMC NotifyOnGrab is not enabled");
|
||||
}
|
||||
|
||||
_logger.Trace("XBMC Notifier is not enabled");
|
||||
}
|
||||
|
||||
public override void OnDownload(string message, Series series)
|
||||
{
|
||||
const string header = "NzbDrone [TV] - Downloaded";
|
||||
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)))
|
||||
{
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false)))
|
||||
{
|
||||
_logger.Trace("Sending Notification to XBMC");
|
||||
_xbmcProvider.Notify(header, message);
|
||||
}
|
||||
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload", false)))
|
||||
{
|
||||
_logger.Trace("Sending Update Request to XBMC");
|
||||
_xbmcProvider.Update(series);
|
||||
}
|
||||
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false)))
|
||||
{
|
||||
_logger.Trace("Sending Clean DB Request to XBMC");
|
||||
_xbmcProvider.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Trace("XBMC Notifier is not enabled");
|
||||
}
|
||||
|
||||
public override void OnRename(string message, Series series)
|
||||
{
|
||||
const string header = "NzbDrone [TV] - Renamed";
|
||||
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false)))
|
||||
{
|
||||
_logger.Trace("Sending Notification to XBMC");
|
||||
_xbmcProvider.Notify(header, message);
|
||||
}
|
||||
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false)))
|
||||
{
|
||||
_logger.Trace("Sending Update Request to XBMC");
|
||||
_xbmcProvider.Update(series);
|
||||
}
|
||||
|
||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false)))
|
||||
{
|
||||
_logger.Trace("Sending Clean DB Request to XBMC");
|
||||
_xbmcProvider.Clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue