Initial Notification Updates and Support (#401)

* Bare bones of notifications working.

* Add MovieDownload event handler

To allow Download notificaitons

* Update pushover text to indicate movie

* Initial Notification Support

On Download and On Grab notifications should work.

* Telegram Notification Text

* Update Custom Script For Movies

* Update PP script WiKi page

Also added wiki page to Radarr wiki.
pull/432/head
vertigo235 8 years ago committed by Leonardo Galli
parent 1ad4006819
commit 9e7cb708bf

@ -18,18 +18,22 @@ namespace NzbDrone.Core.Notifications.Boxcar
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Episode Grabbed";
const string title = "Movie Grabbed";
_proxy.SendNotification(title, grabMessage.Message, Settings);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
const string title = "Movie Downloaded";
_proxy.SendNotification(title, message.Message, Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
@ -24,73 +25,73 @@ namespace NzbDrone.Core.Notifications.CustomScript
_logger = logger;
}
public override string Link => "https://github.com/Sonarr/Sonarr/wiki/Custom-Post-Processing-Scripts";
public override string Link => "https://github.com/Radarr/Radarr/wiki/Custom-Post-Processing-Scripts";
public override void OnGrab(GrabMessage message)
{
var series = message.Series;
var remoteEpisode = message.Episode;
var releaseGroup = remoteEpisode.ParsedEpisodeInfo.ReleaseGroup;
var movie = message.Movie;
var remoteMovie = message.RemoteMovie;
var releaseGroup = remoteMovie.ParsedEpisodeInfo.ReleaseGroup;
var environmentVariables = new StringDictionary();
environmentVariables.Add("Sonarr_EventType", "Grab");
environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString());
environmentVariables.Add("Sonarr_Series_Title", series.Title);
environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString());
environmentVariables.Add("Sonarr_Series_Type", series.SeriesType.ToString());
environmentVariables.Add("Sonarr_Release_EpisodeCount", remoteEpisode.Episodes.Count.ToString());
environmentVariables.Add("Sonarr_Release_SeasonNumber", remoteEpisode.ParsedEpisodeInfo.SeasonNumber.ToString());
environmentVariables.Add("Sonarr_Release_EpisodeNumbers", string.Join(",", remoteEpisode.Episodes.Select(e => e.EpisodeNumber)));
environmentVariables.Add("Sonarr_Release_Title", remoteEpisode.Release.Title);
environmentVariables.Add("Sonarr_Release_Indexer", remoteEpisode.Release.Indexer);
environmentVariables.Add("Sonarr_Release_Size", remoteEpisode.Release.Size.ToString());
environmentVariables.Add("Sonarr_Release_ReleaseGroup", releaseGroup);
environmentVariables.Add("Radarr_EventType", "Grab");
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId.ToString());
environmentVariables.Add("Radarr_Release_Title", remoteMovie.Release.Title);
environmentVariables.Add("Radarr_Release_Indexer", remoteMovie.Release.Indexer);
environmentVariables.Add("Radarr_Release_Size", remoteMovie.Release.Size.ToString());
environmentVariables.Add("Radarr_Release_ReleaseGroup", releaseGroup);
ExecuteScript(environmentVariables);
}
public override void OnDownload(DownloadMessage message)
{
var series = message.Series;
var episodeFile = message.EpisodeFile;
var movie = message.Movie;
var movieFile = message.MovieFile;
var sourcePath = message.SourcePath;
var environmentVariables = new StringDictionary();
environmentVariables.Add("Sonarr_EventType", "Download");
environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString());
environmentVariables.Add("Sonarr_Series_Title", series.Title);
environmentVariables.Add("Sonarr_Series_Path", series.Path);
environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString());
environmentVariables.Add("Sonarr_Series_Type", series.SeriesType.ToString());
environmentVariables.Add("Sonarr_EpisodeFile_Id", episodeFile.Id.ToString());
environmentVariables.Add("Sonarr_EpisodeFile_EpisodeCount", episodeFile.Episodes.Value.Count.ToString());
environmentVariables.Add("Sonarr_EpisodeFile_RelativePath", episodeFile.RelativePath);
environmentVariables.Add("Sonarr_EpisodeFile_Path", Path.Combine(series.Path, episodeFile.RelativePath));
environmentVariables.Add("Sonarr_EpisodeFile_SeasonNumber", episodeFile.SeasonNumber.ToString());
environmentVariables.Add("Sonarr_EpisodeFile_EpisodeNumbers", string.Join(",", episodeFile.Episodes.Value.Select(e => e.EpisodeNumber)));
environmentVariables.Add("Sonarr_EpisodeFile_EpisodeAirDates", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDate)));
environmentVariables.Add("Sonarr_EpisodeFile_EpisodeAirDatesUtc", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDateUtc)));
environmentVariables.Add("Sonarr_EpisodeFile_EpisodeTitles", string.Join("|", episodeFile.Episodes.Value.Select(e => e.Title)));
environmentVariables.Add("Sonarr_EpisodeFile_Quality", episodeFile.Quality.Quality.Name);
environmentVariables.Add("Sonarr_EpisodeFile_QualityVersion", episodeFile.Quality.Revision.Version.ToString());
environmentVariables.Add("Sonarr_EpisodeFile_ReleaseGroup", episodeFile.ReleaseGroup ?? string.Empty);
environmentVariables.Add("Sonarr_EpisodeFile_SceneName", episodeFile.SceneName ?? string.Empty);
environmentVariables.Add("Sonarr_EpisodeFile_SourcePath", sourcePath);
environmentVariables.Add("Sonarr_EpisodeFile_SourceFolder", Path.GetDirectoryName(sourcePath));
environmentVariables.Add("Radarr_EventType", "Download");
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId.ToString());
environmentVariables.Add("Radarr_MovieFile_Id", movieFile.Id.ToString());
environmentVariables.Add("Radarr_MovieFile_RelativePath", movieFile.RelativePath);
environmentVariables.Add("Radarr_MovieFile_Path", Path.Combine(movie.Path, movieFile.RelativePath));
environmentVariables.Add("Radarr_MovieFile_Quality", movieFile.Quality.Quality.Name);
environmentVariables.Add("Radarr_MovieFile_QualityVersion", movieFile.Quality.Revision.Version.ToString());
environmentVariables.Add("Radarr_MovieFile_ReleaseGroup", movieFile.ReleaseGroup ?? string.Empty);
environmentVariables.Add("Radarr_MovieFile_SceneName", movieFile.SceneName ?? string.Empty);
environmentVariables.Add("Radarr_MovieFile_SourcePath", sourcePath);
environmentVariables.Add("Radarr_MovieFile_SourceFolder", Path.GetDirectoryName(sourcePath));
ExecuteScript(environmentVariables);
}
public override void OnMovieRename(Movie movie)
{
var environmentVariables = new StringDictionary();
environmentVariables.Add("Radarr_EventType", "Rename");
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_TvdbId", movie.ImdbId.ToString());
ExecuteScript(environmentVariables);
}
public override void OnRename(Series series)
{
var environmentVariables = new StringDictionary();
environmentVariables.Add("Sonarr_EventType", "Rename");
environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString());
environmentVariables.Add("Sonarr_Series_Title", series.Title);
environmentVariables.Add("Sonarr_Series_Path", series.Path);
environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString());
environmentVariables.Add("Sonarr_Series_Type", series.SeriesType.ToString());
environmentVariables.Add("Radarr_EventType", "Rename");
environmentVariables.Add("Radarr_Series_Id", series.Id.ToString());
environmentVariables.Add("Radarr_Series_Title", series.Title);
environmentVariables.Add("Radarr_Series_Path", series.Path);
environmentVariables.Add("Radarr_Series_TvdbId", series.TvdbId.ToString());
environmentVariables.Add("Radarr_Series_Type", series.SeriesType.ToString());
ExecuteScript(environmentVariables);
}

@ -8,8 +8,11 @@ namespace NzbDrone.Core.Notifications
{
public string Message { get; set; }
public Series Series { get; set; }
public Movie Movie { get; set; }
public EpisodeFile EpisodeFile { get; set; }
public List<EpisodeFile> OldFiles { get; set; }
public MovieFile MovieFile { get; set; }
public List<MovieFile> OldMovieFiles { get; set; }
public string SourcePath { get; set; }
public override string ToString()

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Notifications.Email
public override void OnGrab(GrabMessage grabMessage)
{
const string subject = "Radarr [TV] - Grabbed";
const string subject = "Radarr [Movie] - Grabbed";
var body = string.Format("{0} sent to queue.", grabMessage.Message);
_emailService.SendEmail(Settings, subject, body);
@ -26,12 +26,16 @@ namespace NzbDrone.Core.Notifications.Email
public override void OnDownload(DownloadMessage message)
{
const string subject = "Radarr [TV] - Downloaded";
const string subject = "Radarr [Movie] - Downloaded";
var body = string.Format("{0} Downloaded and sorted.", message.Message);
_emailService.SendEmail(Settings, subject, body);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -8,6 +8,8 @@ namespace NzbDrone.Core.Notifications
{
public string Message { get; set; }
public Series Series { get; set; }
public Movie Movie { get; set; }
public RemoteMovie RemoteMovie { get; set; }
public RemoteEpisode Episode { get; set; }
public QualityModel Quality { get; set; }

@ -18,18 +18,22 @@ namespace NzbDrone.Core.Notifications.Growl
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Episode Grabbed";
const string title = "Movie Grabbed";
_growlService.SendNotification(title, grabMessage.Message, "GRAB", Settings.Host, Settings.Port, Settings.Password);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
const string title = "Movie Downloaded";
_growlService.SendNotification(title, message.Message, "DOWNLOAD", Settings.Host, Settings.Port, Settings.Password);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -10,6 +10,7 @@ namespace NzbDrone.Core.Notifications
void OnGrab(GrabMessage grabMessage);
void OnDownload(DownloadMessage message);
void OnRename(Series series);
void OnMovieRename(Movie movie);
bool SupportsOnGrab { get; }
bool SupportsOnDownload { get; }
bool SupportsOnUpgrade { get; }

@ -18,18 +18,22 @@ namespace NzbDrone.Core.Notifications.Join
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Radarr - Episode Grabbed";
const string title = "Radarr - Movie Grabbed";
_proxy.SendNotification(title, grabMessage.Message, Settings);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Radarr - Episode Downloaded";
const string title = "Radarr - Movie Downloaded";
_proxy.SendNotification(title, message.Message, Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Notifications.MediaBrowser
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Radarr - Grabbed";
const string title = "Radarr - Movie Grabbed";
if (Settings.Notify)
{
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Notifications.MediaBrowser
public override void OnDownload(DownloadMessage message)
{
const string title = "Radarr - Downloaded";
const string title = "Radarr - Movie Downloaded";
if (Settings.Notify)
{
@ -41,6 +41,10 @@ namespace NzbDrone.Core.Notifications.MediaBrowser
}
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
if (Settings.UpdateLibrary)

@ -24,6 +24,7 @@ namespace NzbDrone.Core.Notifications
public abstract void OnGrab(GrabMessage grabMessage);
public abstract void OnDownload(DownloadMessage message);
public abstract void OnRename(Series series);
public abstract void OnMovieRename(Movie movie);
public virtual bool SupportsOnGrab => true;
public virtual bool SupportsOnDownload => true;

@ -15,7 +15,11 @@ namespace NzbDrone.Core.Notifications
public class NotificationService
: IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeDownloadedEvent>,
IHandle<SeriesRenamedEvent>
IHandle<SeriesRenamedEvent>,
IHandle<MovieRenamedEvent>,
IHandle<MovieGrabbedEvent>,
IHandle<MovieDownloadedEvent>
{
private readonly INotificationFactory _notificationFactory;
private readonly Logger _logger;
@ -67,6 +71,41 @@ namespace NzbDrone.Core.Notifications
qualityString);
}
private string GetMessage(Movie movie, QualityModel quality)
{
var qualityString = quality.Quality.ToString();
if (quality.Revision.Version > 1)
{
qualityString += " Proper";
}
return string.Format("{0}[{1}]",
movie.Title,
qualityString);
}
private bool ShouldHandleMovie(ProviderDefinition definition, Movie movie)
{
var notificationDefinition = (NotificationDefinition)definition;
if (notificationDefinition.Tags.Empty())
{
_logger.Debug("No tags set for this notification.");
return true;
}
if (notificationDefinition.Tags.Intersect(movie.Tags).Any())
{
_logger.Debug("Notification and series have one or more matching tags.");
return true;
}
//TODO: this message could be more clear
_logger.Debug("{0} does not have any tags that match {1}'s tags", notificationDefinition.Name, movie.Title);
return false;
}
private bool ShouldHandleSeries(ProviderDefinition definition, Series series)
{
var notificationDefinition = (NotificationDefinition) definition;
@ -112,6 +151,33 @@ namespace NzbDrone.Core.Notifications
}
}
public void Handle(MovieGrabbedEvent message)
{
var grabMessage = new GrabMessage
{
Message = GetMessage(message.Movie.Movie, message.Movie.ParsedMovieInfo.Quality),
Series = null,
Quality = message.Movie.ParsedMovieInfo.Quality,
Episode = null,
Movie = message.Movie.Movie,
RemoteMovie = message.Movie
};
foreach (var notification in _notificationFactory.OnGrabEnabled())
{
try
{
if (!ShouldHandleMovie(notification.Definition, message.Movie.Movie)) continue;
notification.OnGrab(grabMessage);
}
catch (Exception ex)
{
_logger.Error(ex, "Unable to send OnGrab notification to: " + notification.Definition.Name);
}
}
}
public void Handle(EpisodeDownloadedEvent message)
{
var downloadMessage = new DownloadMessage();
@ -141,6 +207,36 @@ namespace NzbDrone.Core.Notifications
}
}
public void Handle(MovieDownloadedEvent message)
{
var downloadMessage = new DownloadMessage();
downloadMessage.Message = GetMessage(message.Movie.Movie, message.Movie.ParsedMovieInfo.Quality);
downloadMessage.Series = null;
downloadMessage.EpisodeFile = null;
downloadMessage.Movie = message.Movie.Movie;
downloadMessage.OldMovieFiles = message.OldFiles;
downloadMessage.SourcePath = message.Movie.Path;
foreach (var notification in _notificationFactory.OnDownloadEnabled())
{
try
{
if (ShouldHandleMovie(notification.Definition, message.Movie.Movie))
{
if (downloadMessage.OldMovieFiles.Empty() || ((NotificationDefinition)notification.Definition).OnUpgrade)
{
notification.OnDownload(downloadMessage);
}
}
}
catch (Exception ex)
{
_logger.Warn(ex, "Unable to send OnDownload notification to: " + notification.Definition.Name);
}
}
}
public void Handle(SeriesRenamedEvent message)
{
foreach (var notification in _notificationFactory.OnRenameEnabled())
@ -159,5 +255,24 @@ namespace NzbDrone.Core.Notifications
}
}
}
public void Handle(MovieRenamedEvent message)
{
foreach (var notification in _notificationFactory.OnRenameEnabled())
{
try
{
if (ShouldHandleMovie(notification.Definition, message.Movie))
{
notification.OnMovieRename(message.Movie);
}
}
catch (Exception ex)
{
_logger.Warn(ex, "Unable to send OnRename notification to: " + notification.Definition.Name);
}
}
}
}
}

@ -19,18 +19,22 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Episode Grabbed";
const string title = "Movie Grabbed";
_proxy.SendNotification(title, grabMessage.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
const string title = "Movie Downloaded";
_proxy.SendNotification(title, message.Message, Settings.ApiKey, (NotifyMyAndroidPriority)Settings.Priority);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -28,6 +28,10 @@ namespace NzbDrone.Core.Notifications.Plex
_plexClientService.Notify(Settings, header, message.Message);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -35,6 +35,10 @@ namespace NzbDrone.Core.Notifications.Plex
Notify(Settings, header, message.Message);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{

@ -25,6 +25,10 @@ namespace NzbDrone.Core.Notifications.Plex
UpdateIfEnabled(message.Series);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
UpdateIfEnabled(series);

@ -19,18 +19,22 @@ namespace NzbDrone.Core.Notifications.Prowl
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Episode Grabbed";
const string title = "Movie Grabbed";
_prowlService.SendNotification(title, grabMessage.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
const string title = "Movie Downloaded";
_prowlService.SendNotification(title, message.Message, Settings.ApiKey, (NotificationPriority)Settings.Priority);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -18,18 +18,22 @@ namespace NzbDrone.Core.Notifications.PushBullet
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Radarr - Episode Grabbed";
const string title = "Radarr - Movie Grabbed";
_proxy.SendNotification(title, grabMessage.Message, Settings);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Radarr - Episode Downloaded";
const string title = "Radarr - Movie Downloaded";
_proxy.SendNotification(title, message.Message, Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -18,18 +18,22 @@ namespace NzbDrone.Core.Notifications.Pushalot
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Episode Grabbed";
const string title = "Movie Grabbed";
_proxy.SendNotification(title, grabMessage.Message, Settings);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
const string title = "Movie Downloaded";
_proxy.SendNotification(title, message.Message, Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -18,18 +18,22 @@ namespace NzbDrone.Core.Notifications.Pushover
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Episode Grabbed";
const string title = "Movie Grabbed";
_proxy.SendNotification(title, grabMessage.Message, Settings);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
const string title = "Movie Downloaded";
_proxy.SendNotification(title, message.Message, Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -69,6 +69,10 @@ namespace NzbDrone.Core.Notifications.Slack
NotifySlack(payload);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
var payload = new SlackPayload

@ -42,6 +42,10 @@ namespace NzbDrone.Core.Notifications.Synology
}
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
if (Settings.UpdateLibrary)

@ -18,18 +18,22 @@ namespace NzbDrone.Core.Notifications.Telegram
public override void OnGrab(GrabMessage grabMessage)
{
const string title = "Episode Grabbed";
const string title = "Movie Grabbed";
_proxy.SendNotification(title, grabMessage.Message, Settings);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
const string title = "Movie Downloaded";
_proxy.SendNotification(title, message.Message, Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -29,6 +29,10 @@ namespace NzbDrone.Core.Notifications.Twitter
_twitterService.SendNotification($"Imported: {message.Message}", Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
}

@ -27,6 +27,10 @@ namespace NzbDrone.Core.Notifications.Webhook
_service.OnDownload(message.Series, message.EpisodeFile, Settings);
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
_service.OnRename(series, Settings);

@ -36,6 +36,10 @@ namespace NzbDrone.Core.Notifications.Xbmc
UpdateAndClean(message.Series, message.OldFiles.Any());
}
public override void OnMovieRename(Movie movie)
{
}
public override void OnRename(Series series)
{
UpdateAndClean(series);

Loading…
Cancel
Save