mirror of
https://github.com/Radarr/Radarr
synced 2025-02-23 23:01:10 +00:00
New: Tags field for Discord
This commit is contained in:
parent
3a7b27fb45
commit
3ff8e511b5
3 changed files with 33 additions and 7 deletions
|
@ -8,6 +8,7 @@
|
|||
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 @@ public override void OnGrab(GrabMessage message)
|
|||
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 @@ public override void OnDownload(DownloadMessage message)
|
|||
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 @@ public override void OnManualInteractionRequired(ManualInteractionRequiredMessag
|
|||
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 @@ private string GetTitle(Movie movie)
|
|||
|
||||
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 @@ public enum DiscordGrabFieldType
|
|||
Fanart,
|
||||
Indexer,
|
||||
CustomFormats,
|
||||
CustomFormatScore
|
||||
CustomFormatScore,
|
||||
Tags
|
||||
}
|
||||
|
||||
public enum DiscordImportFieldType
|
||||
|
@ -31,7 +32,8 @@ public enum DiscordImportFieldType
|
|||
Links,
|
||||
Release,
|
||||
Poster,
|
||||
Fanart
|
||||
Fanart,
|
||||
Tags
|
||||
}
|
||||
|
||||
public enum DiscordManualInteractionFieldType
|
||||
|
@ -45,6 +47,7 @@ public enum DiscordManualInteractionFieldType
|
|||
Links,
|
||||
DownloadTitle,
|
||||
Poster,
|
||||
Fanart
|
||||
Fanart,
|
||||
Tags
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ public DiscordSettings()
|
|||
(int)DiscordGrabFieldType.Fanart,
|
||||
(int)DiscordGrabFieldType.Indexer,
|
||||
(int)DiscordGrabFieldType.CustomFormats,
|
||||
(int)DiscordGrabFieldType.CustomFormatScore
|
||||
(int)DiscordGrabFieldType.CustomFormatScore,
|
||||
(int)DiscordGrabFieldType.Tags
|
||||
};
|
||||
ImportFields = new[]
|
||||
{
|
||||
|
@ -49,7 +50,8 @@ public DiscordSettings()
|
|||
(int)DiscordImportFieldType.Links,
|
||||
(int)DiscordImportFieldType.Release,
|
||||
(int)DiscordImportFieldType.Poster,
|
||||
(int)DiscordImportFieldType.Fanart
|
||||
(int)DiscordImportFieldType.Fanart,
|
||||
(int)DiscordImportFieldType.Tags
|
||||
};
|
||||
ManualInteractionFields = new[]
|
||||
{
|
||||
|
@ -62,7 +64,8 @@ public DiscordSettings()
|
|||
(int)DiscordManualInteractionFieldType.Links,
|
||||
(int)DiscordManualInteractionFieldType.DownloadTitle,
|
||||
(int)DiscordManualInteractionFieldType.Poster,
|
||||
(int)DiscordManualInteractionFieldType.Fanart
|
||||
(int)DiscordManualInteractionFieldType.Fanart,
|
||||
(int)DiscordManualInteractionFieldType.Tags
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue