diff --git a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs index 09f2df3cf..17159bf37 100644 --- a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs @@ -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 { 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; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 915718116..8384508d4 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -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 { 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; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs index 8b7c48d1f..6de5d086c 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs @@ -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 : NotificationBase 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 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 GetTagLabels(Movie movie) { return _tagRepository.GetTags(movie.Tags) diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookImage.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookImage.cs new file mode 100644 index 000000000..87f511dc1 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookImage.cs @@ -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; + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs index df651e8e2..5bf362573 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovie.cs @@ -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 Genres { get; set; } + public List Images { get; set; } public List Tags { get; set; } public WebhookMovie() @@ -32,6 +35,8 @@ public WebhookMovie(Movie movie, List 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; }