diff --git a/frontend/src/Settings/Notifications/Notifications/Notification.js b/frontend/src/Settings/Notifications/Notifications/Notification.js index 9e25e0904..b4aebae09 100644 --- a/frontend/src/Settings/Notifications/Notifications/Notification.js +++ b/frontend/src/Settings/Notifications/Notifications/Notification.js @@ -59,6 +59,7 @@ class Notification extends Component { onDownload, onUpgrade, onRename, + onMovieAdded, onMovieDelete, onMovieFileDelete, onMovieFileDeleteForUpgrade, @@ -68,6 +69,7 @@ class Notification extends Component { supportsOnDownload, supportsOnUpgrade, supportsOnRename, + supportsOnMovieAdded, supportsOnMovieDelete, supportsOnMovieFileDelete, supportsOnMovieFileDeleteForUpgrade, @@ -117,6 +119,14 @@ class Notification extends Component { null } + { + supportsOnMovieAdded && onMovieAdded ? + + {translate('OnMovieAdded')} + : + null + } + { supportsOnHealthIssue && onHealthIssue ? @@ -196,6 +206,7 @@ Notification.propTypes = { onDownload: PropTypes.bool.isRequired, onUpgrade: PropTypes.bool.isRequired, onRename: PropTypes.bool.isRequired, + onMovieAdded: PropTypes.bool.isRequired, onMovieDelete: PropTypes.bool.isRequired, onMovieFileDelete: PropTypes.bool.isRequired, onMovieFileDeleteForUpgrade: PropTypes.bool.isRequired, @@ -208,6 +219,7 @@ Notification.propTypes = { supportsOnMovieFileDeleteForUpgrade: PropTypes.bool.isRequired, supportsOnUpgrade: PropTypes.bool.isRequired, supportsOnRename: PropTypes.bool.isRequired, + supportsOnMovieAdded: PropTypes.bool.isRequired, supportsOnHealthIssue: PropTypes.bool.isRequired, supportsOnApplicationUpdate: PropTypes.bool.isRequired, onConfirmDeleteNotification: PropTypes.func.isRequired diff --git a/frontend/src/Settings/Notifications/Notifications/NotificationEventItems.js b/frontend/src/Settings/Notifications/Notifications/NotificationEventItems.js index 1f665b459..b7e5cbb8a 100644 --- a/frontend/src/Settings/Notifications/Notifications/NotificationEventItems.js +++ b/frontend/src/Settings/Notifications/Notifications/NotificationEventItems.js @@ -19,6 +19,7 @@ function NotificationEventItems(props) { onDownload, onUpgrade, onRename, + onMovieAdded, onMovieDelete, onMovieFileDelete, onMovieFileDeleteForUpgrade, @@ -28,6 +29,7 @@ function NotificationEventItems(props) { supportsOnDownload, supportsOnUpgrade, supportsOnRename, + supportsOnMovieAdded, supportsOnMovieDelete, supportsOnMovieFileDelete, supportsOnMovieFileDeleteForUpgrade, @@ -92,6 +94,17 @@ function NotificationEventItems(props) { /> + + + + renamedFi TestLogger.Info("OnRename was called"); } + public override void OnMovieAdded(Movie movie) + { + TestLogger.Info("OnMovieAdded was called"); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage message) { TestLogger.Info("OnMovieFileDelete was called"); @@ -117,6 +122,7 @@ public void should_support_all_if_implemented() notification.SupportsOnDownload.Should().BeTrue(); notification.SupportsOnUpgrade.Should().BeTrue(); notification.SupportsOnRename.Should().BeTrue(); + notification.SupportsOnMovieAdded.Should().BeTrue(); notification.SupportsOnMovieDelete.Should().BeTrue(); notification.SupportsOnMovieFileDelete.Should().BeTrue(); notification.SupportsOnMovieFileDeleteForUpgrade.Should().BeTrue(); @@ -133,6 +139,7 @@ public void should_support_none_if_none_are_implemented() notification.SupportsOnDownload.Should().BeFalse(); notification.SupportsOnUpgrade.Should().BeFalse(); notification.SupportsOnRename.Should().BeFalse(); + notification.SupportsOnMovieAdded.Should().BeFalse(); notification.SupportsOnMovieDelete.Should().BeFalse(); notification.SupportsOnMovieFileDelete.Should().BeFalse(); notification.SupportsOnMovieFileDeleteForUpgrade.Should().BeFalse(); diff --git a/src/NzbDrone.Core/Datastore/Migration/210_movie_added_notifications.cs b/src/NzbDrone.Core/Datastore/Migration/210_movie_added_notifications.cs new file mode 100644 index 000000000..a9715d502 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/210_movie_added_notifications.cs @@ -0,0 +1,14 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(210)] + public class movie_added_notifications : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Notifications").AddColumn("OnMovieAdded").AsBoolean().WithDefaultValue(false); + } + } +} diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 357ce19c5..b6287c09a 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -88,6 +88,7 @@ public static void Map() .Ignore(i => i.SupportsOnDownload) .Ignore(i => i.SupportsOnUpgrade) .Ignore(i => i.SupportsOnRename) + .Ignore(i => i.SupportsOnMovieAdded) .Ignore(i => i.SupportsOnMovieDelete) .Ignore(i => i.SupportsOnMovieFileDelete) .Ignore(i => i.SupportsOnMovieFileDeleteForUpgrade) diff --git a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs index 204db5b89..801a27fcb 100644 --- a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs +++ b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs @@ -107,7 +107,8 @@ private void ProcessMovieReport(ImportListDefinition importList, ImportListMovie AddOptions = new AddMovieOptions { SearchForMovie = monitorType != MonitorTypes.None && importList.SearchOnAdd, - Monitor = monitorType + Monitor = monitorType, + AddMethod = AddMovieMethod.List } }); } diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index a7aaf472a..5139bc847 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -648,6 +648,8 @@ "OnLatestVersion": "The latest version of Radarr is already installed", "OnlyTorrent": "Only Torrent", "OnlyUsenet": "Only Usenet", + "OnMovieAdded": "On Movie Added", + "OnMovieAddedHelpText": "On Movie Added", "OnMovieDelete": "On Movie Delete", "OnMovieDeleteHelpText": "On Movie Delete", "OnMovieFileDelete": "On Movie File Delete", diff --git a/src/NzbDrone.Core/Movies/AddMovieOptions.cs b/src/NzbDrone.Core/Movies/AddMovieOptions.cs index 29f52abc1..c91803590 100644 --- a/src/NzbDrone.Core/Movies/AddMovieOptions.cs +++ b/src/NzbDrone.Core/Movies/AddMovieOptions.cs @@ -3,5 +3,13 @@ namespace NzbDrone.Core.Movies public class AddMovieOptions : MonitoringOptions { public bool SearchForMovie { get; set; } + public AddMovieMethod AddMethod { get; set; } + } + + public enum AddMovieMethod + { + Manual, + List, + Collection } } diff --git a/src/NzbDrone.Core/Movies/RefreshCollectionService.cs b/src/NzbDrone.Core/Movies/RefreshCollectionService.cs index 671471b4e..d4d46b11b 100644 --- a/src/NzbDrone.Core/Movies/RefreshCollectionService.cs +++ b/src/NzbDrone.Core/Movies/RefreshCollectionService.cs @@ -109,7 +109,8 @@ private void SyncCollectionMovies(MovieCollection collection) MinimumAvailability = collection.MinimumAvailability, AddOptions = new AddMovieOptions { - SearchForMovie = collection.SearchOnAdd + SearchForMovie = collection.SearchOnAdd, + AddMethod = AddMovieMethod.Collection }, Monitored = true }).ToList()); diff --git a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs index aa06ab8c3..a76318bce 100644 --- a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs +++ b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Boxcar { @@ -26,6 +27,11 @@ public override void OnDownload(DownloadMessage message) _proxy.SendNotification(MOVIE_DOWNLOADED_TITLE, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE_BRANDED, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index a83f0ffae..b14eca6e8 100755 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -125,6 +125,22 @@ public override void OnMovieRename(Movie movie, List renamedFi ExecuteScript(environmentVariables); } + public override void OnMovieAdded(Movie movie) + { + var environmentVariables = new StringDictionary(); + + environmentVariables.Add("Radarr_EventType", "MovieAdded"); + 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_AddMethod", movie.AddOptions.AddMethod.ToString()); + + ExecuteScript(environmentVariables); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { var movie = deleteMessage.Movie; diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 07a232120..53361e555 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -8,6 +8,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http.Dispatchers; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Email { @@ -40,6 +41,13 @@ public override void OnDownload(DownloadMessage message) SendEmail(Settings, MOVIE_DOWNLOADED_TITLE_BRANDED, body); } + public override void OnMovieAdded(Movie movie) + { + var body = $"{movie.Title} added to library."; + + SendEmail(Settings, MOVIE_ADDED_TITLE_BRANDED, body); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { var body = $"{deleteMessage.Message} deleted."; diff --git a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs index 789ebc34c..3932801a6 100644 --- a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs +++ b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NLog; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Gotify { @@ -29,6 +30,11 @@ public override void OnDownload(DownloadMessage message) _proxy.SendNotification(MOVIE_DOWNLOADED_TITLE, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/INotification.cs b/src/NzbDrone.Core/Notifications/INotification.cs index d8a11006e..68c592782 100644 --- a/src/NzbDrone.Core/Notifications/INotification.cs +++ b/src/NzbDrone.Core/Notifications/INotification.cs @@ -14,6 +14,7 @@ public interface INotification : IProvider void OnMovieRename(Movie movie, List renamedFiles); void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage); void OnMovieDelete(MovieDeleteMessage deleteMessage); + void OnMovieAdded(Movie movie); void OnHealthIssue(HealthCheck.HealthCheck healthCheck); void OnApplicationUpdate(ApplicationUpdateMessage updateMessage); void ProcessQueue(); @@ -21,6 +22,7 @@ public interface INotification : IProvider bool SupportsOnDownload { get; } bool SupportsOnUpgrade { get; } bool SupportsOnRename { get; } + bool SupportsOnMovieAdded { get; } bool SupportsOnMovieDelete { get; } bool SupportsOnMovieFileDelete { get; } bool SupportsOnMovieFileDeleteForUpgrade { get; } diff --git a/src/NzbDrone.Core/Notifications/Join/Join.cs b/src/NzbDrone.Core/Notifications/Join/Join.cs index 94acccb68..0eb96a9f2 100644 --- a/src/NzbDrone.Core/Notifications/Join/Join.cs +++ b/src/NzbDrone.Core/Notifications/Join/Join.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Join { @@ -27,6 +28,11 @@ public override void OnDownload(DownloadMessage message) _proxy.SendNotification(MOVIE_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE_BRANDED, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE_BRANDED, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/Mailgun/Mailgun.cs b/src/NzbDrone.Core/Notifications/Mailgun/Mailgun.cs index 3cafa6f10..e5b517a70 100644 --- a/src/NzbDrone.Core/Notifications/Mailgun/Mailgun.cs +++ b/src/NzbDrone.Core/Notifications/Mailgun/Mailgun.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NLog; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Mailgun { @@ -29,6 +30,11 @@ public override void OnDownload(DownloadMessage downloadMessage) _proxy.SendNotification(downloadMessage.OldMovieFiles.Count > 0 ? MOVIE_UPGRADED_TITLE : MOVIE_DOWNLOADED_TITLE, downloadMessage.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { var body = $"{deleteMessage.Message} deleted."; diff --git a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs index 005158fdc..9f88f43f7 100644 --- a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs @@ -6,6 +6,7 @@ using FluentValidation.Results; using NzbDrone.Common.Extensions; using NzbDrone.Core.HealthCheck; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Notifiarr { @@ -116,6 +117,22 @@ public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) _proxy.SendNotification(variables, Settings); } + public override void OnMovieAdded(Movie movie) + { + var variables = new StringDictionary(); + + variables.Add("Radarr_EventType", "MovieAdded"); + variables.Add("Radarr_Movie_Id", movie.Id.ToString()); + variables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title); + variables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString()); + variables.Add("Radarr_Movie_Path", movie.Path); + variables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty); + variables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString()); + variables.Add("Radarr_Movie_AddMethod", movie.AddOptions.AddMethod.ToString()); + + _proxy.SendNotification(variables, Settings); + } + public override void OnMovieDelete(MovieDeleteMessage deleteMessage) { var movie = deleteMessage.Movie; diff --git a/src/NzbDrone.Core/Notifications/NotificationBase.cs b/src/NzbDrone.Core/Notifications/NotificationBase.cs index e99d4e1ed..169132bd1 100644 --- a/src/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/src/NzbDrone.Core/Notifications/NotificationBase.cs @@ -13,12 +13,14 @@ public abstract class NotificationBase : INotification protected const string MOVIE_GRABBED_TITLE = "Movie Grabbed"; protected const string MOVIE_DOWNLOADED_TITLE = "Movie Downloaded"; protected const string MOVIE_UPGRADED_TITLE = "Movie Upgraded"; + protected const string MOVIE_ADDED_TITLE = "Movie Added"; protected const string MOVIE_DELETED_TITLE = "Movie Deleted"; protected const string MOVIE_FILE_DELETED_TITLE = "Movie File Deleted"; protected const string HEALTH_ISSUE_TITLE = "Health Check Failure"; protected const string APPLICATION_UPDATE_TITLE = "Application Updated"; protected const string MOVIE_GRABBED_TITLE_BRANDED = "Radarr - " + MOVIE_GRABBED_TITLE; + protected const string MOVIE_ADDED_TITLE_BRANDED = "Radarr - " + MOVIE_ADDED_TITLE; protected const string MOVIE_DOWNLOADED_TITLE_BRANDED = "Radarr - " + MOVIE_DOWNLOADED_TITLE; protected const string MOVIE_DELETED_TITLE_BRANDED = "Radarr - " + MOVIE_DELETED_TITLE; protected const string MOVIE_FILE_DELETED_TITLE_BRANDED = "Radarr - " + MOVIE_FILE_DELETED_TITLE; @@ -50,6 +52,10 @@ public virtual void OnMovieRename(Movie movie, List renamedFil { } + public virtual void OnMovieAdded(Movie movie) + { + } + public virtual void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { } @@ -74,6 +80,7 @@ public virtual void ProcessQueue() public bool SupportsOnRename => HasConcreteImplementation("OnMovieRename"); public bool SupportsOnDownload => HasConcreteImplementation("OnDownload"); public bool SupportsOnUpgrade => SupportsOnDownload; + public bool SupportsOnMovieAdded => HasConcreteImplementation("OnMovieAdded"); public bool SupportsOnMovieDelete => HasConcreteImplementation("OnMovieDelete"); public bool SupportsOnMovieFileDelete => HasConcreteImplementation("OnMovieFileDelete"); public bool SupportsOnMovieFileDeleteForUpgrade => SupportsOnMovieFileDelete; diff --git a/src/NzbDrone.Core/Notifications/NotificationDefinition.cs b/src/NzbDrone.Core/Notifications/NotificationDefinition.cs index aea00bafd..169948111 100644 --- a/src/NzbDrone.Core/Notifications/NotificationDefinition.cs +++ b/src/NzbDrone.Core/Notifications/NotificationDefinition.cs @@ -8,6 +8,7 @@ public class NotificationDefinition : ProviderDefinition public bool OnDownload { get; set; } public bool OnUpgrade { get; set; } public bool OnRename { get; set; } + public bool OnMovieAdded { get; set; } public bool OnMovieDelete { get; set; } public bool OnMovieFileDelete { get; set; } public bool OnMovieFileDeleteForUpgrade { get; set; } @@ -17,6 +18,7 @@ public class NotificationDefinition : ProviderDefinition public bool SupportsOnDownload { get; set; } public bool SupportsOnUpgrade { get; set; } public bool SupportsOnRename { get; set; } + public bool SupportsOnMovieAdded { get; set; } public bool SupportsOnMovieDelete { get; set; } public bool SupportsOnMovieFileDelete { get; set; } public bool SupportsOnMovieFileDeleteForUpgrade { get; set; } @@ -24,6 +26,6 @@ public class NotificationDefinition : ProviderDefinition public bool IncludeHealthWarnings { get; set; } public bool SupportsOnApplicationUpdate { get; set; } - public override bool Enable => OnGrab || OnDownload || (OnDownload && OnUpgrade) || OnMovieDelete || OnMovieFileDelete || OnMovieFileDeleteForUpgrade || OnHealthIssue || OnApplicationUpdate; + public override bool Enable => OnGrab || OnDownload || (OnDownload && OnUpgrade) || OnMovieAdded || OnMovieDelete || OnMovieFileDelete || OnMovieFileDeleteForUpgrade || OnHealthIssue || OnApplicationUpdate; } } diff --git a/src/NzbDrone.Core/Notifications/NotificationFactory.cs b/src/NzbDrone.Core/Notifications/NotificationFactory.cs index 51321cf07..61923fa0c 100644 --- a/src/NzbDrone.Core/Notifications/NotificationFactory.cs +++ b/src/NzbDrone.Core/Notifications/NotificationFactory.cs @@ -13,6 +13,7 @@ public interface INotificationFactory : IProviderFactory OnDownloadEnabled(); List OnUpgradeEnabled(); List OnRenameEnabled(); + List OnMovieAddedEnabled(); List OnMovieDeleteEnabled(); List OnMovieFileDeleteEnabled(); List OnHealthIssueEnabled(); @@ -46,6 +47,11 @@ public List OnRenameEnabled() return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnRename).ToList(); } + public List OnMovieAddedEnabled() + { + return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieAdded).ToList(); + } + public List OnMovieDeleteEnabled() { return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieDelete).ToList(); diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 62b799742..2bfba5116 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -19,6 +19,7 @@ public class NotificationService IHandle, IHandle, IHandle, + IHandle, IHandle, IHandle, IHandle, @@ -155,6 +156,24 @@ public void Handle(MovieImportedEvent message) } } + public void Handle(MovieAddedEvent message) + { + foreach (var notification in _notificationFactory.OnMovieAddedEnabled()) + { + try + { + if (ShouldHandleMovie(notification.Definition, message.Movie)) + { + notification.OnMovieAdded(message.Movie); + } + } + catch (Exception ex) + { + _logger.Warn(ex, "Unable to send OnMovieAdded notification to: " + notification.Definition.Name); + } + } + } + public void Handle(MovieRenamedEvent message) { foreach (var notification in _notificationFactory.OnRenameEnabled()) diff --git a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs index fbd8bc19c..e19df0b1d 100644 --- a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs +++ b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Prowl { @@ -26,6 +27,11 @@ public override void OnDownload(DownloadMessage message) _prowlProxy.SendNotification(MOVIE_DOWNLOADED_TITLE, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _prowlProxy.SendNotification(MOVIE_ADDED_TITLE, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _prowlProxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs index d3be5c47d..a122f6ea3 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs @@ -3,6 +3,7 @@ using System.Linq; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Movies; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.PushBullet @@ -29,6 +30,11 @@ public override void OnDownload(DownloadMessage message) _proxy.SendNotification(MOVIE_DOWNLOADED_TITLE_BRANDED, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE_BRANDED, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs index bfa28e000..7f6a46cef 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Pushover { @@ -26,6 +27,11 @@ public override void OnDownload(DownloadMessage message) _proxy.SendNotification(MOVIE_DOWNLOADED_TITLE, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs b/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs index 7a7a479a1..fbb03bb43 100644 --- a/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs +++ b/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NLog; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.SendGrid { @@ -29,6 +30,11 @@ public override void OnDownload(DownloadMessage message) _proxy.SendNotification(MOVIE_DOWNLOADED_TITLE, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/Simplepush/Simplepush.cs b/src/NzbDrone.Core/Notifications/Simplepush/Simplepush.cs index ec96917f1..d1c77ce8f 100644 --- a/src/NzbDrone.Core/Notifications/Simplepush/Simplepush.cs +++ b/src/NzbDrone.Core/Notifications/Simplepush/Simplepush.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Simplepush { @@ -26,6 +27,11 @@ public override void OnDownload(DownloadMessage message) _proxy.SendNotification(MOVIE_DOWNLOADED_TITLE, message.Message, Settings); } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs index cb2af1940..dc990016e 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs @@ -2,6 +2,7 @@ using System.Linq; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Movies; namespace NzbDrone.Core.Notifications.Telegram { @@ -34,6 +35,11 @@ public override void OnDownload(DownloadMessage message) } } + public override void OnMovieAdded(Movie movie) + { + _proxy.SendNotification(MOVIE_ADDED_TITLE, $"{movie.Title} added to library", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _proxy.SendNotification(MOVIE_FILE_DELETED_TITLE, deleteMessage.Message, Settings); diff --git a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs index d5576d7f6..cabf74dd9 100644 --- a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs +++ b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs @@ -2,6 +2,7 @@ using FluentValidation.Results; using NzbDrone.Common.Extensions; using NzbDrone.Core.Exceptions; +using NzbDrone.Core.Movies; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.Twitter @@ -28,6 +29,11 @@ public override void OnDownload(DownloadMessage message) _twitterService.SendNotification($"[Radarr] Imported: {message.Message}", Settings); } + public override void OnMovieAdded(Movie movie) + { + _twitterService.SendNotification($"[Radarr] Added: {movie.Title}", Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { _twitterService.SendNotification($"Movie File Deleted: {deleteMessage.Message}", Settings); diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 192fddcb2..f6f9837f4 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -79,6 +79,17 @@ public override void OnMovieRename(Movie movie, List renamedFi _proxy.SendWebhook(payload, Settings); } + public override void OnMovieAdded(Movie movie) + { + var payload = new WebhookRenamePayload + { + EventType = WebhookEventType.MovieAdded, + Movie = new WebhookMovie(movie) + }; + + _proxy.SendWebhook(payload, Settings); + } + public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage) { var payload = new WebhookMovieFileDeletePayload diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookAddedPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookAddedPayload.cs new file mode 100644 index 000000000..e5d74bd14 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookAddedPayload.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookAddedPayload : WebhookPayload + { + public WebhookMovie Movie { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs index 335706143..fe58da46b 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs @@ -15,6 +15,7 @@ public enum WebhookEventType MovieDelete, MovieFileDelete, Health, - ApplicationUpdate + ApplicationUpdate, + MovieAdded } } diff --git a/src/Radarr.Api.V3/Notifications/NotificationResource.cs b/src/Radarr.Api.V3/Notifications/NotificationResource.cs index 78f7d1447..4bd4438d6 100644 --- a/src/Radarr.Api.V3/Notifications/NotificationResource.cs +++ b/src/Radarr.Api.V3/Notifications/NotificationResource.cs @@ -9,6 +9,7 @@ public class NotificationResource : ProviderResource public bool OnDownload { get; set; } public bool OnUpgrade { get; set; } public bool OnRename { get; set; } + public bool OnMovieAdded { get; set; } public bool OnMovieDelete { get; set; } public bool OnMovieFileDelete { get; set; } public bool OnMovieFileDeleteForUpgrade { get; set; } @@ -18,6 +19,7 @@ public class NotificationResource : ProviderResource public bool SupportsOnDownload { get; set; } public bool SupportsOnUpgrade { get; set; } public bool SupportsOnRename { get; set; } + public bool SupportsOnMovieAdded { get; set; } public bool SupportsOnMovieDelete { get; set; } public bool SupportsOnMovieFileDelete { get; set; } public bool SupportsOnMovieFileDeleteForUpgrade { get; set; } @@ -42,6 +44,7 @@ public override NotificationResource ToResource(NotificationDefinition definitio resource.OnDownload = definition.OnDownload; resource.OnUpgrade = definition.OnUpgrade; resource.OnRename = definition.OnRename; + resource.OnMovieAdded = definition.OnMovieAdded; resource.OnMovieDelete = definition.OnMovieDelete; resource.OnMovieFileDelete = definition.OnMovieFileDelete; resource.OnMovieFileDeleteForUpgrade = definition.OnMovieFileDeleteForUpgrade; @@ -51,6 +54,7 @@ public override NotificationResource ToResource(NotificationDefinition definitio resource.SupportsOnDownload = definition.SupportsOnDownload; resource.SupportsOnUpgrade = definition.SupportsOnUpgrade; resource.SupportsOnRename = definition.SupportsOnRename; + resource.SupportsOnMovieAdded = definition.SupportsOnMovieAdded; resource.SupportsOnMovieDelete = definition.SupportsOnMovieDelete; resource.SupportsOnMovieFileDelete = definition.SupportsOnMovieFileDelete; resource.SupportsOnMovieFileDeleteForUpgrade = definition.SupportsOnMovieFileDeleteForUpgrade; @@ -74,6 +78,7 @@ public override NotificationDefinition ToModel(NotificationResource resource) definition.OnDownload = resource.OnDownload; definition.OnUpgrade = resource.OnUpgrade; definition.OnRename = resource.OnRename; + definition.OnMovieAdded = resource.OnMovieAdded; definition.OnMovieDelete = resource.OnMovieDelete; definition.OnMovieFileDelete = resource.OnMovieFileDelete; definition.OnMovieFileDeleteForUpgrade = resource.OnMovieFileDeleteForUpgrade; @@ -83,6 +88,7 @@ public override NotificationDefinition ToModel(NotificationResource resource) definition.SupportsOnDownload = resource.SupportsOnDownload; definition.SupportsOnUpgrade = resource.SupportsOnUpgrade; definition.SupportsOnRename = resource.SupportsOnRename; + definition.SupportsOnMovieAdded = resource.SupportsOnMovieAdded; definition.SupportsOnMovieDelete = resource.SupportsOnMovieDelete; definition.SupportsOnMovieFileDelete = resource.SupportsOnMovieFileDelete; definition.SupportsOnMovieFileDeleteForUpgrade = resource.SupportsOnMovieFileDeleteForUpgrade;