mirror of
https://github.com/Sonarr/Sonarr
synced 2026-05-08 13:01:10 +02:00
New: Include series poster for Apprise
This commit is contained in:
parent
72b3b825eb
commit
f9dccd6ec7
5 changed files with 37 additions and 16 deletions
|
|
@ -653,7 +653,6 @@
|
|||
"EpisodeHistoryLoadError": "Unable to load episode history",
|
||||
"EpisodeImported": "Episode Imported",
|
||||
"EpisodeImportedTooltip": "Episode downloaded successfully and picked up from download client",
|
||||
"EpisodesInSeason": "{episodeCount} episodes in season",
|
||||
"EpisodeInfo": "Episode Info",
|
||||
"EpisodeIsDownloading": "Episode is downloading",
|
||||
"EpisodeIsNotMonitored": "Episode is not monitored",
|
||||
|
|
@ -669,6 +668,7 @@
|
|||
"EpisodeTitleRequired": "Episode Title Required",
|
||||
"EpisodeTitleRequiredHelpText": "Prevent importing for up to 48 hours if the episode title is in the naming format and the episode title is TBA",
|
||||
"Episodes": "Episodes",
|
||||
"EpisodesInSeason": "{episodeCount} episodes in season",
|
||||
"EpisodesLoadError": "Unable to load episodes",
|
||||
"Error": "Error",
|
||||
"ErrorLoadingContent": "There was an error loading this content",
|
||||
|
|
@ -1329,6 +1329,8 @@
|
|||
"NotificationTriggersHelpText": "Select which events should trigger this notification",
|
||||
"NotificationsAppriseSettingsConfigurationKey": "Apprise Configuration Key",
|
||||
"NotificationsAppriseSettingsConfigurationKeyHelpText": "Configuration Key for the Persistent Storage Solution. Leave empty if Stateless URLs is used.",
|
||||
"NotificationsAppriseSettingsIncludePoster": "Include Poster",
|
||||
"NotificationsAppriseSettingsIncludePosterHelpText": "Include poster in message",
|
||||
"NotificationsAppriseSettingsNotificationType": "Apprise Notification Type",
|
||||
"NotificationsAppriseSettingsPasswordHelpText": "HTTP Basic Auth Password",
|
||||
"NotificationsAppriseSettingsServerUrl": "Apprise Server URL",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Apprise
|
||||
{
|
||||
|
|
@ -19,52 +22,52 @@ public Apprise(IAppriseProxy proxy)
|
|||
|
||||
public override void OnGrab(GrabMessage grabMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||
_proxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, GetPosterUrl(grabMessage.Series), Settings);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, GetPosterUrl(message.Series), Settings);
|
||||
}
|
||||
|
||||
public override void OnImportComplete(ImportCompleteMessage message)
|
||||
{
|
||||
_proxy.SendNotification(IMPORT_COMPLETE_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(IMPORT_COMPLETE_TITLE, message.Message, GetPosterUrl(message.Series), Settings);
|
||||
}
|
||||
|
||||
public override void OnEpisodeFileDelete(EpisodeDeleteMessage deleteMessage)
|
||||
{
|
||||
_proxy.SendNotification(EPISODE_DELETED_TITLE, deleteMessage.Message, Settings);
|
||||
_proxy.SendNotification(EPISODE_DELETED_TITLE, deleteMessage.Message, GetPosterUrl(deleteMessage.Series), Settings);
|
||||
}
|
||||
|
||||
public override void OnSeriesAdd(SeriesAddMessage message)
|
||||
{
|
||||
_proxy.SendNotification(SERIES_ADDED_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(SERIES_ADDED_TITLE, message.Message, GetPosterUrl(message.Series), Settings);
|
||||
}
|
||||
|
||||
public override void OnSeriesDelete(SeriesDeleteMessage deleteMessage)
|
||||
{
|
||||
_proxy.SendNotification(SERIES_DELETED_TITLE, deleteMessage.Message, Settings);
|
||||
_proxy.SendNotification(SERIES_DELETED_TITLE, deleteMessage.Message, GetPosterUrl(deleteMessage.Series), Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings);
|
||||
_proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, null, Settings);
|
||||
}
|
||||
|
||||
public override void OnHealthRestored(HealthCheck.HealthCheck previousCheck)
|
||||
{
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", Settings);
|
||||
_proxy.SendNotification(HEALTH_RESTORED_TITLE, $"The following issue is now resolved: {previousCheck.Message}", null, Settings);
|
||||
}
|
||||
|
||||
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||
{
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, null, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, GetPosterUrl(message.Series), Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
@ -75,5 +78,10 @@ public override ValidationResult Test()
|
|||
|
||||
return new ValidationResult(failures);
|
||||
}
|
||||
|
||||
private static string GetPosterUrl(Series series)
|
||||
{
|
||||
return series?.Images?.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ public class ApprisePayload
|
|||
|
||||
public string Body { get; set; }
|
||||
|
||||
public string Attachment { get; set; }
|
||||
|
||||
public AppriseNotificationType Type { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Notifications.Apprise
|
|||
{
|
||||
public interface IAppriseProxy
|
||||
{
|
||||
void SendNotification(string title, string message, AppriseSettings settings);
|
||||
void SendNotification(string title, string message, string posterUrl, AppriseSettings settings);
|
||||
ValidationFailure Test(AppriseSettings settings);
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ public AppriseProxy(IHttpClient httpClient, ILocalizationService localizationSer
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public void SendNotification(string title, string message, AppriseSettings settings)
|
||||
public void SendNotification(string title, string message, string posterUrl, AppriseSettings settings)
|
||||
{
|
||||
var payload = new ApprisePayload
|
||||
{
|
||||
|
|
@ -61,6 +61,11 @@ public void SendNotification(string title, string message, AppriseSettings setti
|
|||
payload.Tag = settings.Tags.Join(",");
|
||||
}
|
||||
|
||||
if (settings.IncludePoster && posterUrl.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
payload.Attachment = posterUrl;
|
||||
}
|
||||
|
||||
if (settings.AuthUsername.IsNotNullOrWhiteSpace() || settings.AuthPassword.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
requestBuilder.NetworkCredential = new BasicNetworkCredential(settings.AuthUsername, settings.AuthPassword);
|
||||
|
|
@ -86,10 +91,11 @@ public ValidationFailure Test(AppriseSettings settings)
|
|||
{
|
||||
const string title = "Sonarr - Test Notification";
|
||||
const string body = "Success! You have properly configured your apprise notification settings.";
|
||||
const string posterUrl = "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/Logo/128.png";
|
||||
|
||||
try
|
||||
{
|
||||
SendNotification(title, body, settings);
|
||||
SendNotification(title, body, posterUrl, settings);
|
||||
}
|
||||
catch (AppriseException ex) when (ex.InnerException is HttpException httpException)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,10 +59,13 @@ public AppriseSettings()
|
|||
[FieldDefinition(5, Label = "NotificationsAppriseSettingsTags", Type = FieldType.Tag, HelpText = "NotificationsAppriseSettingsTagsHelpText")]
|
||||
public IEnumerable<string> Tags { get; set; }
|
||||
|
||||
[FieldDefinition(6, Label = "Username", Type = FieldType.Textbox, HelpText = "NotificationsAppriseSettingsUsernameHelpText", Privacy = PrivacyLevel.UserName)]
|
||||
[FieldDefinition(6, Label = "NotificationsAppriseSettingsIncludePoster", Type = FieldType.Checkbox, HelpText = "NotificationsAppriseSettingsIncludePosterHelpText")]
|
||||
public bool IncludePoster { get; set; }
|
||||
|
||||
[FieldDefinition(7, Label = "Username", Type = FieldType.Textbox, HelpText = "NotificationsAppriseSettingsUsernameHelpText", Privacy = PrivacyLevel.UserName)]
|
||||
public string AuthUsername { get; set; }
|
||||
|
||||
[FieldDefinition(7, Label = "Password", Type = FieldType.Password, HelpText = "NotificationsAppriseSettingsPasswordHelpText", Privacy = PrivacyLevel.Password)]
|
||||
[FieldDefinition(8, Label = "Password", Type = FieldType.Password, HelpText = "NotificationsAppriseSettingsPasswordHelpText", Privacy = PrivacyLevel.Password)]
|
||||
public string AuthPassword { get; set; }
|
||||
|
||||
public override NzbDroneValidationResult Validate()
|
||||
|
|
|
|||
Loading…
Reference in a new issue