1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-21 11:02:01 +02:00

New: Genres and Images for Webhooks and Notifiarr

Closes #6822
This commit is contained in:
Mark McDowall 2024-05-23 06:42:16 -07:00 committed by Mark McDowall
parent 11e5c5a11b
commit fd3dd1ab7d
5 changed files with 47 additions and 12 deletions

View File

@ -3,6 +3,7 @@ using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization; using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Notifications.Webhook; using NzbDrone.Core.Notifications.Webhook;
using NzbDrone.Core.Tags; using NzbDrone.Core.Tags;
@ -15,8 +16,8 @@ namespace NzbDrone.Core.Notifications.Notifiarr
{ {
private readonly INotifiarrProxy _proxy; private readonly INotifiarrProxy _proxy;
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository) public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository, IMapCoversToLocal mediaCoverService)
: base(configFileProvider, configService, localizationService, tagRepository) : base(configFileProvider, configService, localizationService, tagRepository, mediaCoverService)
{ {
_proxy = proxy; _proxy = proxy;
} }

View File

@ -3,6 +3,7 @@ using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization; using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Tags; using NzbDrone.Core.Tags;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
@ -14,8 +15,8 @@ namespace NzbDrone.Core.Notifications.Webhook
{ {
private readonly IWebhookProxy _proxy; private readonly IWebhookProxy _proxy;
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository) public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService, ILocalizationService localizationService, ITagRepository tagRepository, IMapCoversToLocal mediaCoverService)
: base(configFileProvider, configService, localizationService, tagRepository) : base(configFileProvider, configService, localizationService, tagRepository, mediaCoverService)
{ {
_proxy = proxy; _proxy = proxy;
} }

View File

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

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

View File

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