1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

New: Genres and Images for Webhooks and Notifiarr

(cherry picked from commit fd3dd1ab7dc86cd9e231fa432cc8d2772d5a4bad)

Closes #10055
This commit is contained in:
Mark McDowall 2024-05-23 06:42:16 -07:00 committed by Bogdan
parent 4cec41324b
commit 792b8182b2
5 changed files with 47 additions and 12 deletions

View File

@ -3,6 +3,7 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Notifications.Webhook;
@ -15,8 +16,8 @@ public class Notifiarr : WebhookBase<NotifiarrSettings>
{
private readonly INotifiarrProxy _proxy;
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository)
: base(configFileProvider, configService, localizationService, tagRepository)
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository, IMapCoversToLocal mediaCoverService)
: base(configFileProvider, configService, localizationService, tagRepository, mediaCoverService)
{
_proxy = proxy;
}

View File

@ -3,6 +3,7 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Tags;
@ -14,8 +15,8 @@ public class Webhook : WebhookBase<WebhookSettings>
{
private readonly IWebhookProxy _proxy;
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository)
: base(configFileProvider, configService, localizationService, tagRepository)
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository, IMapCoversToLocal mediaCoverService)
: base(configFileProvider, configService, localizationService, tagRepository, mediaCoverService)
{
_proxy = proxy;
}

View File

@ -4,6 +4,7 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Tags;
@ -17,13 +18,15 @@ public abstract class WebhookBase<TSettings> : NotificationBase<TSettings>
private readonly IConfigService _configService;
protected readonly ILocalizationService _localizationService;
private readonly ITagRepository _tagRepository;
private readonly IMapCoversToLocal _mediaCoverService;
protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository)
protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository, IMapCoversToLocal mediaCoverService)
{
_configFileProvider = configFileProvider;
_configService = configService;
_localizationService = localizationService;
_tagRepository = tagRepository;
_mediaCoverService = mediaCoverService;
}
protected WebhookGrabPayload BuildOnGrabPayload(GrabMessage message)
@ -36,7 +39,7 @@ protected WebhookGrabPayload BuildOnGrabPayload(GrabMessage message)
EventType = WebhookEventType.Grab,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Movie = new WebhookMovie(message.Movie, GetTagLabels(message.Movie)),
Movie = GetMovie(message.Movie),
RemoteMovie = new WebhookRemoteMovie(remoteMovie),
Release = new WebhookRelease(quality, remoteMovie),
DownloadClient = message.DownloadClientName,
@ -55,7 +58,7 @@ protected WebhookImportPayload BuildOnDownloadPayload(DownloadMessage message)
EventType = WebhookEventType.Download,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Movie = new WebhookMovie(message.Movie, GetTagLabels(message.Movie)),
Movie = GetMovie(message.Movie),
RemoteMovie = new WebhookRemoteMovie(message.Movie),
MovieFile = new WebhookMovieFile(movieFile),
Release = new WebhookGrabbedRelease(message.Release),
@ -86,7 +89,7 @@ protected WebhookAddedPayload BuildOnMovieAdded(Movie movie)
EventType = WebhookEventType.MovieAdded,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Movie = new WebhookMovie(movie, GetTagLabels(movie)),
Movie = GetMovie(movie),
AddMethod = movie.AddOptions.AddMethod
};
}
@ -98,7 +101,7 @@ protected WebhookMovieFileDeletePayload BuildOnMovieFileDelete(MovieFileDeleteMe
EventType = WebhookEventType.MovieFileDelete,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Movie = new WebhookMovie(deleteMessage.Movie, GetTagLabels(deleteMessage.Movie)),
Movie = GetMovie(deleteMessage.Movie),
MovieFile = new WebhookMovieFile(deleteMessage.MovieFile),
DeleteReason = deleteMessage.Reason
};
@ -111,7 +114,7 @@ protected WebhookMovieDeletePayload BuildOnMovieDelete(MovieDeleteMessage delete
EventType = WebhookEventType.MovieDelete,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Movie = new WebhookMovie(deleteMessage.Movie, GetTagLabels(deleteMessage.Movie)),
Movie = GetMovie(deleteMessage.Movie),
DeletedFiles = deleteMessage.DeletedFiles
};
@ -130,7 +133,7 @@ protected WebhookRenamePayload BuildOnRenamePayload(Movie movie, List<RenamedMov
EventType = WebhookEventType.Rename,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Movie = new WebhookMovie(movie, GetTagLabels(movie)),
Movie = GetMovie(movie),
RenamedMovieFiles = renamedFiles.ConvertAll(x => new WebhookRenamedMovieFile(x))
};
}
@ -185,7 +188,7 @@ protected WebhookManualInteractionPayload BuildManualInteractionRequiredPayload(
EventType = WebhookEventType.ManualInteractionRequired,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Movie = new WebhookMovie(message.Movie, GetTagLabels(message.Movie)),
Movie = GetMovie(message.Movie),
DownloadInfo = new WebhookDownloadClientItem(quality, message.TrackedDownload.DownloadItem),
DownloadClient = message.DownloadClientInfo?.Name,
DownloadClientType = message.DownloadClientInfo?.Type,
@ -232,6 +235,13 @@ protected WebhookPayload BuildTestPayload()
};
}
private WebhookMovie GetMovie(Movie movie)
{
_mediaCoverService.ConvertToLocalUrls(movie.Id, movie.MovieMetadata.Value.Images);
return new WebhookMovie(movie, GetTagLabels(movie));
}
private List<string> GetTagLabels(Movie movie)
{
return _tagRepository.GetTags(movie.Tags)

View File

@ -0,0 +1,18 @@
using NzbDrone.Core.MediaCover;
namespace NzbDrone.Core.Notifications.Webhook
{
public class WebhookImage
{
public MediaCoverTypes CoverType { get; set; }
public string Url { get; set; }
public string RemoteUrl { get; set; }
public WebhookImage(MediaCover.MediaCover image)
{
CoverType = image.CoverType;
RemoteUrl = image.RemoteUrl;
Url = image.Url;
}
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
@ -16,6 +17,8 @@ public class WebhookMovie
public int TmdbId { get; set; }
public string ImdbId { get; set; }
public string Overview { get; set; }
public List<string> Genres { get; set; }
public List<WebhookImage> Images { get; set; }
public List<string> Tags { get; set; }
public WebhookMovie()
@ -32,6 +35,8 @@ public WebhookMovie(Movie movie, List<string> tags)
TmdbId = movie.TmdbId;
ImdbId = movie.ImdbId;
Overview = movie.MovieMetadata.Value.Overview;
Genres = movie.MovieMetadata.Value.Genres;
Images = movie.MovieMetadata.Value.Images.Select(i => new WebhookImage(i)).ToList();
Tags = tags;
}