parent
1b34780b7e
commit
cf33e40e70
@ -0,0 +1,15 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(158)]
|
||||
public class remove_plex_hometheatre : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Delete.FromTable("Notifications").Row(new { Implementation = "PlexHomeTheater" });
|
||||
Delete.FromTable("Notifications").Row(new { Implementation = "PlexClient" });
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Plex.HomeTheater
|
||||
{
|
||||
public class PlexClient : NotificationBase<PlexClientSettings>
|
||||
{
|
||||
private readonly IPlexClientService _plexClientService;
|
||||
|
||||
public override string Link => "https://www.plex.tv/";
|
||||
public override string Name => "Plex Media Center";
|
||||
|
||||
public PlexClient(IPlexClientService plexClientService)
|
||||
{
|
||||
_plexClientService = plexClientService;
|
||||
}
|
||||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_plexClientService.Notify(Settings, MOVIE_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_plexClientService.Notify(Settings, MOVIE_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
||||
failures.AddIfNotNull(_plexClientService.Test(Settings));
|
||||
|
||||
return new ValidationResult(failures);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Notifications.Xbmc;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Plex.HomeTheater
|
||||
{
|
||||
public class PlexHomeTheater : NotificationBase<PlexHomeTheaterSettings>
|
||||
{
|
||||
private readonly IXbmcService _xbmcService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public PlexHomeTheater(IXbmcService xbmcService, Logger logger)
|
||||
{
|
||||
_xbmcService = xbmcService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override string Name => "Plex Home Theater";
|
||||
public override string Link => "https://plex.tv/";
|
||||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
Notify(Settings, MOVIE_GRABBED_TITLE_BRANDED, grabMessage.Message);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
Notify(Settings, MOVIE_DOWNLOADED_TITLE_BRANDED, message.Message);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
||||
failures.AddIfNotNull(_xbmcService.Test(Settings, "Success! PHT has been successfully configured!"));
|
||||
|
||||
return new ValidationResult(failures);
|
||||
}
|
||||
|
||||
private void Notify(XbmcSettings settings, string header, string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Settings.Notify)
|
||||
{
|
||||
_xbmcService.Notify(Settings, header, message);
|
||||
}
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
var logMessage = $"Unable to connect to PHT Host: {Settings.Host}:{Settings.Port}";
|
||||
_logger.Debug(ex, logMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue