2014-07-04 08:09:48 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using FluentValidation.Results;
|
2014-12-02 06:26:25 +00:00
|
|
|
|
using NzbDrone.Common.Extensions;
|
2014-07-04 08:09:48 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
{
|
2013-05-20 02:43:22 +00:00
|
|
|
|
public class PlexClient : NotificationBase<PlexClientSettings>
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
2015-05-25 19:53:37 +00:00
|
|
|
|
private readonly IPlexClientService _plexClientService;
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2015-05-25 19:53:37 +00:00
|
|
|
|
public PlexClient(IPlexClientService plexClientService)
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
2015-05-25 19:53:37 +00:00
|
|
|
|
_plexClientService = plexClientService;
|
2013-05-19 23:17:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-09 06:54:15 +00:00
|
|
|
|
public override string Link => "http://www.plexapp.com/";
|
2013-07-27 20:57:41 +00:00
|
|
|
|
|
2015-08-24 05:21:14 +00:00
|
|
|
|
public override void OnGrab(GrabMessage grabMessage)
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
2014-11-16 04:11:50 +00:00
|
|
|
|
const string header = "Sonarr [TV] - Grabbed";
|
2015-08-24 05:21:14 +00:00
|
|
|
|
_plexClientService.Notify(Settings, header, grabMessage.Message);
|
2013-05-19 23:17:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-18 06:28:40 +00:00
|
|
|
|
public override void OnDownload(DownloadMessage message)
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
2014-11-16 04:11:50 +00:00
|
|
|
|
const string header = "Sonarr [TV] - Downloaded";
|
2015-05-25 19:53:37 +00:00
|
|
|
|
_plexClientService.Notify(Settings, header, message.Message);
|
2013-05-19 23:17:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-20 23:22:10 +00:00
|
|
|
|
public override void OnRename(Series series)
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
2014-07-04 08:09:48 +00:00
|
|
|
|
|
2016-12-09 06:54:15 +00:00
|
|
|
|
public override string Name => "Plex Media Center";
|
2015-04-25 16:02:17 +00:00
|
|
|
|
|
2016-12-09 06:54:15 +00:00
|
|
|
|
public override bool SupportsOnRename => false;
|
2015-05-20 23:22:10 +00:00
|
|
|
|
|
2014-07-04 08:09:48 +00:00
|
|
|
|
public override ValidationResult Test()
|
|
|
|
|
{
|
|
|
|
|
var failures = new List<ValidationFailure>();
|
|
|
|
|
|
2015-05-25 19:53:37 +00:00
|
|
|
|
failures.AddIfNotNull(_plexClientService.Test(Settings));
|
2014-07-04 08:09:48 +00:00
|
|
|
|
|
|
|
|
|
return new ValidationResult(failures);
|
|
|
|
|
}
|
2013-05-19 23:17:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|