You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.6 KiB
70 lines
1.6 KiB
using System.Collections.Generic;
|
|
using FluentValidation.Results;
|
|
using NzbDrone.Common.Extensions;
|
|
using NzbDrone.Core.Tv;
|
|
|
|
namespace NzbDrone.Core.Notifications.Plex
|
|
{
|
|
public class PlexServer : NotificationBase<PlexServerSettings>
|
|
{
|
|
private readonly IPlexServerService _plexServerService;
|
|
|
|
public PlexServer(IPlexServerService plexServerService)
|
|
{
|
|
_plexServerService = plexServerService;
|
|
}
|
|
|
|
public override string Link
|
|
{
|
|
get { return "http://www.plexapp.com/"; }
|
|
}
|
|
|
|
public override void OnGrab(string message)
|
|
{
|
|
}
|
|
|
|
public override void OnDownload(DownloadMessage message)
|
|
{
|
|
UpdateIfEnabled(message.Series);
|
|
}
|
|
|
|
public override void OnRename(Series series)
|
|
{
|
|
UpdateIfEnabled(series);
|
|
}
|
|
|
|
private void UpdateIfEnabled(Series series)
|
|
{
|
|
if (Settings.UpdateLibrary)
|
|
{
|
|
_plexServerService.UpdateLibrary(series, Settings);
|
|
}
|
|
}
|
|
|
|
public override string Name
|
|
{
|
|
get
|
|
{
|
|
return "Plex Media Server";
|
|
}
|
|
}
|
|
|
|
public override bool SupportsOnGrab
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public override ValidationResult Test()
|
|
{
|
|
var failures = new List<ValidationFailure>();
|
|
|
|
failures.AddIfNotNull(_plexServerService.Test(Settings));
|
|
|
|
return new ValidationResult(failures);
|
|
}
|
|
}
|
|
}
|