mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-19 17:32:38 +01:00
New: Tags field for Notifiarr and Webhook
This commit is contained in:
parent
8837473ed8
commit
deac2bdf5c
@ -625,7 +625,7 @@ private string GetTitle(Movie movie)
|
||||
|
||||
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.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 @@ public class Notifiarr : WebhookBase<NotifiarrSettings>
|
||||
{
|
||||
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.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 @@ public class Webhook : WebhookBase<WebhookSettings>
|
||||
{
|
||||
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.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 @@ public abstract class WebhookBase<TSettings> : NotificationBase<TSettings>
|
||||
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 @@ protected WebhookGrabPayload BuildOnGrabPayload(GrabMessage message)
|
||||
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 @@ protected WebhookImportPayload BuildOnDownloadPayload(DownloadMessage message)
|
||||
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 @@ protected WebhookAddedPayload BuildOnMovieAdded(Movie movie)
|
||||
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 @@ protected WebhookMovieFileDeletePayload BuildOnMovieFileDelete(MovieFileDeleteMe
|
||||
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 @@ protected WebhookMovieDeletePayload BuildOnMovieDelete(MovieDeleteMessage delete
|
||||
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 @@ protected WebhookRenamePayload BuildOnRenamePayload(Movie movie, List<RenamedMov
|
||||
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 @@ protected WebhookManualInteractionPayload BuildManualInteractionRequiredPayload(
|
||||
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 @@ protected WebhookPayload BuildTestPayload()
|
||||
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 @@ protected WebhookPayload BuildTestPayload()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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 @@ public class WebhookMovie
|
||||
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 @@ public WebhookMovie(Movie movie)
|
||||
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
Block a user