sonarr-repo-only/NzbDrone.Core/Providers/ExternalNotification/Xbmc.cs

74 lines
1.9 KiB
C#
Raw Normal View History

using System;
2013-02-24 06:48:52 +00:00
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers.ExternalNotification
{
public class Xbmc : ExternalNotificationBase
{
private readonly XbmcProvider _xbmcProvider;
2013-02-24 06:48:52 +00:00
public Xbmc(IConfigService configService, XbmcProvider xbmcProvider)
: base(configService)
{
_xbmcProvider = xbmcProvider;
}
public override string Name
{
get { return "XBMC"; }
}
public override void OnGrab(string message)
{
const string header = "NzbDrone [TV] - Grabbed";
2013-02-24 06:48:52 +00:00
if (_configService.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";
2013-02-24 06:48:52 +00:00
if (_configService.XbmcNotifyOnDownload)
{
_logger.Trace("Sending Notification to XBMC");
_xbmcProvider.Notify(header, message);
}
UpdateAndClean(series);
}
public override void OnRename(string message, Series series)
{
}
public override void AfterRename(string message, Series series)
{
UpdateAndClean(series);
}
private void UpdateAndClean(Series series)
{
2013-02-24 06:48:52 +00:00
if (_configService.XbmcUpdateLibrary)
{
_logger.Trace("Sending Update Request to XBMC");
_xbmcProvider.Update(series);
}
2013-02-24 06:48:52 +00:00
if (_configService.XbmcCleanLibrary)
{
_logger.Trace("Sending Clean DB Request to XBMC");
_xbmcProvider.Clean();
}
}
}
}