New: Tags field for Discord

pull/9531/head
Bogdan 11 months ago
parent 3a7b27fb45
commit 3ff8e511b5

@ -8,6 +8,7 @@ using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Notifications.Discord.Payloads;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.Discord
@ -15,10 +16,12 @@ namespace NzbDrone.Core.Notifications.Discord
public class Discord : NotificationBase<DiscordSettings>
{
private readonly IDiscordProxy _proxy;
private readonly ITagRepository _tagRepository;
public Discord(IDiscordProxy proxy)
public Discord(IDiscordProxy proxy, ITagRepository tagRepository)
{
_proxy = proxy;
_tagRepository = tagRepository;
}
public override string Name => "Discord";
@ -110,6 +113,10 @@ namespace NzbDrone.Core.Notifications.Discord
discordField.Name = "Indexer";
discordField.Value = message.RemoteMovie.Release.Indexer;
break;
case DiscordGrabFieldType.Tags:
discordField.Name = "Tags";
discordField.Value = GetTagLabels(message.Movie)?.Join(", ") ?? string.Empty;
break;
}
if (discordField.Name.IsNotNullOrWhiteSpace() && discordField.Value.IsNotNullOrWhiteSpace())
@ -214,6 +221,10 @@ namespace NzbDrone.Core.Notifications.Discord
discordField.Name = "Links";
discordField.Value = GetLinksString(message.Movie);
break;
case DiscordImportFieldType.Tags:
discordField.Name = "Tags";
discordField.Value = GetTagLabels(message.Movie)?.Join(", ") ?? string.Empty;
break;
}
if (discordField.Name.IsNotNullOrWhiteSpace() && discordField.Value.IsNotNullOrWhiteSpace())
@ -499,6 +510,10 @@ namespace NzbDrone.Core.Notifications.Discord
discordField.Name = "Links";
discordField.Value = GetLinksString(message.Movie);
break;
case DiscordManualInteractionFieldType.Tags:
discordField.Name = "Tags";
discordField.Value = GetTagLabels(message.Movie)?.Join(", ") ?? string.Empty;
break;
}
if (discordField.Name.IsNotNullOrWhiteSpace() && discordField.Value.IsNotNullOrWhiteSpace())
@ -604,5 +619,10 @@ namespace NzbDrone.Core.Notifications.Discord
return title.Length > 256 ? $"{title.AsSpan(0, 253)}..." : title;
}
private IEnumerable<string> GetTagLabels(Movie movie)
{
return movie.Tags?.Select(t => _tagRepository.Get(t)?.Label).Take(5).OrderBy(t => t);
}
}
}

@ -14,7 +14,8 @@ namespace NzbDrone.Core.Notifications.Discord
Fanart,
Indexer,
CustomFormats,
CustomFormatScore
CustomFormatScore,
Tags
}
public enum DiscordImportFieldType
@ -31,7 +32,8 @@ namespace NzbDrone.Core.Notifications.Discord
Links,
Release,
Poster,
Fanart
Fanart,
Tags
}
public enum DiscordManualInteractionFieldType
@ -45,6 +47,7 @@ namespace NzbDrone.Core.Notifications.Discord
Links,
DownloadTitle,
Poster,
Fanart
Fanart,
Tags
}
}

@ -33,7 +33,8 @@ namespace NzbDrone.Core.Notifications.Discord
(int)DiscordGrabFieldType.Fanart,
(int)DiscordGrabFieldType.Indexer,
(int)DiscordGrabFieldType.CustomFormats,
(int)DiscordGrabFieldType.CustomFormatScore
(int)DiscordGrabFieldType.CustomFormatScore,
(int)DiscordGrabFieldType.Tags
};
ImportFields = new[]
{
@ -49,7 +50,8 @@ namespace NzbDrone.Core.Notifications.Discord
(int)DiscordImportFieldType.Links,
(int)DiscordImportFieldType.Release,
(int)DiscordImportFieldType.Poster,
(int)DiscordImportFieldType.Fanart
(int)DiscordImportFieldType.Fanart,
(int)DiscordImportFieldType.Tags
};
ManualInteractionFields = new[]
{
@ -62,7 +64,8 @@ namespace NzbDrone.Core.Notifications.Discord
(int)DiscordManualInteractionFieldType.Links,
(int)DiscordManualInteractionFieldType.DownloadTitle,
(int)DiscordManualInteractionFieldType.Poster,
(int)DiscordManualInteractionFieldType.Fanart
(int)DiscordManualInteractionFieldType.Fanart,
(int)DiscordManualInteractionFieldType.Tags
};
}

Loading…
Cancel
Save