diff --git a/README.md b/README.md index 2eba5bb..8200a55 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ plexWatch - 0.3.2 (2014-11-19) **Supported Push Notifications** * Email * https://pushover.net +* https://www.pushsafer.com * https://prowlapp.com * http://growl.info/ (via GrowlNotify @ http://growl.info/downloads#generaldownloads) * https://twitter.com/ (create a new app @ https://dev.twitter.com/apps) @@ -38,7 +39,7 @@ plexWatch - 0.3.2 (2014-11-19) * notify when a user pauses watching a video * notify when a user resumes watching a video * notify on recently added content to a PMS server -* notifies via email, prowl, pushover, growl, twitter, boxcar, pushbullet, GNTP and/or a log file +* notifies via email, prowl, pushover, pushsafer, growl, twitter, boxcar, pushbullet, GNTP and/or a log file * enable/disable notifications per provider & per notification type (start, stop, paush, resume, recently added) * backed by a SQLite DB (for state and history) * CLI to query watched videos, videos being watched and stats on time watched per user @@ -147,10 +148,11 @@ $debug_logging = 1; ## logs to $data_dir/debug.log ( only really helps debug IP ```bash $notify = {... - * to enable a provider, i.e. file, prowl, pushover + * to enable a provider, i.e. file, prowl, pushover, pushsafer set 'enabled' => 1, under selected provider * Prowl : 'apikey' required * Pushover : 'token' and 'user' required + * Pushsafer : 'privatekey' required * Growl : 'script' required :: GrowlNotify from http://growl.info/downloads (GNTP replaces this) * twitter : 'consumer_key', 'consumer_secret', 'access_token', 'access_token_secret' required * boxcar : 'email' required @@ -581,7 +583,7 @@ $backup_opts = { --debug hit and miss - not very useful OPTIONS - --notify This will send you a notification through prowl, pushover, boxcar, pushbullet, growl and/or twitter. It will also log the event to a file and to the database. This is the default if no + --notify This will send you a notification through prowl, pushover, pushsafer, boxcar, pushbullet, growl and/or twitter. It will also log the event to a file and to the database. This is the default if no options are given. --watched Print a list of watched content from all users. diff --git a/README.windows.md b/README.windows.md index 6432c54..15b9154 100644 --- a/README.windows.md +++ b/README.windows.md @@ -11,6 +11,7 @@ http://forums.plexapp.com/index.php/topic/72552-plexwatch-plex-notify-script-sen **Supported Push Notifications** * https://pushover.net +* https://www.pushsafer.com * https://prowlapp.com * http://growl.info/ (via GrowlNotify @ http://growl.info/downloads#generaldownloads) * https://twitter.com/ (create a new app @ https://dev.twitter.com/apps) @@ -21,7 +22,7 @@ http://forums.plexapp.com/index.php/topic/72552-plexwatch-plex-notify-script-sen * notify when a user starts watching a video * notify when a user stops watching a video * notify on recently added content to a PMS server -* notifies via prowl, pushover, growl, twitter, boxcar, GNTP and/or a log file +* notifies via prowl, pushover, pushsafer, growl, twitter, boxcar, GNTP and/or a log file * enable/disable notifications per provider & per notification type (watching, watched, recently added) * backed by a SQLite DB (for state and history) * CLI to query watched videos, videos being watched and stats on time watched per user @@ -117,10 +118,11 @@ $debug_logging = 1; ## logs to $data_dir/debug.log ( only really helps debug IP ```bash $notify = {... - * to enable a provider, i.e. file, prowl, pushover + * to enable a provider, i.e. file, prowl, pushover, pushsafer set 'enabled' => 1, under selected provider * Prowl : 'apikey' required * Pushover : 'token' and 'user' required + * Pushsafer : 'privatekey' required * Growl : 'script' required :: GrowlNotify from http://growl.info/downloads (GNTP replaces this) * twitter : 'consumer_key', 'consumer_secret', 'access_token', 'access_token_secret' required * boxcar : 'email' required @@ -512,7 +514,7 @@ $backup_opts = { --debug hit and miss - not very useful OPTIONS - --notify This will send you a notification through prowl, pushover, boxcar, growl and/or twitter. It will also log the event to a file and to the database. This is the default if no + --notify This will send you a notification through prowl, pushover, pushsafer, boxcar, growl and/or twitter. It will also log the event to a file and to the database. This is the default if no options are given. --watched Print a list of watched content from all users. diff --git a/config.pl-dist b/config.pl-dist index 52ed1b8..266e27f 100644 --- a/config.pl-dist +++ b/config.pl-dist @@ -75,6 +75,20 @@ $notify = { 'title' => '{user}', 'sound' => 'intermission', }, + + 'pushsafer' => { + 'enabled' => 0, ## set to 1 to enable Pushover + 'push_recentlyadded' => 0, + 'push_watched' => 0, + 'push_watching' => 0, + 'push_paused' => 0, + 'push_resumed' => 0, + 'privatekey' => 'Private or Alias Key', ## your Private or Alias Key + 'title' => '{user}', + 'device' => '', + 'sound' => '', + 'vibration' => '', + }, 'growl' => { 'enabled' => 0, ## set to 1 to enable local growl (You should probably used GNTP - growl supported for multiple platforms - below) diff --git a/config.pl-dist-win32 b/config.pl-dist-win32 index e382d5e..1047be4 100644 --- a/config.pl-dist-win32 +++ b/config.pl-dist-win32 @@ -75,6 +75,20 @@ $notify = { 'title' => '{user}', 'sound' => 'intermission', }, + + 'pushsafer' => { + 'enabled' => 0, ## set to 1 to enable Pushsafer + 'push_recentlyadded' => 0, + 'push_watched' => 0, + 'push_watching' => 0, + 'push_paused' => 0, + 'push_resumed' => 0, + 'privatekey' => 'Private or Alias Key', ## your Private or Alias Key + 'title' => '{user}', + 'device' => '', + 'sound' => '', + 'vibration' => '', + }, 'growl' => { 'enabled' => 0, ## set to 1 to enable local growl (You should probably used GNTP - growl supported for multiple platforms - below) diff --git a/plexWatch.pl b/plexWatch.pl index 5dbfd78..ab7e554 100755 --- a/plexWatch.pl +++ b/plexWatch.pl @@ -1784,6 +1784,7 @@ () { 'name' => 'GNTP', 'definition' => 'INTEGER',}, { 'name' => 'EMAIL', 'definition' => 'INTEGER',}, { 'name' => 'pushover', 'definition' => 'INTEGER',}, + { 'name' => 'pushsafer', 'definition' => 'INTEGER',}, { 'name' => 'pushbullet', 'definition' => 'INTEGER',}, { 'name' => 'pushalot', 'definition' => 'INTEGER',}, { 'name' => 'boxcar', 'definition' => 'INTEGER',}, @@ -2389,6 +2390,70 @@ () return 1; ## success } +sub NotifyPushsafer() { + my $provider = 'pushsafer'; + + #my $alert = shift; + my $info = shift; + my ($alert) = &formatAlert($info,$provider); + + my $alert_options = shift; + + if ($provider_452->{$provider}) { + if ($options{'debug'}) { print uc($provider) . " 452: backing off\n"; } + return 0; + } + + my %po = %{$notify->{pushsafer}}; + my $ua = LWP::UserAgent->new( ssl_opts => { + verify_hostname => 0, + SSL_verify_mode => SSL_VERIFY_NONE, + }); + $ua->timeout(20); + $po{'message'} = $alert; + + ## Pushsafer title is AppName by default. If there is a real title for push type, It's 'AppName: push_type' + + ## allow formatting of appname + $po{'title'} = '{user}' if $po{'title'} eq $appname; ## force {user} if people still use $appname in config -- forcing update with the need to modify config. + my $format = $po{'title'}; + + + if ($format =~ /\{.*\}/) { + my $regex = join "|", keys %{$alert_options}; + $regex = qr/$regex/; + $po{'title'} =~ s/{($regex)}/$alert_options->{$1}/g; + $po{'title'} =~ s/{\w+}//g; ## remove any {word} - templates that failed + $po{'title'} = $appname if !$po{'title'}; ## replace appname if empty + } + $po{'title'} .= ': ' . $push_type_titles->{$alert_options->{'push_type'}} if $alert_options->{'push_type'}; + $po{'title'} .= ' ' . ucfirst($alert_options->{'item_type'}) if $alert_options->{'item_type'}; + + my $response = $ua->post( "https://www.pushsafer.com/api", [ + "k" => $po{'privatekey'}, + "t" => $po{'title'}, + "m" => $po{'message'}, + 'd' => $po{'device'}, + 's' => $po{'sound'}, + 'v' => $po{'vibration'}, + ]); + my $content = $response->decoded_content(); + + + if ($content !~ /\"status\":1/) { + print STDERR "Failed to post Pushsafer notification -- $po{'message'} result:$content\n"; + $provider_452->{$provider} = 1; + my $msg452 = uc($provider) . " failed: $alert - setting $provider to back off additional notifications\n"; + &ConsoleLog($msg452,,1); + + return 0; + } + + my $dmsg = uc($provider) . " Notification successfully posted.\n" if $debug; + &DebugLog($dmsg) if $dmsg && $debug; + return 1; ## success +} + sub NotifyBoxcar() { my $provider = 'boxcar'; ## this will try to notifiy via box car @@ -3594,6 +3659,7 @@ () prowl => \&NotifyProwl, growl => \&NotifyGrowl, pushover => \&NotifyPushOver, + pushsafer => \&NotifyPushsafer, twitter => \&NotifyTwitter, boxcar => \&NotifyBoxcar, boxcar_v2 => \&NotifyBoxcar_V2, @@ -4350,7 +4416,7 @@ =head1 OPTIONS =item B<--notify> -This will send you a notification through prowl, pushover, boxcar, growl and/or twitter. It will also log the event to a file and to the database. +This will send you a notification through prowl, pushover, pushsafer, boxcar, growl and/or twitter. It will also log the event to a file and to the database. This is the default if no options are given. =item B<--watched> diff --git a/screenshots/iOS-plexWatch_pushsafer.png b/screenshots/iOS-plexWatch_pushsafer.png new file mode 100644 index 0000000..b83f8a3 Binary files /dev/null and b/screenshots/iOS-plexWatch_pushsafer.png differ