|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using FluentValidation.Results;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Core.Localization;
|
|
|
|
|
using NzbDrone.Core.MediaCover;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
@ -12,6 +13,8 @@ namespace NzbDrone.Core.Notifications.Gotify
|
|
|
|
|
{
|
|
|
|
|
public class Gotify : NotificationBase<GotifySettings>
|
|
|
|
|
{
|
|
|
|
|
private const string SonarrImageUrl = "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/Logo/128.png";
|
|
|
|
|
|
|
|
|
|
private readonly IGotifyProxy _proxy;
|
|
|
|
|
private readonly ILocalizationService _localizationService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
@ -88,20 +91,30 @@ namespace NzbDrone.Core.Notifications.Gotify
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
sb.AppendLine("This is a test message from Sonarr");
|
|
|
|
|
|
|
|
|
|
var payload = new GotifyMessage
|
|
|
|
|
{
|
|
|
|
|
Title = title,
|
|
|
|
|
Priority = Settings.Priority
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (Settings.IncludeSeriesPoster)
|
|
|
|
|
{
|
|
|
|
|
isMarkdown = true;
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("\r");
|
|
|
|
|
sb.AppendLine($"\r");
|
|
|
|
|
payload.SetImage(SonarrImageUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var payload = new GotifyMessage
|
|
|
|
|
if (Settings.MetadataLinks.Any())
|
|
|
|
|
{
|
|
|
|
|
Title = title,
|
|
|
|
|
Message = sb.ToString(),
|
|
|
|
|
Priority = Settings.Priority
|
|
|
|
|
};
|
|
|
|
|
isMarkdown = true;
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("");
|
|
|
|
|
sb.AppendLine("[Sonarr.tv](https://sonarr.tv)");
|
|
|
|
|
payload.SetClickUrl("https://sonarr.tv");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
payload.Message = sb.ToString();
|
|
|
|
|
payload.SetContentType(isMarkdown);
|
|
|
|
|
|
|
|
|
|
_proxy.SendNotification(payload, Settings);
|
|
|
|
@ -122,24 +135,72 @@ namespace NzbDrone.Core.Notifications.Gotify
|
|
|
|
|
|
|
|
|
|
sb.AppendLine(message);
|
|
|
|
|
|
|
|
|
|
if (Settings.IncludeSeriesPoster && series != null)
|
|
|
|
|
var payload = new GotifyMessage
|
|
|
|
|
{
|
|
|
|
|
var poster = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl;
|
|
|
|
|
Title = title,
|
|
|
|
|
Priority = Settings.Priority
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (series != null)
|
|
|
|
|
{
|
|
|
|
|
if (Settings.IncludeSeriesPoster)
|
|
|
|
|
{
|
|
|
|
|
var poster = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl;
|
|
|
|
|
|
|
|
|
|
if (poster != null)
|
|
|
|
|
{
|
|
|
|
|
isMarkdown = true;
|
|
|
|
|
sb.AppendLine($"\r");
|
|
|
|
|
payload.SetImage(poster);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (poster != null)
|
|
|
|
|
if (Settings.MetadataLinks.Any())
|
|
|
|
|
{
|
|
|
|
|
isMarkdown = true;
|
|
|
|
|
sb.AppendLine($"\r");
|
|
|
|
|
sb.AppendLine("");
|
|
|
|
|
|
|
|
|
|
foreach (var link in Settings.MetadataLinks)
|
|
|
|
|
{
|
|
|
|
|
var linkType = (MetadataLinkType)link;
|
|
|
|
|
var linkText = "";
|
|
|
|
|
var linkUrl = "";
|
|
|
|
|
|
|
|
|
|
if (linkType == MetadataLinkType.Imdb && series.ImdbId.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
linkText = "IMDb";
|
|
|
|
|
linkUrl = $"https://www.imdb.com/title/{series.ImdbId}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (linkType == MetadataLinkType.Tvdb && series.TvdbId > 0)
|
|
|
|
|
{
|
|
|
|
|
linkText = "TVDb";
|
|
|
|
|
linkUrl = $"http://www.thetvdb.com/?tab=series&id={series.TvdbId}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (linkType == MetadataLinkType.Trakt && series.TvdbId > 0)
|
|
|
|
|
{
|
|
|
|
|
linkText = "TVMaze";
|
|
|
|
|
linkUrl = $"http://trakt.tv/search/tvdb/{series.TvdbId}?id_type=show";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (linkType == MetadataLinkType.Tvmaze && series.TvMazeId > 0)
|
|
|
|
|
{
|
|
|
|
|
linkText = "Trakt";
|
|
|
|
|
linkUrl = $"http://www.tvmaze.com/shows/{series.TvMazeId}/_";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sb.AppendLine($"[{linkText}]({linkUrl})");
|
|
|
|
|
|
|
|
|
|
if (link == Settings.PreferredMetadataLink)
|
|
|
|
|
{
|
|
|
|
|
payload.SetClickUrl(linkUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var payload = new GotifyMessage
|
|
|
|
|
{
|
|
|
|
|
Title = title,
|
|
|
|
|
Message = sb.ToString(),
|
|
|
|
|
Priority = Settings.Priority
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
payload.Message = sb.ToString();
|
|
|
|
|
payload.SetContentType(isMarkdown);
|
|
|
|
|
|
|
|
|
|
_proxy.SendNotification(payload, Settings);
|
|
|
|
|