mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
Fixed: Remove MediaBrowser metadata and pushalot
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Pushalot
|
||||
{
|
||||
public class Pushalot : NotificationBase<PushalotSettings>
|
||||
{
|
||||
private readonly IPushalotProxy _proxy;
|
||||
|
||||
public Pushalot(IPushalotProxy proxy)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
|
||||
public override string Name => "Pushalot";
|
||||
public override string Link => "https://pushalot.com/";
|
||||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(ALBUM_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(TrackDownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(TRACK_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnAlbumDownload(AlbumDownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(ALBUM_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
||||
failures.AddIfNotNull(_proxy.Test(Settings));
|
||||
|
||||
return new ValidationResult(failures);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace NzbDrone.Core.Notifications.Pushalot
|
||||
{
|
||||
public enum PushalotPriority
|
||||
{
|
||||
Silent = -1,
|
||||
Normal = 0,
|
||||
Important = 1
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Rest;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Pushalot
|
||||
{
|
||||
public interface IPushalotProxy
|
||||
{
|
||||
void SendNotification(string title, string message, PushalotSettings settings);
|
||||
ValidationFailure Test(PushalotSettings settings);
|
||||
}
|
||||
|
||||
public class PushalotProxy : IPushalotProxy
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private const string URL = "https://pushalot.com/api/sendmessage";
|
||||
|
||||
public PushalotProxy(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void SendNotification(string title, string message, PushalotSettings settings)
|
||||
{
|
||||
var client = RestClientFactory.BuildClient(URL);
|
||||
var request = BuildRequest();
|
||||
|
||||
request.AddParameter("Source", "Lidarr");
|
||||
|
||||
if (settings.Image)
|
||||
{
|
||||
request.AddParameter("Image", "https://raw.githubusercontent.com/Lidarr/Lidarr/develop/Logo/128.png");
|
||||
}
|
||||
|
||||
request.AddParameter("Title", title);
|
||||
request.AddParameter("Body", message);
|
||||
request.AddParameter("AuthorizationToken", settings.AuthToken);
|
||||
|
||||
if ((PushalotPriority)settings.Priority == PushalotPriority.Important)
|
||||
{
|
||||
request.AddParameter("IsImportant", true);
|
||||
}
|
||||
|
||||
if ((PushalotPriority)settings.Priority == PushalotPriority.Silent)
|
||||
{
|
||||
request.AddParameter("IsSilent", true);
|
||||
}
|
||||
|
||||
client.ExecuteAndValidate(request);
|
||||
}
|
||||
|
||||
public RestRequest BuildRequest()
|
||||
{
|
||||
var request = new RestRequest(Method.POST);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public ValidationFailure Test(PushalotSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
const string title = "Test Notification";
|
||||
const string body = "This is a test message from Lidarr";
|
||||
|
||||
SendNotification(title, body, settings);
|
||||
}
|
||||
catch (RestException ex)
|
||||
{
|
||||
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
_logger.Error(ex, "Authentication Token is invalid");
|
||||
return new ValidationFailure("AuthToken", "Authentication Token is invalid");
|
||||
}
|
||||
|
||||
if (ex.Response.StatusCode == HttpStatusCode.NotAcceptable)
|
||||
{
|
||||
_logger.Error(ex, "Message limit reached");
|
||||
return new ValidationFailure("AuthToken", "Message limit reached");
|
||||
}
|
||||
|
||||
if (ex.Response.StatusCode == HttpStatusCode.Gone)
|
||||
{
|
||||
_logger.Error(ex, "Authorization Token is no longer valid");
|
||||
return new ValidationFailure("AuthToken", "Authorization Token is no longer valid, please use a new one.");
|
||||
}
|
||||
|
||||
var response = Json.Deserialize<PushalotResponse>(ex.Response.Content);
|
||||
|
||||
_logger.Error(ex, "Unable to send test message");
|
||||
return new ValidationFailure("AuthToken", response.Description);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Unable to send test message");
|
||||
return new ValidationFailure("", "Unable to send test message");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace NzbDrone.Core.Notifications.Pushalot
|
||||
{
|
||||
public class PushalotResponse
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public int Status { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Pushalot
|
||||
{
|
||||
public class PushalotSettingsValidator : AbstractValidator<PushalotSettings>
|
||||
{
|
||||
public PushalotSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.AuthToken).NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class PushalotSettings : IProviderConfig
|
||||
{
|
||||
public PushalotSettings()
|
||||
{
|
||||
Image = true;
|
||||
}
|
||||
|
||||
private static readonly PushalotSettingsValidator Validator = new PushalotSettingsValidator();
|
||||
|
||||
[FieldDefinition(0, Label = "Authorization Token", HelpLink = "https://pushalot.com/manager/authorizations")]
|
||||
public string AuthToken { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(PushalotPriority))]
|
||||
public int Priority { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Image", Type = FieldType.Checkbox, HelpText = "Include Lidarr logo with notifications")]
|
||||
public bool Image { get; set; }
|
||||
|
||||
public bool IsValid => !string.IsNullOrWhiteSpace(AuthToken);
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user