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