|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|