New: Notifications when Manual Interaction is required for importing

(cherry picked from commit 5ec282750bdea16f770282b80fdaec56a65749e2)
This commit is contained in:
Stickie 2022-10-17 18:19:54 +02:00 committed by Bogdan
parent 8563ed0a20
commit a1e622a363
49 changed files with 524 additions and 34 deletions

View File

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

View File

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

View File

@ -111,6 +111,7 @@ export default {
selectedSchema.onMovieFileDelete = selectedSchema.supportsOnMovieFileDelete;
selectedSchema.onMovieFileDeleteForUpgrade = selectedSchema.supportsOnMovieFileDeleteForUpgrade;
selectedSchema.onApplicationUpdate = selectedSchema.supportsOnApplicationUpdate;
selectedSchema.onManualInteractionRequired = selectedSchema.supportsOnManualInteractionRequired;
return selectedSchema;
});

View File

@ -52,8 +52,8 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests
.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 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests
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 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests
_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 @@ namespace NzbDrone.Core.Test.Download.CompletedDownloadServiceTests
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();

View File

@ -2,7 +2,9 @@ using System.Linq;
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 @@ namespace NzbDrone.Core.Test.MediaFiles.MovieImport.Specifications
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]

View File

@ -93,6 +93,11 @@ namespace NzbDrone.Core.Test.NotificationTests
{
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 @@ namespace NzbDrone.Core.Test.NotificationTests
notification.SupportsOnHealthIssue.Should().BeTrue();
notification.SupportsOnHealthRestored.Should().BeTrue();
notification.SupportsOnApplicationUpdate.Should().BeTrue();
notification.SupportsOnManualInteractionRequired.Should().BeTrue();
}
[Test]
@ -152,6 +158,7 @@ namespace NzbDrone.Core.Test.NotificationTests
notification.SupportsOnHealthIssue.Should().BeFalse();
notification.SupportsOnHealthRestored.Should().BeFalse();
notification.SupportsOnApplicationUpdate.Should().BeFalse();
notification.SupportsOnManualInteractionRequired.Should().BeFalse();
}
}
}

View File

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

View File

@ -94,7 +94,8 @@ namespace NzbDrone.Core.Datastore
.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)

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
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 @@ namespace NzbDrone.Core.Download
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 @@ namespace NzbDrone.Core.Download
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;
}
}

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

View File

@ -15,6 +15,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
IExecute<CheckForFinishedDownloadCommand>,
IHandle<MovieGrabbedEvent>,
IHandle<MovieFileImportedEvent>,
IHandle<ManualInteractionRequiredEvent>,
IHandle<DownloadsProcessedEvent>,
IHandle<TrackedDownloadsRemovedEvent>
{
@ -169,6 +170,11 @@ namespace NzbDrone.Core.Download.TrackedDownloads
_refreshDebounce.Execute();
}
public void Handle(ManualInteractionRequiredEvent message)
{
_refreshDebounce.Execute();
}
public void Handle(MovieFileImportedEvent message)
{
_refreshDebounce.Execute();

View File

@ -1,3 +1,4 @@
using System;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
@ -15,10 +16,11 @@ namespace NzbDrone.Core.Download.TrackedDownloads
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)

View File

@ -107,7 +107,8 @@ namespace NzbDrone.Core.Download.TrackedDownloads
DownloadClient = downloadClient.Id,
DownloadItem = downloadItem,
Protocol = downloadClient.Protocol,
IsTrackable = true
IsTrackable = true,
HasNotifiedManualInteractionRequired = existingItem?.HasNotifiedManualInteractionRequired ?? false
};
try

View File

@ -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",

View File

@ -31,20 +31,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Aggregation.Aggregators
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;
}

View File

@ -58,6 +58,11 @@ namespace NzbDrone.Core.Notifications.Apprise
_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>();

View File

@ -57,6 +57,11 @@ namespace NzbDrone.Core.Notifications.Boxcar
_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>();

View File

@ -277,6 +277,30 @@ namespace NzbDrone.Core.Notifications.CustomScript
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>();

View File

@ -379,6 +379,95 @@ namespace NzbDrone.Core.Notifications.Discord
_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>();

View File

@ -33,4 +33,18 @@ namespace NzbDrone.Core.Notifications.Discord
Poster,
Fanart
}
public enum DiscordManualInteractionFieldType
{
Overview,
Rating,
Genres,
Quality,
Group,
Size,
Links,
DownloadTitle,
Poster,
Fanart
}
}

View File

@ -21,6 +21,7 @@ namespace NzbDrone.Core.Notifications.Discord
// 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 @@ namespace NzbDrone.Core.Notifications.Discord
[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));

View File

@ -79,6 +79,13 @@ namespace NzbDrone.Core.Notifications.Email
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>();

View File

@ -63,6 +63,11 @@ namespace NzbDrone.Core.Notifications.Gotify
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>();

View File

@ -18,6 +18,7 @@ namespace NzbDrone.Core.Notifications
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 @@ namespace NzbDrone.Core.Notifications
bool SupportsOnHealthIssue { get; }
bool SupportsOnHealthRestored { get; }
bool SupportsOnApplicationUpdate { get; }
bool SupportsOnManualInteractionRequired { get; }
}
}

View File

@ -58,6 +58,11 @@ namespace NzbDrone.Core.Notifications.Join
_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>();

View File

@ -64,6 +64,11 @@ namespace NzbDrone.Core.Notifications.Mailgun
_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>();

View File

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

View File

@ -67,6 +67,11 @@ namespace NzbDrone.Core.Notifications.Notifiarr
_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>();

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Notifications
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 @@ namespace NzbDrone.Core.Notifications
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 @@ namespace NzbDrone.Core.Notifications
{
}
public virtual void OnManualInteractionRequired(ManualInteractionRequiredMessage message)
{
}
public virtual void ProcessQueue()
{
}
@ -93,6 +99,7 @@ namespace NzbDrone.Core.Notifications
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;

View File

@ -15,6 +15,7 @@ namespace NzbDrone.Core.Notifications
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 @@ namespace NzbDrone.Core.Notifications
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;
}
}

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Notifications
List<INotification> OnHealthIssueEnabled();
List<INotification> OnHealthRestoredEnabled();
List<INotification> OnApplicationUpdateEnabled();
List<INotification> OnManualInteractionEnabled();
}
public class NotificationFactory : ProviderFactory<INotification, NotificationDefinition>, INotificationFactory
@ -83,6 +84,11 @@ namespace NzbDrone.Core.Notifications
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 @@ namespace NzbDrone.Core.Notifications
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
definition.SupportsOnHealthRestored = provider.SupportsOnHealthRestored;
definition.SupportsOnApplicationUpdate = provider.SupportsOnApplicationUpdate;
definition.SupportsOnManualInteractionRequired = provider.SupportsOnManualInteractionRequired;
}
}
}

View File

@ -3,6 +3,7 @@ using System.Linq;
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 @@ namespace NzbDrone.Core.Notifications
IHandle<HealthCheckFailedEvent>,
IHandle<HealthCheckRestoredEvent>,
IHandle<UpdateInstalledEvent>,
IHandle<ManualInteractionRequiredEvent>,
IHandleAsync<DeleteCompletedEvent>,
IHandleAsync<DownloadsProcessedEvent>,
IHandleAsync<RenameCompletedEvent>,
@ -237,6 +239,39 @@ namespace NzbDrone.Core.Notifications
}
}
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();

View File

@ -59,6 +59,11 @@ namespace NzbDrone.Core.Notifications.Ntfy
_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>();

View File

@ -57,6 +57,11 @@ namespace NzbDrone.Core.Notifications.Prowl
_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>();

View File

@ -60,6 +60,11 @@ namespace NzbDrone.Core.Notifications.PushBullet
_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>();

View File

@ -57,6 +57,11 @@ namespace NzbDrone.Core.Notifications.Pushover
_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>();

View File

@ -60,6 +60,11 @@ namespace NzbDrone.Core.Notifications.SendGrid
_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>();

View File

@ -57,6 +57,11 @@ namespace NzbDrone.Core.Notifications.Simplepush
_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>();

View File

@ -157,6 +157,23 @@ namespace NzbDrone.Core.Notifications.Slack
_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>();

View File

@ -65,6 +65,11 @@ namespace NzbDrone.Core.Notifications.Telegram
_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>();

View File

@ -59,6 +59,11 @@ namespace NzbDrone.Core.Notifications.Twitter
_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")

View File

@ -65,6 +65,11 @@ namespace NzbDrone.Core.Notifications.Webhook
_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()

View File

@ -4,6 +4,7 @@ using System.Linq;
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 @@ namespace NzbDrone.Core.Notifications.Webhook
};
}
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

View File

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

View File

@ -17,6 +17,7 @@ namespace NzbDrone.Core.Notifications.Webhook
Health,
ApplicationUpdate,
MovieAdded,
HealthRestored
HealthRestored,
ManualInteractionRequired
}
}

View File

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

View File

@ -76,6 +76,11 @@ namespace NzbDrone.Core.Notifications.Xbmc
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()

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.History;
namespace NzbDrone.Core.Parser.Model
{
@ -9,5 +11,20 @@ namespace NzbDrone.Core.Parser.Model
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;
}
}
}

View File

@ -16,6 +16,7 @@ namespace Radarr.Api.V3.Notifications
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 @@ namespace Radarr.Api.V3.Notifications
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 @@ namespace Radarr.Api.V3.Notifications
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 @@ namespace Radarr.Api.V3.Notifications
resource.SupportsOnHealthRestored = definition.SupportsOnHealthRestored;
resource.IncludeHealthWarnings = definition.IncludeHealthWarnings;
resource.SupportsOnApplicationUpdate = definition.SupportsOnApplicationUpdate;
resource.SupportsOnManualInteractionRequired = definition.SupportsOnManualInteractionRequired;
return resource;
}
@ -89,6 +93,7 @@ namespace Radarr.Api.V3.Notifications
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 @@ namespace Radarr.Api.V3.Notifications
definition.SupportsOnHealthRestored = resource.SupportsOnHealthRestored;
definition.IncludeHealthWarnings = resource.IncludeHealthWarnings;
definition.SupportsOnApplicationUpdate = resource.SupportsOnApplicationUpdate;
definition.SupportsOnManualInteractionRequired = resource.SupportsOnManualInteractionRequired;
return definition;
}