mirror of
https://github.com/Radarr/Radarr
synced 2025-02-20 13:27:10 +00:00
New: Notifications when Manual Interaction is required for importing
(cherry picked from commit 5ec282750bdea16f770282b80fdaec56a65749e2)
This commit is contained in:
parent
8563ed0a20
commit
a1e622a363
49 changed files with 524 additions and 34 deletions
|
@ -66,6 +66,7 @@ class Notification extends Component {
|
|||
onHealthIssue,
|
||||
onHealthRestored,
|
||||
onApplicationUpdate,
|
||||
onManualInteractionRequired,
|
||||
supportsOnGrab,
|
||||
supportsOnDownload,
|
||||
supportsOnUpgrade,
|
||||
|
@ -76,7 +77,8 @@ class Notification extends Component {
|
|||
supportsOnMovieFileDeleteForUpgrade,
|
||||
supportsOnHealthIssue,
|
||||
supportsOnHealthRestored,
|
||||
supportsOnApplicationUpdate
|
||||
supportsOnApplicationUpdate,
|
||||
supportsOnManualInteractionRequired
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
|
@ -178,7 +180,15 @@ class Notification extends Component {
|
|||
}
|
||||
|
||||
{
|
||||
!onGrab && !onDownload && !onRename && !onHealthIssue && !onHealthRestored && !onApplicationUpdate && !onMovieDelete && !onMovieFileDelete ?
|
||||
supportsOnManualInteractionRequired && onManualInteractionRequired ?
|
||||
<Label kind={kinds.SUCCESS}>
|
||||
{translate('OnManualInteractionRequired')}
|
||||
</Label> :
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
!onGrab && !onDownload && !onRename && !onHealthIssue && !onHealthRestored && !onApplicationUpdate && !onMovieDelete && !onMovieFileDelete && !onManualInteractionRequired ?
|
||||
<Label
|
||||
kind={kinds.DISABLED}
|
||||
outline={true}
|
||||
|
@ -223,6 +233,7 @@ Notification.propTypes = {
|
|||
onHealthIssue: PropTypes.bool.isRequired,
|
||||
onHealthRestored: PropTypes.bool.isRequired,
|
||||
onApplicationUpdate: PropTypes.bool.isRequired,
|
||||
onManualInteractionRequired: PropTypes.bool.isRequired,
|
||||
supportsOnGrab: PropTypes.bool.isRequired,
|
||||
supportsOnDownload: PropTypes.bool.isRequired,
|
||||
supportsOnMovieDelete: PropTypes.bool.isRequired,
|
||||
|
@ -234,6 +245,7 @@ Notification.propTypes = {
|
|||
supportsOnHealthIssue: PropTypes.bool.isRequired,
|
||||
supportsOnHealthRestored: PropTypes.bool.isRequired,
|
||||
supportsOnApplicationUpdate: PropTypes.bool.isRequired,
|
||||
supportsOnManualInteractionRequired: PropTypes.bool.isRequired,
|
||||
onConfirmDeleteNotification: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ function NotificationEventItems(props) {
|
|||
onHealthIssue,
|
||||
onHealthRestored,
|
||||
onApplicationUpdate,
|
||||
onManualInteractionRequired,
|
||||
supportsOnGrab,
|
||||
supportsOnDownload,
|
||||
supportsOnUpgrade,
|
||||
|
@ -35,6 +36,7 @@ function NotificationEventItems(props) {
|
|||
supportsOnMovieFileDelete,
|
||||
supportsOnMovieFileDeleteForUpgrade,
|
||||
supportsOnApplicationUpdate,
|
||||
supportsOnManualInteractionRequired,
|
||||
supportsOnHealthIssue,
|
||||
supportsOnHealthRestored,
|
||||
includeHealthWarnings
|
||||
|
@ -189,6 +191,17 @@ function NotificationEventItems(props) {
|
|||
onChange={onInputChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<FormInputGroup
|
||||
type={inputTypes.CHECK}
|
||||
name="onManualInteractionRequired"
|
||||
helpText={translate('OnManualInteractionRequiredHelpText')}
|
||||
isDisabled={!supportsOnManualInteractionRequired.value}
|
||||
{...onManualInteractionRequired}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</FormGroup>
|
||||
|
|
|
@ -111,6 +111,7 @@ export default {
|
|||
selectedSchema.onMovieFileDelete = selectedSchema.supportsOnMovieFileDelete;
|
||||
selectedSchema.onMovieFileDeleteForUpgrade = selectedSchema.supportsOnMovieFileDeleteForUpgrade;
|
||||
selectedSchema.onApplicationUpdate = selectedSchema.supportsOnApplicationUpdate;
|
||||
selectedSchema.onManualInteractionRequired = selectedSchema.supportsOnManualInteractionRequired;
|
||||
|
||||
return selectedSchema;
|
||||
});
|
||||
|
|
|
@ -52,8 +52,8 @@ public void Setup()
|
|||
.Returns((DownloadClientItem item, DownloadClientItem previous) => item);
|
||||
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
.Setup(s => s.MostRecentForDownloadId(_trackedDownload.DownloadItem.DownloadId))
|
||||
.Returns(new MovieHistory());
|
||||
.Setup(s => s.FindByDownloadId(_trackedDownload.DownloadItem.DownloadId))
|
||||
.Returns(new List<MovieHistory>());
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetMovie("Drone.S01E01.HDTV"))
|
||||
|
@ -71,8 +71,8 @@ private RemoteMovie BuildRemoteMovie()
|
|||
private void GivenNoGrabbedHistory()
|
||||
{
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
.Setup(s => s.MostRecentForDownloadId(_trackedDownload.DownloadItem.DownloadId))
|
||||
.Returns((MovieHistory)null);
|
||||
.Setup(s => s.FindByDownloadId(_trackedDownload.DownloadItem.DownloadId))
|
||||
.Returns(new List<MovieHistory>());
|
||||
}
|
||||
|
||||
private void GivenMovieMatch()
|
||||
|
@ -87,8 +87,11 @@ private void GivenABadlyNamedDownload()
|
|||
_trackedDownload.DownloadItem.DownloadId = "1234";
|
||||
_trackedDownload.DownloadItem.Title = "Droned Pilot"; // Set a badly named download
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
.Setup(s => s.MostRecentForDownloadId(It.Is<string>(i => i == "1234")))
|
||||
.Returns(new MovieHistory() { SourceTitle = "Droned S01E01" });
|
||||
.Setup(s => s.FindByDownloadId(It.Is<string>(i => i == "1234")))
|
||||
.Returns(new List<MovieHistory>
|
||||
{
|
||||
new MovieHistory() { SourceTitle = "Droned S01E01", EventType = MovieHistoryEventType.Grabbed }
|
||||
});
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.GetMovie(It.IsAny<string>()))
|
||||
|
@ -158,9 +161,6 @@ public void should_not_process_if_the_download_cannot_be_tracked_using_the_sourc
|
|||
new ImportResult(new ImportDecision(new LocalMovie { Path = @"C:\TestPath\Droned.S01E01.mkv" }))
|
||||
});
|
||||
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
.Setup(s => s.MostRecentForDownloadId(It.Is<string>(i => i == "1234")));
|
||||
|
||||
Subject.Check(_trackedDownload);
|
||||
|
||||
AssertNotReadyToImport();
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.MediaFiles.MovieImport.Specifications;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
@ -46,8 +48,22 @@ public void Setup()
|
|||
|
||||
private void GivenHistoryForMovies(params Movie[] movies)
|
||||
{
|
||||
_localMovie.Release = new GrabbedReleaseInfo();
|
||||
_localMovie.Release.MovieIds = movies.Select(e => e.Id).ToList();
|
||||
if (movies.Empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var grabbedHistories = Builder<MovieHistory>.CreateListOfSize(movies.Length)
|
||||
.All()
|
||||
.With(h => h.EventType == MovieHistoryEventType.Grabbed)
|
||||
.BuildList();
|
||||
|
||||
for (var i = 0; i < grabbedHistories.Count; i++)
|
||||
{
|
||||
grabbedHistories[i].MovieId = movies[i].Id;
|
||||
}
|
||||
|
||||
_localMovie.Release = new GrabbedReleaseInfo(grabbedHistories);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -93,6 +93,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
{
|
||||
TestLogger.Info("OnApplicationUpdate was called");
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
TestLogger.Info("OnManualInteractionRequired was called");
|
||||
}
|
||||
}
|
||||
|
||||
private class TestNotificationWithNoEvents : NotificationBase<TestSetting>
|
||||
|
@ -134,6 +139,7 @@ public void should_support_all_if_implemented()
|
|||
notification.SupportsOnHealthIssue.Should().BeTrue();
|
||||
notification.SupportsOnHealthRestored.Should().BeTrue();
|
||||
notification.SupportsOnApplicationUpdate.Should().BeTrue();
|
||||
notification.SupportsOnManualInteractionRequired.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -152,6 +158,7 @@ public void should_support_none_if_none_are_implemented()
|
|||
notification.SupportsOnHealthIssue.Should().BeFalse();
|
||||
notification.SupportsOnHealthRestored.Should().BeFalse();
|
||||
notification.SupportsOnApplicationUpdate.Should().BeFalse();
|
||||
notification.SupportsOnManualInteractionRequired.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(221)]
|
||||
public class add_on_manual_interaction_required_to_notifications : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("Notifications").AddColumn("OnManualInteractionRequired").AsBoolean().WithDefaultValue(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -94,7 +94,8 @@ public static void Map()
|
|||
.Ignore(i => i.SupportsOnMovieFileDeleteForUpgrade)
|
||||
.Ignore(i => i.SupportsOnHealthIssue)
|
||||
.Ignore(i => i.SupportsOnHealthRestored)
|
||||
.Ignore(i => i.SupportsOnApplicationUpdate);
|
||||
.Ignore(i => i.SupportsOnApplicationUpdate)
|
||||
.Ignore(i => i.SupportsOnManualInteractionRequired);
|
||||
|
||||
Mapper.Entity<MetadataDefinition>("Metadata").RegisterModel()
|
||||
.Ignore(x => x.ImplementationName)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NLog.Fluent;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Instrumentation.Extensions;
|
||||
|
@ -70,7 +69,8 @@ public void Check(TrackedDownload trackedDownload)
|
|||
return;
|
||||
}
|
||||
|
||||
var historyItem = _historyService.MostRecentForDownloadId(trackedDownload.DownloadItem.DownloadId);
|
||||
var grabbedHistories = _historyService.FindByDownloadId(trackedDownload.DownloadItem.DownloadId).Where(h => h.EventType == MovieHistoryEventType.Grabbed).ToList();
|
||||
var historyItem = grabbedHistories.MaxBy(h => h.Date);
|
||||
|
||||
if (historyItem == null && trackedDownload.DownloadItem.Category.IsNullOrWhiteSpace())
|
||||
{
|
||||
|
@ -105,6 +105,17 @@ public void Check(TrackedDownload trackedDownload)
|
|||
if (movieMatchType == MovieMatchType.Id && releaseSource != ReleaseSourceType.InteractiveSearch)
|
||||
{
|
||||
trackedDownload.Warn("Found matching movie via grab history, but release was matched to movie by ID. Manual Import required.");
|
||||
|
||||
if (!trackedDownload.HasNotifiedManualInteractionRequired)
|
||||
{
|
||||
trackedDownload.HasNotifiedManualInteractionRequired = true;
|
||||
|
||||
var releaseInfo = new GrabbedReleaseInfo(grabbedHistories);
|
||||
var manualInteractionEvent = new ManualInteractionRequiredEvent(trackedDownload, releaseInfo);
|
||||
|
||||
_eventAggregator.PublishEvent(manualInteractionEvent);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
20
src/NzbDrone.Core/Download/ManualInteractionRequiredEvent.cs
Normal file
20
src/NzbDrone.Core/Download/ManualInteractionRequiredEvent.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public class ManualInteractionRequiredEvent : IEvent
|
||||
{
|
||||
public RemoteMovie RemoteMovie { get; private set; }
|
||||
public TrackedDownload TrackedDownload { get; private set; }
|
||||
public GrabbedReleaseInfo Release { get; private set; }
|
||||
|
||||
public ManualInteractionRequiredEvent(TrackedDownload trackedDownload, GrabbedReleaseInfo release)
|
||||
{
|
||||
TrackedDownload = trackedDownload;
|
||||
RemoteMovie = trackedDownload.RemoteMovie;
|
||||
Release = release;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ public class DownloadMonitoringService : IExecute<RefreshMonitoredDownloadsComma
|
|||
IExecute<CheckForFinishedDownloadCommand>,
|
||||
IHandle<MovieGrabbedEvent>,
|
||||
IHandle<MovieFileImportedEvent>,
|
||||
IHandle<ManualInteractionRequiredEvent>,
|
||||
IHandle<DownloadsProcessedEvent>,
|
||||
IHandle<TrackedDownloadsRemovedEvent>
|
||||
{
|
||||
|
@ -169,6 +170,11 @@ public void Handle(MovieGrabbedEvent message)
|
|||
_refreshDebounce.Execute();
|
||||
}
|
||||
|
||||
public void Handle(ManualInteractionRequiredEvent message)
|
||||
{
|
||||
_refreshDebounce.Execute();
|
||||
}
|
||||
|
||||
public void Handle(MovieFileImportedEvent message)
|
||||
{
|
||||
_refreshDebounce.Execute();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
|
@ -15,10 +16,11 @@ public class TrackedDownload
|
|||
public DownloadProtocol Protocol { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public bool IsTrackable { get; set; }
|
||||
public bool HasNotifiedManualInteractionRequired { get; set; }
|
||||
|
||||
public TrackedDownload()
|
||||
{
|
||||
StatusMessages = System.Array.Empty<TrackedDownloadStatusMessage>();
|
||||
StatusMessages = Array.Empty<TrackedDownloadStatusMessage>();
|
||||
}
|
||||
|
||||
public void Warn(string message, params object[] args)
|
||||
|
|
|
@ -107,7 +107,8 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do
|
|||
DownloadClient = downloadClient.Id,
|
||||
DownloadItem = downloadItem,
|
||||
Protocol = downloadClient.Protocol,
|
||||
IsTrackable = true
|
||||
IsTrackable = true,
|
||||
HasNotifiedManualInteractionRequired = existingItem?.HasNotifiedManualInteractionRequired ?? false
|
||||
};
|
||||
|
||||
try
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
"ApplicationURL": "Application URL",
|
||||
"ApplicationUrlHelpText": "This application's external URL including http(s)://, port and URL base",
|
||||
"Apply": "Apply",
|
||||
"OnManualInteractionRequired": "On Manual Interaction Required",
|
||||
"OnManualInteractionRequiredHelpText": "On Manual Interaction Required",
|
||||
"ApplyTags": "Apply Tags",
|
||||
"ApplyTagsHelpTexts1": "How to apply tags to the selected movies",
|
||||
"ApplyTagsHelpTexts2": "Add: Add the tags to the existing list of tags",
|
||||
|
|
|
@ -31,20 +31,7 @@ public LocalMovie Aggregate(LocalMovie localMovie, DownloadClientItem downloadCl
|
|||
return localMovie;
|
||||
}
|
||||
|
||||
var movieIds = grabbedHistories.Select(h => h.MovieId).Distinct().ToList();
|
||||
var grabbedHistory = grabbedHistories.First();
|
||||
var releaseInfo = new GrabbedReleaseInfo();
|
||||
|
||||
grabbedHistory.Data.TryGetValue("indexer", out var indexer);
|
||||
grabbedHistory.Data.TryGetValue("size", out var sizeString);
|
||||
long.TryParse(sizeString, out var size);
|
||||
|
||||
releaseInfo.Title = grabbedHistory.SourceTitle;
|
||||
releaseInfo.Indexer = indexer;
|
||||
releaseInfo.Size = size;
|
||||
releaseInfo.MovieIds = movieIds;
|
||||
|
||||
localMovie.Release = releaseInfo;
|
||||
localMovie.Release = new GrabbedReleaseInfo(grabbedHistories);
|
||||
|
||||
return localMovie;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -57,6 +57,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage message)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -277,6 +277,30 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
var movie = message.Movie;
|
||||
var environmentVariables = new StringDictionary();
|
||||
|
||||
environmentVariables.Add("Radarr_EventType", "ManualInteractionRequired");
|
||||
environmentVariables.Add("Radarr_InstanceName", _configFileProvider.InstanceName);
|
||||
environmentVariables.Add("Radarr_ApplicationUrl", _configService.ApplicationUrl);
|
||||
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
|
||||
environmentVariables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title);
|
||||
environmentVariables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString());
|
||||
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
|
||||
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
|
||||
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
|
||||
environmentVariables.Add("Radarr_Movie_Overview", movie.MovieMetadata.Value.Overview);
|
||||
environmentVariables.Add("Radarr_Download_Client", message.DownloadClientName ?? string.Empty);
|
||||
environmentVariables.Add("Radarr_Download_Client_Type", message.DownloadClientType ?? string.Empty);
|
||||
environmentVariables.Add("Radarr_Download_Id", message.DownloadId ?? string.Empty);
|
||||
environmentVariables.Add("Radarr_Download_Size", message.TrackedDownload.DownloadItem.TotalSize.ToString());
|
||||
environmentVariables.Add("Radarr_Download_Title", message.TrackedDownload.DownloadItem.Title);
|
||||
|
||||
ExecuteScript(environmentVariables);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -379,6 +379,95 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
var movie = message.Movie;
|
||||
|
||||
var embed = new Embed
|
||||
{
|
||||
Author = new DiscordAuthor
|
||||
{
|
||||
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author,
|
||||
IconUrl = "https://raw.githubusercontent.com/Radarr/Radarr/develop/Logo/256.png"
|
||||
},
|
||||
Url = $"https://www.themoviedb.org/movie/{movie.MovieMetadata.Value.TmdbId}",
|
||||
Description = "Manual interaction needed",
|
||||
Title = movie.MovieMetadata.Value.Title,
|
||||
Color = (int)DiscordColors.Standard,
|
||||
Fields = new List<DiscordField>(),
|
||||
Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
|
||||
};
|
||||
|
||||
if (Settings.ManualInteractionFields.Contains((int)DiscordGrabFieldType.Poster))
|
||||
{
|
||||
embed.Thumbnail = new DiscordImage
|
||||
{
|
||||
Url = movie.MovieMetadata.Value.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.Url
|
||||
};
|
||||
}
|
||||
|
||||
if (Settings.ManualInteractionFields.Contains((int)DiscordGrabFieldType.Fanart))
|
||||
{
|
||||
embed.Image = new DiscordImage
|
||||
{
|
||||
Url = movie.MovieMetadata.Value.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.Url
|
||||
};
|
||||
}
|
||||
|
||||
foreach (var field in Settings.ManualInteractionFields)
|
||||
{
|
||||
var discordField = new DiscordField();
|
||||
|
||||
switch ((DiscordManualInteractionFieldType)field)
|
||||
{
|
||||
case DiscordManualInteractionFieldType.Overview:
|
||||
var overview = movie.MovieMetadata.Value.Overview ?? "";
|
||||
discordField.Name = "Overview";
|
||||
discordField.Value = overview.Length <= 300 ? overview : $"{overview.AsSpan(0, 300)}...";
|
||||
break;
|
||||
case DiscordManualInteractionFieldType.Rating:
|
||||
discordField.Name = "Rating";
|
||||
discordField.Value = movie.MovieMetadata.Value.Ratings.Tmdb?.Value.ToString() ?? string.Empty;
|
||||
break;
|
||||
case DiscordManualInteractionFieldType.Genres:
|
||||
discordField.Name = "Genres";
|
||||
discordField.Value = movie.MovieMetadata.Value.Genres.Take(5).Join(", ");
|
||||
break;
|
||||
case DiscordManualInteractionFieldType.Quality:
|
||||
discordField.Name = "Quality";
|
||||
discordField.Inline = true;
|
||||
discordField.Value = message.Quality.Quality.Name;
|
||||
break;
|
||||
case DiscordManualInteractionFieldType.Group:
|
||||
discordField.Name = "Group";
|
||||
discordField.Value = message.RemoteMovie.ParsedMovieInfo.ReleaseGroup;
|
||||
break;
|
||||
case DiscordManualInteractionFieldType.Size:
|
||||
discordField.Name = "Size";
|
||||
discordField.Value = BytesToString(message.TrackedDownload.DownloadItem.TotalSize);
|
||||
discordField.Inline = true;
|
||||
break;
|
||||
case DiscordManualInteractionFieldType.DownloadTitle:
|
||||
discordField.Name = "Download";
|
||||
discordField.Value = string.Format("```{0}```", message.TrackedDownload.DownloadItem.Title);
|
||||
break;
|
||||
case DiscordManualInteractionFieldType.Links:
|
||||
discordField.Name = "Links";
|
||||
discordField.Value = GetLinksString(message.Movie);
|
||||
break;
|
||||
}
|
||||
|
||||
if (discordField.Name.IsNotNullOrWhiteSpace() && discordField.Value.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
embed.Fields.Add(discordField);
|
||||
}
|
||||
}
|
||||
|
||||
var payload = CreatePayload(null, new List<Embed> { embed });
|
||||
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -33,4 +33,18 @@ public enum DiscordImportFieldType
|
|||
Poster,
|
||||
Fanart
|
||||
}
|
||||
|
||||
public enum DiscordManualInteractionFieldType
|
||||
{
|
||||
Overview,
|
||||
Rating,
|
||||
Genres,
|
||||
Quality,
|
||||
Group,
|
||||
Size,
|
||||
Links,
|
||||
DownloadTitle,
|
||||
Poster,
|
||||
Fanart
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public DiscordSettings()
|
|||
// Set Default Fields
|
||||
GrabFields = new List<int> { 0, 1, 2, 3, 5, 6, 7, 8, 9 };
|
||||
ImportFields = new List<int> { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12 };
|
||||
ManualInteractionFields = new[] { 0, 1, 2, 3, 5, 6, 7, 8, 9 };
|
||||
}
|
||||
|
||||
private static readonly DiscordSettingsValidator Validator = new DiscordSettingsValidator();
|
||||
|
@ -43,6 +44,9 @@ public DiscordSettings()
|
|||
[FieldDefinition(5, Label = "On Import Fields", Advanced = true, SelectOptions = typeof(DiscordImportFieldType), HelpText = "Change the fields that are passed for this 'on import' notification", Type = FieldType.TagSelect)]
|
||||
public IEnumerable<int> ImportFields { get; set; }
|
||||
|
||||
[FieldDefinition(6, Label = "On Manual Interaction Fields", Advanced = true, SelectOptions = typeof(DiscordManualInteractionFieldType), HelpText = "Change the fields that are passed for this 'on manual interaction' notification", Type = FieldType.TagSelect)]
|
||||
public IEnumerable<int> ManualInteractionFields { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
|
|
|
@ -79,6 +79,13 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
SendEmail(Settings, APPLICATION_UPDATE_TITLE_BRANDED, body);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
var body = $"{message.Message} requires manual interaction.";
|
||||
|
||||
SendEmail(Settings, MANUAL_INTERACTION_REQUIRED_TITLE_BRANDED, body);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -63,6 +63,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage message)
|
|||
SendNotification(APPLICATION_UPDATE_TITLE, message.Message, null);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, message.Movie);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -18,6 +18,7 @@ public interface INotification : IProvider
|
|||
void OnHealthIssue(HealthCheck.HealthCheck healthCheck);
|
||||
void OnHealthRestored(HealthCheck.HealthCheck previousCheck);
|
||||
void OnApplicationUpdate(ApplicationUpdateMessage updateMessage);
|
||||
void OnManualInteractionRequired(ManualInteractionRequiredMessage message);
|
||||
void ProcessQueue();
|
||||
bool SupportsOnGrab { get; }
|
||||
bool SupportsOnDownload { get; }
|
||||
|
@ -30,5 +31,6 @@ public interface INotification : IProvider
|
|||
bool SupportsOnHealthIssue { get; }
|
||||
bool SupportsOnHealthRestored { get; }
|
||||
bool SupportsOnApplicationUpdate { get; }
|
||||
bool SupportsOnManualInteractionRequired { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -64,6 +64,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Notifications
|
||||
{
|
||||
public class ManualInteractionRequiredMessage
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public Movie Movie { get; set; }
|
||||
public RemoteMovie RemoteMovie { get; set; }
|
||||
public TrackedDownload TrackedDownload { get; set; }
|
||||
public QualityModel Quality { get; set; }
|
||||
public string DownloadClientType { get; set; }
|
||||
public string DownloadClientName { get; set; }
|
||||
public string DownloadId { get; set; }
|
||||
public GrabbedReleaseInfo Release { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Message;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,6 +67,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(BuildApplicationUpdatePayload(updateMessage), Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(BuildManualInteractionRequiredPayload(message), Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -19,6 +19,7 @@ public abstract class NotificationBase<TSettings> : INotification
|
|||
protected const string HEALTH_ISSUE_TITLE = "Health Check Failure";
|
||||
protected const string HEALTH_RESTORED_TITLE = "Health Check Restored";
|
||||
protected const string APPLICATION_UPDATE_TITLE = "Application Updated";
|
||||
protected const string MANUAL_INTERACTION_REQUIRED_TITLE = "Manual Interaction";
|
||||
|
||||
protected const string MOVIE_GRABBED_TITLE_BRANDED = "Radarr - " + MOVIE_GRABBED_TITLE;
|
||||
protected const string MOVIE_ADDED_TITLE_BRANDED = "Radarr - " + MOVIE_ADDED_TITLE;
|
||||
|
@ -28,6 +29,7 @@ public abstract class NotificationBase<TSettings> : INotification
|
|||
protected const string HEALTH_ISSUE_TITLE_BRANDED = "Radarr - " + HEALTH_ISSUE_TITLE;
|
||||
protected const string HEALTH_RESTORED_TITLE_BRANDED = "Radarr - " + HEALTH_RESTORED_TITLE;
|
||||
protected const string APPLICATION_UPDATE_TITLE_BRANDED = "Radarr - " + APPLICATION_UPDATE_TITLE;
|
||||
protected const string MANUAL_INTERACTION_REQUIRED_TITLE_BRANDED = "Radarr - " + MANUAL_INTERACTION_REQUIRED_TITLE;
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
|
@ -78,6 +80,10 @@ public virtual void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
{
|
||||
}
|
||||
|
||||
public virtual void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ProcessQueue()
|
||||
{
|
||||
}
|
||||
|
@ -93,6 +99,7 @@ public virtual void ProcessQueue()
|
|||
public bool SupportsOnHealthIssue => HasConcreteImplementation("OnHealthIssue");
|
||||
public bool SupportsOnHealthRestored => HasConcreteImplementation("OnHealthRestored");
|
||||
public bool SupportsOnApplicationUpdate => HasConcreteImplementation("OnApplicationUpdate");
|
||||
public bool SupportsOnManualInteractionRequired => HasConcreteImplementation("OnManualInteractionRequired");
|
||||
|
||||
protected TSettings Settings => (TSettings)Definition.Settings;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ public class NotificationDefinition : ProviderDefinition
|
|||
public bool OnHealthIssue { get; set; }
|
||||
public bool OnHealthRestored { get; set; }
|
||||
public bool OnApplicationUpdate { get; set; }
|
||||
public bool OnManualInteractionRequired { get; set; }
|
||||
public bool SupportsOnGrab { get; set; }
|
||||
public bool SupportsOnDownload { get; set; }
|
||||
public bool SupportsOnUpgrade { get; set; }
|
||||
|
@ -27,7 +28,8 @@ public class NotificationDefinition : ProviderDefinition
|
|||
public bool SupportsOnHealthRestored { get; set; }
|
||||
public bool IncludeHealthWarnings { get; set; }
|
||||
public bool SupportsOnApplicationUpdate { get; set; }
|
||||
public bool SupportsOnManualInteractionRequired { get; set; }
|
||||
|
||||
public override bool Enable => OnGrab || OnDownload || (OnDownload && OnUpgrade) || OnMovieAdded || OnMovieDelete || OnMovieFileDelete || OnMovieFileDeleteForUpgrade || OnHealthIssue || OnHealthRestored || OnApplicationUpdate;
|
||||
public override bool Enable => OnGrab || OnDownload || (OnDownload && OnUpgrade) || OnMovieAdded || OnMovieDelete || OnMovieFileDelete || OnMovieFileDeleteForUpgrade || OnHealthIssue || OnHealthRestored || OnApplicationUpdate || OnManualInteractionRequired;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public interface INotificationFactory : IProviderFactory<INotification, Notifica
|
|||
List<INotification> OnHealthIssueEnabled();
|
||||
List<INotification> OnHealthRestoredEnabled();
|
||||
List<INotification> OnApplicationUpdateEnabled();
|
||||
List<INotification> OnManualInteractionEnabled();
|
||||
}
|
||||
|
||||
public class NotificationFactory : ProviderFactory<INotification, NotificationDefinition>, INotificationFactory
|
||||
|
@ -83,6 +84,11 @@ public List<INotification> OnApplicationUpdateEnabled()
|
|||
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnApplicationUpdate).ToList();
|
||||
}
|
||||
|
||||
public List<INotification> OnManualInteractionEnabled()
|
||||
{
|
||||
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnManualInteractionRequired).ToList();
|
||||
}
|
||||
|
||||
public override void SetProviderCharacteristics(INotification provider, NotificationDefinition definition)
|
||||
{
|
||||
base.SetProviderCharacteristics(provider, definition);
|
||||
|
@ -98,6 +104,7 @@ public override void SetProviderCharacteristics(INotification provider, Notifica
|
|||
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
|
||||
definition.SupportsOnHealthRestored = provider.SupportsOnHealthRestored;
|
||||
definition.SupportsOnApplicationUpdate = provider.SupportsOnApplicationUpdate;
|
||||
definition.SupportsOnManualInteractionRequired = provider.SupportsOnManualInteractionRequired;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.HealthCheck;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
@ -25,6 +26,7 @@ public class NotificationService
|
|||
IHandle<HealthCheckFailedEvent>,
|
||||
IHandle<HealthCheckRestoredEvent>,
|
||||
IHandle<UpdateInstalledEvent>,
|
||||
IHandle<ManualInteractionRequiredEvent>,
|
||||
IHandleAsync<DeleteCompletedEvent>,
|
||||
IHandleAsync<DownloadsProcessedEvent>,
|
||||
IHandleAsync<RenameCompletedEvent>,
|
||||
|
@ -237,6 +239,39 @@ public void Handle(UpdateInstalledEvent message)
|
|||
}
|
||||
}
|
||||
|
||||
public void Handle(ManualInteractionRequiredEvent message)
|
||||
{
|
||||
var manualInteractionMessage = new ManualInteractionRequiredMessage
|
||||
{
|
||||
Message = GetMessage(message.RemoteMovie.Movie, message.RemoteMovie.Movie.MovieFile.Quality),
|
||||
Movie = message.RemoteMovie.Movie,
|
||||
Quality = message.RemoteMovie.ParsedMovieInfo.Quality,
|
||||
RemoteMovie = message.RemoteMovie,
|
||||
TrackedDownload = message.TrackedDownload,
|
||||
DownloadClientType = message.TrackedDownload.DownloadItem.DownloadClientInfo.Type,
|
||||
DownloadClientName = message.TrackedDownload.DownloadItem.DownloadClientInfo.Name,
|
||||
DownloadId = message.TrackedDownload.DownloadItem.DownloadId,
|
||||
Release = message.Release
|
||||
};
|
||||
|
||||
foreach (var notification in _notificationFactory.OnManualInteractionEnabled())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ShouldHandleMovie(notification.Definition, message.RemoteMovie.Movie))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
notification.OnManualInteractionRequired(manualInteractionMessage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Unable to send OnManualInteractionRequired notification to {0}", notification.Definition.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Handle(MovieFileDeletedEvent message)
|
||||
{
|
||||
var deleteMessage = new MovieFileDeleteMessage();
|
||||
|
|
|
@ -59,6 +59,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -57,6 +57,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_prowlProxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_prowlProxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -60,6 +60,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE_BRANDED, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -57,6 +57,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -60,6 +60,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -57,6 +57,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -157,6 +157,23 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
var attachments = new List<Attachment>
|
||||
{
|
||||
new Attachment
|
||||
{
|
||||
Title = Environment.MachineName,
|
||||
Text = message.Message,
|
||||
Color = "warning"
|
||||
}
|
||||
};
|
||||
|
||||
var payload = CreatePayload("Manual Interaction Required", attachments);
|
||||
|
||||
_proxy.SendPayload(payload, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -65,6 +65,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendNotification(MANUAL_INTERACTION_REQUIRED_TITLE, message.Message, Settings);
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
|
|
@ -59,6 +59,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_twitterService.SendNotification($"Application Updated: {updateMessage.Message}", Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_twitterService.SendNotification($"Manual Interaction Required: {message.Message}", Settings);
|
||||
}
|
||||
|
||||
public override object RequestAction(string action, IDictionary<string, string> query)
|
||||
{
|
||||
if (action == "startOAuth")
|
||||
|
|
|
@ -65,6 +65,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
_proxy.SendWebhook(BuildApplicationUpdatePayload(updateMessage), Settings);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
_proxy.SendWebhook(BuildManualInteractionRequiredPayload(message), Settings);
|
||||
}
|
||||
|
||||
public override string Name => "Webhook";
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
|
@ -169,6 +170,26 @@ protected WebhookApplicationUpdatePayload BuildApplicationUpdatePayload(Applicat
|
|||
};
|
||||
}
|
||||
|
||||
protected WebhookManualInteractionPayload BuildManualInteractionRequiredPayload(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
var remoteMovie = message.RemoteMovie;
|
||||
var quality = message.Quality;
|
||||
|
||||
return new WebhookManualInteractionPayload
|
||||
{
|
||||
EventType = WebhookEventType.ManualInteractionRequired,
|
||||
InstanceName = _configFileProvider.InstanceName,
|
||||
ApplicationUrl = _configService.ApplicationUrl,
|
||||
Movie = new WebhookMovie(message.Movie),
|
||||
DownloadInfo = new WebhookDownloadClientItem(quality, message.TrackedDownload.DownloadItem),
|
||||
DownloadClient = message.DownloadClientName,
|
||||
DownloadClientType = message.DownloadClientType,
|
||||
DownloadId = message.DownloadId,
|
||||
CustomFormatInfo = new WebhookCustomFormatInfo(remoteMovie.CustomFormats, remoteMovie.CustomFormatScore),
|
||||
Release = new WebhookGrabbedRelease(message.Release)
|
||||
};
|
||||
}
|
||||
|
||||
protected WebhookPayload BuildTestPayload()
|
||||
{
|
||||
return new WebhookGrabPayload
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookDownloadClientItem
|
||||
{
|
||||
public WebhookDownloadClientItem()
|
||||
{
|
||||
}
|
||||
|
||||
public WebhookDownloadClientItem(QualityModel quality, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
Quality = quality.Quality.Name;
|
||||
QualityVersion = quality.Revision.Version;
|
||||
Title = downloadClientItem.Title;
|
||||
Size = downloadClientItem.TotalSize;
|
||||
}
|
||||
|
||||
public string Quality { get; set; }
|
||||
public int QualityVersion { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public long Size { get; set; }
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ public enum WebhookEventType
|
|||
Health,
|
||||
ApplicationUpdate,
|
||||
MovieAdded,
|
||||
HealthRestored
|
||||
HealthRestored,
|
||||
ManualInteractionRequired
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
namespace NzbDrone.Core.Notifications.Webhook
|
||||
{
|
||||
public class WebhookManualInteractionPayload : WebhookPayload
|
||||
{
|
||||
public WebhookMovie Movie { get; set; }
|
||||
public WebhookDownloadClientItem DownloadInfo { get; set; }
|
||||
public string DownloadClient { get; set; }
|
||||
public string DownloadClientType { get; set; }
|
||||
public string DownloadId { get; set; }
|
||||
public WebhookCustomFormatInfo CustomFormatInfo { get; set; }
|
||||
public WebhookGrabbedRelease Release { get; set; }
|
||||
}
|
||||
}
|
|
@ -76,6 +76,11 @@ public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
|||
Notify(Settings, APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message);
|
||||
}
|
||||
|
||||
public override void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
|
||||
{
|
||||
Notify(Settings, MANUAL_INTERACTION_REQUIRED_TITLE, message.Message);
|
||||
}
|
||||
|
||||
public override string Name => "Kodi";
|
||||
|
||||
public override ValidationResult Test()
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.History;
|
||||
|
||||
namespace NzbDrone.Core.Parser.Model
|
||||
{
|
||||
|
@ -9,5 +11,20 @@ public class GrabbedReleaseInfo
|
|||
public long Size { get; set; }
|
||||
|
||||
public List<int> MovieIds { get; set; }
|
||||
|
||||
public GrabbedReleaseInfo(List<MovieHistory> grabbedHistories)
|
||||
{
|
||||
var grabbedHistory = grabbedHistories.MaxBy(h => h.Date);
|
||||
var movieIds = grabbedHistories.Select(h => h.MovieId).Distinct().ToList();
|
||||
|
||||
grabbedHistory.Data.TryGetValue("indexer", out var indexer);
|
||||
grabbedHistory.Data.TryGetValue("size", out var sizeString);
|
||||
long.TryParse(sizeString, out var size);
|
||||
|
||||
Title = grabbedHistory.SourceTitle;
|
||||
Indexer = indexer;
|
||||
Size = size;
|
||||
MovieIds = movieIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public class NotificationResource : ProviderResource<NotificationResource>
|
|||
public bool OnHealthIssue { get; set; }
|
||||
public bool OnHealthRestored { get; set; }
|
||||
public bool OnApplicationUpdate { get; set; }
|
||||
public bool OnManualInteractionRequired { get; set; }
|
||||
public bool SupportsOnGrab { get; set; }
|
||||
public bool SupportsOnDownload { get; set; }
|
||||
public bool SupportsOnUpgrade { get; set; }
|
||||
|
@ -27,6 +28,7 @@ public class NotificationResource : ProviderResource<NotificationResource>
|
|||
public bool SupportsOnHealthIssue { get; set; }
|
||||
public bool SupportsOnHealthRestored { get; set; }
|
||||
public bool SupportsOnApplicationUpdate { get; set; }
|
||||
public bool SupportsOnManualInteractionRequired { get; set; }
|
||||
public bool IncludeHealthWarnings { get; set; }
|
||||
public string TestCommand { get; set; }
|
||||
}
|
||||
|
@ -53,6 +55,7 @@ public override NotificationResource ToResource(NotificationDefinition definitio
|
|||
resource.OnHealthIssue = definition.OnHealthIssue;
|
||||
resource.OnHealthRestored = definition.OnHealthRestored;
|
||||
resource.OnApplicationUpdate = definition.OnApplicationUpdate;
|
||||
resource.OnManualInteractionRequired = definition.OnManualInteractionRequired;
|
||||
resource.SupportsOnGrab = definition.SupportsOnGrab;
|
||||
resource.SupportsOnDownload = definition.SupportsOnDownload;
|
||||
resource.SupportsOnUpgrade = definition.SupportsOnUpgrade;
|
||||
|
@ -65,6 +68,7 @@ public override NotificationResource ToResource(NotificationDefinition definitio
|
|||
resource.SupportsOnHealthRestored = definition.SupportsOnHealthRestored;
|
||||
resource.IncludeHealthWarnings = definition.IncludeHealthWarnings;
|
||||
resource.SupportsOnApplicationUpdate = definition.SupportsOnApplicationUpdate;
|
||||
resource.SupportsOnManualInteractionRequired = definition.SupportsOnManualInteractionRequired;
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
@ -89,6 +93,7 @@ public override NotificationDefinition ToModel(NotificationResource resource)
|
|||
definition.OnHealthIssue = resource.OnHealthIssue;
|
||||
definition.OnHealthRestored = resource.OnHealthRestored;
|
||||
definition.OnApplicationUpdate = resource.OnApplicationUpdate;
|
||||
definition.OnManualInteractionRequired = resource.OnManualInteractionRequired;
|
||||
definition.SupportsOnGrab = resource.SupportsOnGrab;
|
||||
definition.SupportsOnDownload = resource.SupportsOnDownload;
|
||||
definition.SupportsOnUpgrade = resource.SupportsOnUpgrade;
|
||||
|
@ -101,6 +106,7 @@ public override NotificationDefinition ToModel(NotificationResource resource)
|
|||
definition.SupportsOnHealthRestored = resource.SupportsOnHealthRestored;
|
||||
definition.IncludeHealthWarnings = resource.IncludeHealthWarnings;
|
||||
definition.SupportsOnApplicationUpdate = resource.SupportsOnApplicationUpdate;
|
||||
definition.SupportsOnManualInteractionRequired = resource.SupportsOnManualInteractionRequired;
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue