diff --git a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs index 3d5300de8..25ea84301 100644 --- a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; +using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Music; using NzbDrone.Core.Notifications.Webhook; @@ -13,8 +14,8 @@ namespace NzbDrone.Core.Notifications.Notifiarr { private readonly INotifiarrProxy _proxy; - public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService) - : base(configFileProvider, configService) + public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, IMapCoversToLocal mediaCoverService) + : base(configFileProvider, configService, mediaCoverService) { _proxy = proxy; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 9c0f1855b..0b78dcbec 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; +using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Music; using NzbDrone.Core.Validation; @@ -12,8 +13,8 @@ namespace NzbDrone.Core.Notifications.Webhook { private readonly IWebhookProxy _proxy; - public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService) - : base(configFileProvider, configService) + public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, IMapCoversToLocal mediaCoverService) + : base(configFileProvider, configService, mediaCoverService) { _proxy = proxy; } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs index 11a324595..a9070245d 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookAlbum.cs @@ -7,6 +7,17 @@ namespace NzbDrone.Core.Notifications.Webhook { public class WebhookAlbum { + public int Id { get; set; } + public string MBId { get; set; } + public string Title { get; set; } + public string Disambiguation { get; set; } + public string Overview { get; set; } + public string AlbumType { get; set; } + public List SecondaryAlbumTypes { get; set; } + public DateTime? ReleaseDate { get; set; } + public List Genres { get; set; } + public List Images { get; set; } + public WebhookAlbum() { } @@ -20,18 +31,9 @@ namespace NzbDrone.Core.Notifications.Webhook Overview = album.Overview; AlbumType = album.AlbumType; SecondaryAlbumTypes = album.SecondaryTypes.Select(x => x.Name).ToList(); - Genres = album.Genres; ReleaseDate = album.ReleaseDate; + Genres = album.Genres; + Images = album.Images.Select(i => new WebhookImage(i)).ToList(); } - - public int Id { get; set; } - public string MBId { get; set; } - public string Title { get; set; } - public string Disambiguation { get; set; } - public string Overview { get; set; } - public string AlbumType { get; set; } - public List SecondaryAlbumTypes { get; set; } - public List Genres { get; set; } - public DateTime? ReleaseDate { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs index 98acf34c0..e758df600 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookArtist.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using NzbDrone.Core.Music; namespace NzbDrone.Core.Notifications.Webhook @@ -13,6 +14,7 @@ namespace NzbDrone.Core.Notifications.Webhook public string Type { get; set; } public string Overview { get; set; } public List Genres { get; set; } + public List Images { get; set; } public WebhookArtist() { @@ -24,10 +26,11 @@ namespace NzbDrone.Core.Notifications.Webhook Name = artist.Name; Disambiguation = artist.Metadata.Value.Disambiguation; Path = artist.Path; + MBId = artist.Metadata.Value.ForeignArtistId; Type = artist.Metadata.Value.Type; Overview = artist.Metadata.Value.Overview; Genres = artist.Metadata.Value.Genres; - MBId = artist.Metadata.Value.ForeignArtistId; + Images = artist.Metadata.Value.Images.Select(i => new WebhookImage(i)).ToList(); } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs index 9c84efb3e..6d1013194 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookBase.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Core.Configuration; +using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Music; using NzbDrone.Core.ThingiProvider; @@ -12,11 +13,13 @@ namespace NzbDrone.Core.Notifications.Webhook { private readonly IConfigFileProvider _configFileProvider; private readonly IConfigService _configService; + private readonly IMapCoversToLocal _mediaCoverService; - protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService) + protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService, IMapCoversToLocal mediaCoverService) { _configFileProvider = configFileProvider; _configService = configService; + _mediaCoverService = mediaCoverService; } public WebhookGrabPayload BuildOnGrabPayload(GrabMessage message) @@ -29,8 +32,8 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.Grab, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(message.Artist), - Albums = remoteAlbum.Albums.Select(x => new WebhookAlbum(x)).ToList(), + Artist = GetArtist(message.Artist), + Albums = remoteAlbum.Albums.Select(GetAlbum).ToList(), Release = new WebhookRelease(quality, remoteAlbum), DownloadClient = message.DownloadClientName, DownloadClientType = message.DownloadClientType, @@ -47,8 +50,8 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.Download, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(message.Artist), - Album = new WebhookAlbum(message.Album), + Artist = GetArtist(message.Artist), + Album = GetAlbum(message.Album), Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y))).ToList(), TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)), IsUpgrade = message.OldFiles.Any(), @@ -89,7 +92,7 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.ImportFailure, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(message.Artist), + Artist = GetArtist(message.Artist), Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y))).ToList(), TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)), IsUpgrade = message.OldFiles.Any(), @@ -113,7 +116,7 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.Rename, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(artist), + Artist = GetArtist(artist), RenamedTrackFiles = renamedFiles.ConvertAll(x => new WebhookRenamedTrackFile(x)) }; } @@ -125,7 +128,7 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.Retag, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(message.Artist), + Artist = GetArtist(message.Artist), TrackFile = new WebhookTrackFile(message.TrackFile) }; } @@ -137,7 +140,7 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.ArtistAdd, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(addMessage.Artist), + Artist = GetArtist(addMessage.Artist), }; } @@ -148,7 +151,7 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.ArtistDelete, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(deleteMessage.Artist), + Artist = GetArtist(deleteMessage.Artist), DeletedFiles = deleteMessage.DeletedFiles }; } @@ -160,8 +163,8 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.AlbumDelete, InstanceName = _configFileProvider.InstanceName, ApplicationUrl = _configService.ApplicationUrl, - Artist = new WebhookArtist(deleteMessage.Album.Artist), - Album = new WebhookAlbum(deleteMessage.Album), + Artist = GetArtist(deleteMessage.Album.Artist), + Album = GetAlbum(deleteMessage.Album), DeletedFiles = deleteMessage.DeletedFiles }; } @@ -230,5 +233,29 @@ namespace NzbDrone.Core.Notifications.Webhook } }; } + + private WebhookArtist GetArtist(Artist artist) + { + if (artist == null) + { + return null; + } + + _mediaCoverService.ConvertToLocalUrls(artist.Id, MediaCoverEntity.Artist, artist.Metadata.Value.Images); + + return new WebhookArtist(artist); + } + + private WebhookAlbum GetAlbum(Album album) + { + if (album == null) + { + return null; + } + + _mediaCoverService.ConvertToLocalUrls(album.Id, MediaCoverEntity.Album, album.Images); + + return new WebhookAlbum(album); + } } } 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; + } + } +}