mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-05 20:42:19 -07:00
New: Genres and Images for Webhooks and Notifiarr
(cherry picked from commit fd3dd1ab7dc86cd9e231fa432cc8d2772d5a4bad) Closes #4832
This commit is contained in:
parent
36998abba0
commit
261f30d268
6 changed files with 80 additions and 28 deletions
|
@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Core.Notifications.Webhook;
|
using NzbDrone.Core.Notifications.Webhook;
|
||||||
|
@ -13,8 +14,8 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
||||||
{
|
{
|
||||||
private readonly INotifiarrProxy _proxy;
|
private readonly INotifiarrProxy _proxy;
|
||||||
|
|
||||||
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService)
|
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, IMapCoversToLocal mediaCoverService)
|
||||||
: base(configFileProvider, configService)
|
: base(configFileProvider, configService, mediaCoverService)
|
||||||
{
|
{
|
||||||
_proxy = proxy;
|
_proxy = proxy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
@ -12,8 +13,8 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
{
|
{
|
||||||
private readonly IWebhookProxy _proxy;
|
private readonly IWebhookProxy _proxy;
|
||||||
|
|
||||||
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService)
|
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, IMapCoversToLocal mediaCoverService)
|
||||||
: base(configFileProvider, configService)
|
: base(configFileProvider, configService, mediaCoverService)
|
||||||
{
|
{
|
||||||
_proxy = proxy;
|
_proxy = proxy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,17 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
{
|
{
|
||||||
public class WebhookAlbum
|
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<string> SecondaryAlbumTypes { get; set; }
|
||||||
|
public DateTime? ReleaseDate { get; set; }
|
||||||
|
public List<string> Genres { get; set; }
|
||||||
|
public List<WebhookImage> Images { get; set; }
|
||||||
|
|
||||||
public WebhookAlbum()
|
public WebhookAlbum()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -20,18 +31,9 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
Overview = album.Overview;
|
Overview = album.Overview;
|
||||||
AlbumType = album.AlbumType;
|
AlbumType = album.AlbumType;
|
||||||
SecondaryAlbumTypes = album.SecondaryTypes.Select(x => x.Name).ToList();
|
SecondaryAlbumTypes = album.SecondaryTypes.Select(x => x.Name).ToList();
|
||||||
Genres = album.Genres;
|
|
||||||
ReleaseDate = album.ReleaseDate;
|
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<string> SecondaryAlbumTypes { get; set; }
|
|
||||||
public List<string> Genres { get; set; }
|
|
||||||
public DateTime? ReleaseDate { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Notifications.Webhook
|
namespace NzbDrone.Core.Notifications.Webhook
|
||||||
|
@ -13,6 +14,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public string Overview { get; set; }
|
public string Overview { get; set; }
|
||||||
public List<string> Genres { get; set; }
|
public List<string> Genres { get; set; }
|
||||||
|
public List<WebhookImage> Images { get; set; }
|
||||||
|
|
||||||
public WebhookArtist()
|
public WebhookArtist()
|
||||||
{
|
{
|
||||||
|
@ -24,10 +26,11 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
Name = artist.Name;
|
Name = artist.Name;
|
||||||
Disambiguation = artist.Metadata.Value.Disambiguation;
|
Disambiguation = artist.Metadata.Value.Disambiguation;
|
||||||
Path = artist.Path;
|
Path = artist.Path;
|
||||||
|
MBId = artist.Metadata.Value.ForeignArtistId;
|
||||||
Type = artist.Metadata.Value.Type;
|
Type = artist.Metadata.Value.Type;
|
||||||
Overview = artist.Metadata.Value.Overview;
|
Overview = artist.Metadata.Value.Overview;
|
||||||
Genres = artist.Metadata.Value.Genres;
|
Genres = artist.Metadata.Value.Genres;
|
||||||
MBId = artist.Metadata.Value.ForeignArtistId;
|
Images = artist.Metadata.Value.Images.Select(i => new WebhookImage(i)).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.MediaCover;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
using NzbDrone.Core.ThingiProvider;
|
||||||
|
@ -12,11 +13,13 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
{
|
{
|
||||||
private readonly IConfigFileProvider _configFileProvider;
|
private readonly IConfigFileProvider _configFileProvider;
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
|
private readonly IMapCoversToLocal _mediaCoverService;
|
||||||
|
|
||||||
protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService)
|
protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService, IMapCoversToLocal mediaCoverService)
|
||||||
{
|
{
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
|
_mediaCoverService = mediaCoverService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebhookGrabPayload BuildOnGrabPayload(GrabMessage message)
|
public WebhookGrabPayload BuildOnGrabPayload(GrabMessage message)
|
||||||
|
@ -29,8 +32,8 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.Grab,
|
EventType = WebhookEventType.Grab,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Artist = new WebhookArtist(message.Artist),
|
Artist = GetArtist(message.Artist),
|
||||||
Albums = remoteAlbum.Albums.Select(x => new WebhookAlbum(x)).ToList(),
|
Albums = remoteAlbum.Albums.Select(GetAlbum).ToList(),
|
||||||
Release = new WebhookRelease(quality, remoteAlbum),
|
Release = new WebhookRelease(quality, remoteAlbum),
|
||||||
DownloadClient = message.DownloadClientName,
|
DownloadClient = message.DownloadClientName,
|
||||||
DownloadClientType = message.DownloadClientType,
|
DownloadClientType = message.DownloadClientType,
|
||||||
|
@ -47,8 +50,8 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.Download,
|
EventType = WebhookEventType.Download,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Artist = new WebhookArtist(message.Artist),
|
Artist = GetArtist(message.Artist),
|
||||||
Album = new WebhookAlbum(message.Album),
|
Album = GetAlbum(message.Album),
|
||||||
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y))).ToList(),
|
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y))).ToList(),
|
||||||
TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)),
|
TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)),
|
||||||
IsUpgrade = message.OldFiles.Any(),
|
IsUpgrade = message.OldFiles.Any(),
|
||||||
|
@ -89,7 +92,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.ImportFailure,
|
EventType = WebhookEventType.ImportFailure,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
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(),
|
Tracks = trackFiles.SelectMany(x => x.Tracks.Value.Select(y => new WebhookTrack(y))).ToList(),
|
||||||
TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)),
|
TrackFiles = trackFiles.ConvertAll(x => new WebhookTrackFile(x)),
|
||||||
IsUpgrade = message.OldFiles.Any(),
|
IsUpgrade = message.OldFiles.Any(),
|
||||||
|
@ -113,7 +116,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.Rename,
|
EventType = WebhookEventType.Rename,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Artist = new WebhookArtist(artist),
|
Artist = GetArtist(artist),
|
||||||
RenamedTrackFiles = renamedFiles.ConvertAll(x => new WebhookRenamedTrackFile(x))
|
RenamedTrackFiles = renamedFiles.ConvertAll(x => new WebhookRenamedTrackFile(x))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -125,7 +128,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.Retag,
|
EventType = WebhookEventType.Retag,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Artist = new WebhookArtist(message.Artist),
|
Artist = GetArtist(message.Artist),
|
||||||
TrackFile = new WebhookTrackFile(message.TrackFile)
|
TrackFile = new WebhookTrackFile(message.TrackFile)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -137,7 +140,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.ArtistAdd,
|
EventType = WebhookEventType.ArtistAdd,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Artist = new WebhookArtist(addMessage.Artist),
|
Artist = GetArtist(addMessage.Artist),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +151,7 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.ArtistDelete,
|
EventType = WebhookEventType.ArtistDelete,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Artist = new WebhookArtist(deleteMessage.Artist),
|
Artist = GetArtist(deleteMessage.Artist),
|
||||||
DeletedFiles = deleteMessage.DeletedFiles
|
DeletedFiles = deleteMessage.DeletedFiles
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -160,8 +163,8 @@ namespace NzbDrone.Core.Notifications.Webhook
|
||||||
EventType = WebhookEventType.AlbumDelete,
|
EventType = WebhookEventType.AlbumDelete,
|
||||||
InstanceName = _configFileProvider.InstanceName,
|
InstanceName = _configFileProvider.InstanceName,
|
||||||
ApplicationUrl = _configService.ApplicationUrl,
|
ApplicationUrl = _configService.ApplicationUrl,
|
||||||
Artist = new WebhookArtist(deleteMessage.Album.Artist),
|
Artist = GetArtist(deleteMessage.Album.Artist),
|
||||||
Album = new WebhookAlbum(deleteMessage.Album),
|
Album = GetAlbum(deleteMessage.Album),
|
||||||
DeletedFiles = deleteMessage.DeletedFiles
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
src/NzbDrone.Core/Notifications/Webhook/WebhookImage.cs
Normal file
18
src/NzbDrone.Core/Notifications/Webhook/WebhookImage.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue