1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-29 23:12:39 +01: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.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;
}

View File

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

View File

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

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