New: Genres and Images for Webhooks and Notifiarr

Closes #6822
pull/6849/head
Mark McDowall 6 months ago committed by Mark McDowall
parent 11e5c5a11b
commit fd3dd1ab7d

@ -3,6 +3,7 @@ using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Notifications.Webhook;
using NzbDrone.Core.Tags;
@ -15,8 +16,8 @@ namespace NzbDrone.Core.Notifications.Notifiarr
{
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;
}

@ -3,6 +3,7 @@ using FluentValidation.Results;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Tv;
@ -14,8 +15,8 @@ namespace NzbDrone.Core.Notifications.Webhook
{
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;
}

@ -4,6 +4,7 @@ using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Tags;
using NzbDrone.Core.Tv;
@ -17,13 +18,15 @@ namespace NzbDrone.Core.Notifications.Webhook
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 @@ namespace NzbDrone.Core.Notifications.Webhook
EventType = WebhookEventType.Grab,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Series = new WebhookSeries(message.Series, GetTagLabels(message.Series)),
Series = GetSeries(message.Series),
Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x)),
Release = new WebhookRelease(quality, remoteEpisode),
DownloadClient = message.DownloadClientName,
@ -55,7 +58,7 @@ namespace NzbDrone.Core.Notifications.Webhook
EventType = WebhookEventType.Download,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Series = new WebhookSeries(message.Series, GetTagLabels(message.Series)),
Series = GetSeries(message.Series),
Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)),
EpisodeFile = new WebhookEpisodeFile(episodeFile),
Release = new WebhookGrabbedRelease(message.Release),
@ -85,7 +88,7 @@ namespace NzbDrone.Core.Notifications.Webhook
EventType = WebhookEventType.EpisodeFileDelete,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Series = new WebhookSeries(deleteMessage.Series, GetTagLabels(deleteMessage.Series)),
Series = GetSeries(deleteMessage.Series),
Episodes = deleteMessage.EpisodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)),
EpisodeFile = new WebhookEpisodeFile(deleteMessage.EpisodeFile),
DeleteReason = deleteMessage.Reason
@ -99,7 +102,7 @@ namespace NzbDrone.Core.Notifications.Webhook
EventType = WebhookEventType.SeriesAdd,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Series = new WebhookSeries(addMessage.Series, GetTagLabels(addMessage.Series)),
Series = GetSeries(addMessage.Series),
};
}
@ -110,7 +113,7 @@ namespace NzbDrone.Core.Notifications.Webhook
EventType = WebhookEventType.SeriesDelete,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Series = new WebhookSeries(deleteMessage.Series, GetTagLabels(deleteMessage.Series)),
Series = GetSeries(deleteMessage.Series),
DeletedFiles = deleteMessage.DeletedFiles
};
}
@ -122,7 +125,7 @@ namespace NzbDrone.Core.Notifications.Webhook
EventType = WebhookEventType.Rename,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Series = new WebhookSeries(series, GetTagLabels(series)),
Series = GetSeries(series),
RenamedEpisodeFiles = renamedFiles.ConvertAll(x => new WebhookRenamedEpisodeFile(x))
};
}
@ -175,7 +178,7 @@ namespace NzbDrone.Core.Notifications.Webhook
EventType = WebhookEventType.ManualInteractionRequired,
InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Series = new WebhookSeries(message.Series, GetTagLabels(message.Series)),
Series = GetSeries(message.Series),
Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x)),
DownloadInfo = new WebhookDownloadClientItem(quality, message.TrackedDownload.DownloadItem),
DownloadClient = message.DownloadClientInfo?.Name,
@ -216,6 +219,13 @@ namespace NzbDrone.Core.Notifications.Webhook
};
}
private WebhookSeries GetSeries(Series series)
{
_mediaCoverService.ConvertToLocalUrls(series.Id, series.Images);
return new WebhookSeries(series, GetTagLabels(series));
}
private List<string> GetTagLabels(Series series)
{
return _tagRepository.GetTags(series.Tags)

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

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Notifications.Webhook
@ -14,6 +15,8 @@ namespace NzbDrone.Core.Notifications.Webhook
public string ImdbId { get; set; }
public SeriesTypes Type { get; set; }
public int Year { get; set; }
public List<string> Genres { get; set; }
public List<WebhookImage> Images { get; set; }
public List<string> Tags { get; set; }
public WebhookSeries()
@ -31,6 +34,8 @@ namespace NzbDrone.Core.Notifications.Webhook
ImdbId = series.ImdbId;
Type = series.SeriesType;
Year = series.Year;
Genres = series.Genres;
Images = series.Images.Select(i => new WebhookImage(i)).ToList();
Tags = tags;
}
}

Loading…
Cancel
Save