plexWatch - Plex Notify Script - Send Push Alerts On New Sessions and Stopped

How can i show special characters like umlauts (äöü) properly?

You can't. Added to my list for the next Dev verison

so lets say i just use pushover. what do i need to setup? just the pushover information thats it?

so lets say i just use pushover. what do i need to setup? just the pushover information thats it?

You leave the config.pl as is, do not remove anything from it. You will however need to fill in your pushover information in the $notification section.

I.E. it should look something like this ( you have to supply the toke and user fields values between the single quotes

  'pushover' => {
        'enabled' => 1, ## set to 1 to enable PushOver
        'push_recentlyadded'  => 1,
        'push_watched'        => 1,
        'push_watching'       => 1,
        'token' => 'FILL IN YOUR APP TOKE HERE', ## your app token
        'user' => 'FILL IN YOUR USER TOKEN HERE',  ## your user token
        'title' => $appname,
        'sound' => 'intermission',
    },

You leave the config.pl as is, do not remove anything from it. You will however need to fill in your pushover information in the $notification section.

I.E. it should look something like this ( you have to supply the toke and user fields values between the single quotes

  'pushover' => {
        'enabled' => 1, ## set to 1 to enable PushOver
        'push_recentlyadded'  => 1,
        'push_watched'        => 1,
        'push_watching'       => 1,
        'token' => 'FILL IN YOUR APP TOKE HERE', ## your app token
        'user' => 'FILL IN YOUR USER TOKEN HERE',  ## your user token
        'title' => $appname,
        'sound' => 'intermission',
    },

thank you so much for all your help. i am using pushover ipad i see where it give me a user key. and a username and password but, i dont an app token. 

thank you so much for all your help. i am using pushover ipad i see where it give me a user key. and a username and password but, i dont an app token. 

You have to login to https://pushover.net/ and create an application

Type: script

The rest you should be able to leave blank or fill out however you'd like ( including the icon )

Ok. i feel so dumb. I am so sorry. I setup the pushover information and the myplex user and password. when i check in command it says config file missing data. also once its working how do you schedule a task every minute?....... just to try and understand is windows basically running the program every minute and then the program sends the info out?

ok i got iit. the install instructions would be better if you said to rename the .pl file instead of copy to. I thought i was making a folder called config.pl and placing the file in it lol.... soon as i figure out how to schedual a task i will test it out. donate and let you know of bugs. Thanks so much for your hard work.

chris

ok i got it now it says daily weekly monthly backup not found -----trying now. the install instructions would be better if you said to rename the .pl file instead of copy to. I thought i was making a folder called config.pl and placing the file in it lol.

Yea, I bet a lot of the instructions could be written better, but I don't really have the time to go over those fine details. I am more than happy to update things if someone tells me exactly what to change. I would actually prefer people copy the file instead of move/rename it so you have a quick and easy resource to go back to.

The daily,weekly,monthly backup will not be found on the first run - however it should have created them and it won't complain about it again.

This program needs to be ran every minute to query the PMS on what's happening since the PMS doesn't actually log any of this data ( at least they don't have any info on it doing that yet ). Basically what it's doing is querying the PMS for the 'now watching' section of your PMS. If a video is playing, it will insert that into the plexWatch DB and then notify you on the start if you have notifications enable. Every minute it will do the same query and update the status of the now playing state in the DB. When if queries the now playing section and a video it knew was playing previously is no longer playing, it will update the DB once again and send you another notification. There is of course a lot more to it.. but that is mainly what it's doing every minute. 

I hope this makes sense... I have been up for way to long :) 

Yea, I bet a lot of the instructions could be written better, but I don't really have the time to go over those fine details. I am more than happy to update things if someone tells me exactly what to change. I would actually prefer people copy the file instead of move/rename it so you have a quick and easy resource to go back to.

The daily,weekly,monthly backup will not be found on the first run - however it should have created them and it won't complain about it again.

This program needs to be ran every minute to query the PMS on what's happening since the PMS doesn't actually log any of this data ( at least they don't have any info on it doing that yet ). Basically what it's doing is querying the PMS for the 'now watching' section of your PMS. If a video is playing, it will insert that into the plexWatch DB and then notify you on the start if you have notifications enable. Every minute it will do the same query and update the status of the now playing state in the DB. When if queries the now playing section and a video it knew was playing previously is no longer playing, it will update the DB once again and send you another notification. There is of course a lot more to it.. but that is mainly what it's doing every minute. 

I hope this makes sense... I have been up for way to long :)

when i figure it out i will write out detailed instructions and send it to you then you can go over it.

amazing job

Great work. An unfortunate limitation to the Now Playing implementation seems to really mess with stats. Often if someone has a video paused or even sometimes if it ends but they stay on the same page in plex web, it still shows them as viewing. So you sometimes see someone viewing a 30 minute show for 7 hours. Is there any way to filter this out?  I'm assuming its a no. 

Great work. An unfortunate limitation to the Now Playing implementation seems to really mess with stats. Often if someone has a video paused or even sometimes if it ends but they stay on the same page in plex web, it still shows them as viewing. So you sometimes see someone viewing a 30 minute show for 7 hours. Is there any way to filter this out?  I'm assuming its a no. 

It's something I already know about. I know they are paused/playing and I take that into account when given the percentage watched. It still does show they watched something for 7 hours.. technically they did watch it for 7 hours, they may have just paused it for 6 :) It's on the list though and I will probably add some sort of toggle to either show either way. With that said, I don't think I will be able to show the 'real' watched time for previous data.. not sure though. 

Edit: A couple things I could  do

* I have the correct percentage watched. I can just use percentage_watched*length for the actually watched time, although this would not be completely accurate for two reasons:

  Example Video: 100 minutes length

   1) someone could watched 50 minutes (50%), rewind to 10min (now 10%)  -- it would only show wathced for 10 minutes -- so that is wrong

   2) they resumed a video at 25 minutes, stopped at 50 minutes -- it would show watched for 50 minutes.. 

   3) I am sure there are more things off with this... 

 see the fun I have to work with. So again, it's on the list :) I really just need to take into account when a video is paused (which I do, but I may not be logging enough data to work with)

I have something in the works for correcting the watched duration when someone pauses/resumes a video ( will only work going forwards ). It will also allow one to enable a notification when the content is paused/resumed. I’ll probably have something tomorrow or this weekend. I just want to test it a bit before I release it.

Previous entries can be “fixed”, but you’d have to update the DB manually.

I have something in the works for correcting the watched duration when someone pauses/resumes a video ( will only work going forwards ). It will also allow one to enable a notification when the content is paused/resumed. I'll probably have something tomorrow or this weekend. I just want to test it a bit before I release it.

Previous entries can be "fixed", but you'd have to update the DB manually.


Amazing, thanks.

I have something in the works for correcting the watched duration when someone pauses/resumes a video ( will only work going forwards ). It will also allow one to enable a notification when the content is paused/resumed. I'll probably have something tomorrow or this weekend. I just want to test it a bit before I release it. Previous entries can be "fixed", but you'd have to update the DB manually.


It works how I expect it to. I've been meaning to get state changes (pause:resume) into this - it's a nice feature. With that said I was ready to release it, however I completely spaced again on an email notification (provider)! I know... however I have that working too now :) The only thing I need to do is add some error checking into the email provider and this is ready to go. Stay tuned.

0.0.20 DEV is ready for testing

https://github.com/ljunkie/plexWatch/tree/dev

Screenshots: iOS Boxcar // iOS Prowl // iOS Pushover // Win7 Growl

I will post more details later, but I wanted to give everyone early access. Make sure you look at the new config.pl-dist ( old config.pl will work, but you will probably want to update the two things I list below )

Things to update in your config.pl 

1) $alert_format -- I would use these ongoing and change them as your see fit. Mainly removing "{user} watched|watching|etc" from the beginning - The title is dynamically corrected now to to fix redundancy  

$alert_format = {'start'    =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} [{progress} in] {ip_address}',
                 'paused'   =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} [{progress} in] [{percent_complete}%] {ip_address}',
                 'resumed'  =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} [{progress} in] [{percent_complete}%] {ip_address}',
                 'stop'     =>  '{title} [{streamtype}] [{year}] [{rating}] on {platform} for {duration} [{percent_complete}%] {ip_address}',
                 'watched'  =>  '{user} watched {title} [{streamtype}] [{year}] [{length}] [{rating}] on {platform} for {duration} [{percent_complete}%] {ip_address}',
                 'watching' =>  '{user} {state} {title} [{streamtype}] [{year}] [{rating}] [{length}] on {platform} for {duration} [{percent_complete}%] [{time_left} left] {ip_address}'
};

2) $notify  -- added new new push options to every provider ( except file of course )

        'push_paused'         => 1,
        'push_resumed'        => 1,

Change Log  0.0.20

 
 * NEW: Email provider ( NonAuth, Auth, TLS/SSL supported) requires Net::SMTP::TLS
         centos: yum install perl\(Net::SMTP::TLS\)
         debian: apt-get install libnet-smtp-tls-perl
         other: cpan install MIME::Lite
 * NEW: paused/resumed state and time are now accounted for
 * NEW: paused/resumed push types enabled - push_paused, pushed_resumed added to each provider
 * NEW: you can override 'alert_format' per provider ( check out the EMAIL provider for an example )
 * FIX: watched duration corrected going forward (accounts for paused content and can be overridden with $count_paused )
         paused/resumed states have allowed this to work
 * FIX: Redundant titles are now fixed         - Title/Application also will always show {user} unless overridden in config.pl
         $appname is no longer used and replaced with {user} -- {user} if used even if config.pl has $appname ( no need to update config.pl )
         before:  title: "plexWatch watched" msg: "user watched title etc...."
          after:  title: "{user} watched"    msg: "title etc...."
 * FIX: --test_notify will not print options to test ( and they actually correspond to the right notification type now!)
 * FIX: do not print backup info every time --debug is called
 * Screenshots added to screenshots folder for iOS and Windows

Nice additions ljunkie. I'm running into one issue with email when testing. I receive emails using a Gmail account with Auth & TLS @ port 587 but if I test using a local SMTP server which is open having no auth and no TLS/SSL on port 25 I receive the following error in the debug log:

 EMAIL error: Invalid response for STARTTLS: 503 command out of sequence -- use RSET to resynchronise, at ./plexWatch.pl line 2150

Nice additions ljunkie. I'm running into one issue with email when testing. I receive emails using a Gmail account with Auth & TLS @ port 587 but if I test using a local SMTP server which is open having no auth and no TLS/SSL on port 25 I receive the following error in the debug log:

 EMAIL error: Invalid response for STARTTLS: 503 command out of sequence -- use RSET to resynchronise, at ./plexWatch.pl line 2150




Noted. I’ll check it out tomorrow. I just realized my server allows STARTTLS on both ports so I didn’t run into that issue. I’ll work on adding non TLS options soon.

Nice additions ljunkie. I'm running into one issue with email when testing. I receive emails using a Gmail account with Auth & TLS @ port 587 but if I test using a local SMTP server which is open having no auth and no TLS/SSL on port 25 I receive the following error in the debug log:

 EMAIL error: Invalid response for STARTTLS: 503 command out of sequence -- use RSET to resynchronise, at ./plexWatch.pl line 2150

Try a new copy of plexWatch.pl (tls is off by default now)

* one can enable/disable TLS by changing a variable in the config.pl EMAIL $notify section

# TLS Disabled
'enable_tls' => 0, 

TLS Enabled

‘enable_tls’ => 1,

Try a new copy of plexWatch.pl (tls is off by default now)

* one can enable/disable TLS by changing a variable in the config.pl EMAIL $notify section

# TLS Disabled
'enable_tls' => 0, 

TLS Enabled

‘enable_tls’ => 1,

Excellent, that fixed it. Thanks!