mirror of https://github.com/Radarr/Radarr
New: Tags field for Notifiarr and Webhook
This commit is contained in:
parent
8837473ed8
commit
deac2bdf5c
|
@ -625,7 +625,7 @@ namespace NzbDrone.Core.Notifications.Discord
|
|||
|
||||
private IEnumerable<string> GetTagLabels(Movie movie)
|
||||
{
|
||||
return movie.Tags?.Select(t => _tagRepository.Get(t)?.Label).Take(5).OrderBy(t => t);
|
||||
return movie.Tags?.Select(t => _tagRepository.Get(t)?.Label).OrderBy(t => t).Take(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using NzbDrone.Core.Localization;
|
|||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Notifications.Webhook;
|
||||
using NzbDrone.Core.Tags;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Notifiarr
|
||||
|
@ -14,8 +15,8 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|||
{
|
||||
private readonly INotifiarrProxy _proxy;
|
||||
|
||||
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService)
|
||||
: base(configFileProvider, configService, localizationService)
|
||||
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository)
|
||||
: base(configFileProvider, configService, localizationService, tagRepository)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using NzbDrone.Core.Configuration;
|
|||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Tags;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
|
@ -13,8 +14,8 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
{
|
||||
private readonly IWebhookProxy _proxy;
|
||||
|
||||
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService)
|
||||
: base(configFileProvider, configService, localizationService)
|
||||
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository)
|
||||
: base(configFileProvider, configService, localizationService, tagRepository)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using NzbDrone.Core.Configuration;
|
|||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Tags;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
|
@ -15,12 +16,14 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private readonly IConfigService _configService;
|
||||
protected readonly ILocalizationService _localizationService;
|
||||
private readonly ITagRepository _tagRepository;
|
||||
|
||||
protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService)
|
||||
protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
_configService = configService;
|
||||
_localizationService = localizationService;
|
||||
_tagRepository = tagRepository;
|
||||
}
|
||||
|
||||
protected WebhookGrabPayload BuildOnGrabPayload(GrabMessage message)
|
||||
|
@ -33,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
EventType = WebhookEventType.Grab,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(message.Movie),
|
||||
Movie = new WebhookMovie(message.Movie, tags: GetTagLabels(message.Movie)),
|
||||
RemoteMovie = new WebhookRemoteMovie(remoteMovie),
|
||||
Release = new WebhookRelease(quality, remoteMovie),
|
||||
DownloadClient = message.DownloadClientName,
|
||||
|
@ -52,7 +55,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
EventType = WebhookEventType.Download,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(message.Movie),
|
||||
Movie = new WebhookMovie(message.Movie, tags: GetTagLabels(message.Movie)),
|
||||
RemoteMovie = new WebhookRemoteMovie(message.Movie),
|
||||
MovieFile = new WebhookMovieFile(movieFile),
|
||||
Release = new WebhookGrabbedRelease(message.Release),
|
||||
|
@ -83,7 +86,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
EventType = WebhookEventType.MovieAdded,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(movie),
|
||||
Movie = new WebhookMovie(movie, tags: GetTagLabels(movie)),
|
||||
AddMethod = movie.AddOptions.AddMethod
|
||||
};
|
||||
}
|
||||
|
@ -95,7 +98,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
EventType = WebhookEventType.MovieFileDelete,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(deleteMessage.Movie),
|
||||
Movie = new WebhookMovie(deleteMessage.Movie, tags: GetTagLabels(deleteMessage.Movie)),
|
||||
MovieFile = new WebhookMovieFile(deleteMessage.MovieFile),
|
||||
DeleteReason = deleteMessage.Reason
|
||||
};
|
||||
|
@ -108,7 +111,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
EventType = WebhookEventType.MovieDelete,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(deleteMessage.Movie),
|
||||
Movie = new WebhookMovie(deleteMessage.Movie, tags: GetTagLabels(deleteMessage.Movie)),
|
||||
DeletedFiles = deleteMessage.DeletedFiles
|
||||
};
|
||||
|
||||
|
@ -127,7 +130,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
EventType = WebhookEventType.Rename,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(movie),
|
||||
Movie = new WebhookMovie(movie, tags: GetTagLabels(movie)),
|
||||
RenamedMovieFiles = renamedFiles.ConvertAll(x => new WebhookRenamedMovieFile(x))
|
||||
};
|
||||
}
|
||||
|
@ -182,7 +185,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
EventType = WebhookEventType.ManualInteractionRequired,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(message.Movie),
|
||||
Movie = new WebhookMovie(message.Movie, tags: GetTagLabels(message.Movie)),
|
||||
DownloadInfo = new WebhookDownloadClientItem(quality, message.TrackedDownload.DownloadItem),
|
||||
DownloadClient = message.DownloadClientName,
|
||||
DownloadClientType = message.DownloadClientType,
|
||||
|
@ -205,7 +208,8 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
Title = "Test Title",
|
||||
Year = 1970,
|
||||
FolderPath = "C:\\testpath",
|
||||
ReleaseDate = "1970-01-01"
|
||||
ReleaseDate = "1970-01-01",
|
||||
Tags = new[] { "test-tag" }
|
||||
},
|
||||
RemoteMovie = new WebhookRemoteMovie
|
||||
{
|
||||
|
@ -225,5 +229,10 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetTagLabels(Movie movie)
|
||||
{
|
||||
return movie.Tags?.Select(t => _tagRepository.Get(t)?.Label).OrderBy(t => t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies;
|
||||
|
@ -15,6 +16,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
public int TmdbId { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public IEnumerable<string> Tags { get; set; }
|
||||
|
||||
public WebhookMovie()
|
||||
{
|
||||
|
@ -32,6 +34,12 @@ namespace NzbDrone.Core.Notifications.Webhook
|
|||
Overview = movie.MovieMetadata.Value.Overview;
|
||||
}
|
||||
|
||||
public WebhookMovie(Movie movie, IEnumerable<string> tags)
|
||||
: this(movie)
|
||||
{
|
||||
Tags = tags;
|
||||
}
|
||||
|
||||
public WebhookMovie(Movie movie, MovieFile movieFile)
|
||||
: this(movie)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue