|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FluentValidation.Results;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
@ -329,12 +330,12 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
public override void OnRename(Series series, List<RenamedEpisodeFile> renamedFiles)
|
|
|
|
|
{
|
|
|
|
|
var attachments = new List<Embed>
|
|
|
|
|
{
|
|
|
|
|
new Embed
|
|
|
|
|
{
|
|
|
|
|
Title = series.Title,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
{
|
|
|
|
|
new ()
|
|
|
|
|
{
|
|
|
|
|
Title = series.Title,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var payload = CreatePayload("Renamed", attachments);
|
|
|
|
|
|
|
|
|
@ -361,8 +362,8 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
Color = (int)DiscordColors.Danger,
|
|
|
|
|
Fields = new List<DiscordField>
|
|
|
|
|
{
|
|
|
|
|
new DiscordField { Name = "Reason", Value = reason.ToString() },
|
|
|
|
|
new DiscordField { Name = "File name", Value = string.Format("```{0}```", deletedFile) }
|
|
|
|
|
new () { Name = "Reason", Value = reason.ToString() },
|
|
|
|
|
new () { Name = "File name", Value = string.Format("```{0}```", deletedFile) }
|
|
|
|
|
},
|
|
|
|
|
Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"),
|
|
|
|
|
};
|
|
|
|
@ -386,7 +387,7 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
Title = series.Title,
|
|
|
|
|
Description = "Series Added",
|
|
|
|
|
Color = (int)DiscordColors.Success,
|
|
|
|
|
Fields = new List<DiscordField> { new DiscordField { Name = "Links", Value = GetLinksString(series) } }
|
|
|
|
|
Fields = new List<DiscordField> { new () { Name = "Links", Value = GetLinksString(series) } }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (Settings.ImportFields.Contains((int)DiscordImportFieldType.Poster))
|
|
|
|
@ -425,7 +426,7 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
Title = series.Title,
|
|
|
|
|
Description = deleteMessage.DeletedFilesMessage,
|
|
|
|
|
Color = (int)DiscordColors.Danger,
|
|
|
|
|
Fields = new List<DiscordField> { new DiscordField { Name = "Links", Value = GetLinksString(series) } }
|
|
|
|
|
Fields = new List<DiscordField> { new () { Name = "Links", Value = GetLinksString(series) } }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (Settings.ImportFields.Contains((int)DiscordImportFieldType.Poster))
|
|
|
|
@ -503,12 +504,12 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
Color = (int)DiscordColors.Standard,
|
|
|
|
|
Fields = new List<DiscordField>()
|
|
|
|
|
{
|
|
|
|
|
new DiscordField()
|
|
|
|
|
new ()
|
|
|
|
|
{
|
|
|
|
|
Name = "Previous Version",
|
|
|
|
|
Value = updateMessage.PreviousVersion.ToString()
|
|
|
|
|
},
|
|
|
|
|
new DiscordField()
|
|
|
|
|
new ()
|
|
|
|
|
{
|
|
|
|
|
Name = "New Version",
|
|
|
|
|
Value = updateMessage.NewVersion.ToString()
|
|
|
|
@ -533,7 +534,7 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author,
|
|
|
|
|
IconUrl = "https://raw.githubusercontent.com/Sonarr/Sonarr/develop/Logo/256.png"
|
|
|
|
|
},
|
|
|
|
|
Url = $"http://thetvdb.com/?tab=series&id={series.TvdbId}",
|
|
|
|
|
Url = series?.TvdbId > 0 ? $"http://thetvdb.com/?tab=series&id={series.TvdbId}" : null,
|
|
|
|
|
Description = "Manual interaction needed",
|
|
|
|
|
Title = GetTitle(series, episodes),
|
|
|
|
|
Color = (int)DiscordColors.Standard,
|
|
|
|
@ -545,7 +546,7 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
{
|
|
|
|
|
embed.Thumbnail = new DiscordImage
|
|
|
|
|
{
|
|
|
|
|
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.Url
|
|
|
|
|
Url = series?.Images?.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.Url
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -553,7 +554,7 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
{
|
|
|
|
|
embed.Image = new DiscordImage
|
|
|
|
|
{
|
|
|
|
|
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.Url
|
|
|
|
|
Url = series?.Images?.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.Url
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -564,26 +565,26 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
switch ((DiscordManualInteractionFieldType)field)
|
|
|
|
|
{
|
|
|
|
|
case DiscordManualInteractionFieldType.Overview:
|
|
|
|
|
var overview = episodes.First().Overview ?? "";
|
|
|
|
|
var overview = episodes.FirstOrDefault()?.Overview ?? "";
|
|
|
|
|
discordField.Name = "Overview";
|
|
|
|
|
discordField.Value = overview.Length <= 300 ? overview : $"{overview.AsSpan(0, 300)}...";
|
|
|
|
|
break;
|
|
|
|
|
case DiscordManualInteractionFieldType.Rating:
|
|
|
|
|
discordField.Name = "Rating";
|
|
|
|
|
discordField.Value = episodes.First().Ratings.Value.ToString();
|
|
|
|
|
discordField.Value = episodes.FirstOrDefault()?.Ratings?.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
break;
|
|
|
|
|
case DiscordManualInteractionFieldType.Genres:
|
|
|
|
|
discordField.Name = "Genres";
|
|
|
|
|
discordField.Value = series.Genres.Take(5).Join(", ");
|
|
|
|
|
discordField.Value = series?.Genres.Take(5).Join(", ");
|
|
|
|
|
break;
|
|
|
|
|
case DiscordManualInteractionFieldType.Quality:
|
|
|
|
|
discordField.Name = "Quality";
|
|
|
|
|
discordField.Inline = true;
|
|
|
|
|
discordField.Value = message.Quality.Quality.Name;
|
|
|
|
|
discordField.Value = message.Quality?.Quality?.Name;
|
|
|
|
|
break;
|
|
|
|
|
case DiscordManualInteractionFieldType.Group:
|
|
|
|
|
discordField.Name = "Group";
|
|
|
|
|
discordField.Value = message.Episode.ParsedEpisodeInfo.ReleaseGroup;
|
|
|
|
|
discordField.Value = message.Episode?.ParsedEpisodeInfo?.ReleaseGroup;
|
|
|
|
|
break;
|
|
|
|
|
case DiscordManualInteractionFieldType.Size:
|
|
|
|
|
discordField.Name = "Size";
|
|
|
|
@ -592,7 +593,7 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
break;
|
|
|
|
|
case DiscordManualInteractionFieldType.DownloadTitle:
|
|
|
|
|
discordField.Name = "Download";
|
|
|
|
|
discordField.Value = string.Format("```{0}```", message.TrackedDownload.DownloadItem.Title);
|
|
|
|
|
discordField.Value = $"```{message.TrackedDownload.DownloadItem.Title}```";
|
|
|
|
|
break;
|
|
|
|
|
case DiscordManualInteractionFieldType.Links:
|
|
|
|
|
discordField.Name = "Links";
|
|
|
|
@ -677,10 +678,16 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
|
|
|
|
|
private string GetLinksString(Series series)
|
|
|
|
|
{
|
|
|
|
|
var links = new List<string>();
|
|
|
|
|
if (series == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
links.Add($"[The TVDB](https://thetvdb.com/?tab=series&id={series.TvdbId})");
|
|
|
|
|
links.Add($"[Trakt](https://trakt.tv/search/tvdb/{series.TvdbId}?id_type=show)");
|
|
|
|
|
var links = new List<string>
|
|
|
|
|
{
|
|
|
|
|
$"[The TVDB](https://thetvdb.com/?tab=series&id={series.TvdbId})",
|
|
|
|
|
$"[Trakt](https://trakt.tv/search/tvdb/{series.TvdbId}?id_type=show)"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (series.ImdbId.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
@ -692,6 +699,11 @@ namespace NzbDrone.Core.Notifications.Discord
|
|
|
|
|
|
|
|
|
|
private string GetTitle(Series series, List<Episode> episodes)
|
|
|
|
|
{
|
|
|
|
|
if (series == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (series.SeriesType == SeriesTypes.Daily)
|
|
|
|
|
{
|
|
|
|
|
var episode = episodes.First();
|
|
|
|
|