Jump to content


Photo

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


  • Please log in to reply
852 replies to this topic

#1 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 27 June 2013 - 06:35 AM

plexWatch (v0.2.8): Notify and Log 'Now Playing'+'Watched' content on a Plex Media Server + Recently Added content

 
 
Requirements:
* PMS 0.9.8.x +
* PlexPass subscription ( everything but recently added content )
* PMS logs ( with debug enabled ) if you want IP logging
* Clients that support Now Playing  i.e. user must show up in now playing on plex/Web
                                                       note: PMC does not work - use PHT, ATV2 native app does not work
* Recently added notifications will work with any current version (non PlexPass ok)
 

Supported Push Notifications

What it does

  • 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
  • notifications per provider enabled/disabled 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
  • Limit output per user or exclude users
  • MyPlex login: script can run from any computer ( not only the PMS )
  • Automatic SQLite backups. ( Daily,Weekly, Monthly )
  • logs IP address of client device streaming
  • ...more to come

Other things...

 

  • SSL Support for PMS (port 32443) 
  • FriendlyName for users ( converts myplex username into a user specified name - can also be separated per device)

Edited by ljunkie, 09 March 2014 - 12:57 AM.

plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#2 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 28 June 2013 - 07:57 PM

Push a new version of the script.  https://github.com/ljunkie/plexWatch

 

changelog: https://raw.github.c...ster/change.log
readme: https://github.com/l...aster/README.md

 

Many code changes, however the new features are:
 
* Get a list of watched shows from the cli.
* List all watched show (default) or limit the output by date ranges and 'fuzzy' time like today, 1 week ago, etc..

How To:

* list all watched shows - no limit

/opt/git/plexWatch/plexWatch.pl --watched

======================================== Watched ========================================
Date Range: Anytime through Now

User: jimbo
Wed Jun 26 15:56:09 2013: jimbo watched: South Park - A Nightmare on FaceTime [duration: 22 minutes, and 15 seconds]
Wed Jun 26 20:18:34 2013: jimbo watched: The Following - Whips and Regret [duration: 46 minutes, and 45 seconds]
Wed Jun 26 20:55:02 2013: jimbo watched: The Following - The Curse [duration: 46 minutes, and 15 seconds]

User: carrie
Wed Jun 24 08:55:02 2013: carrie watched: The Following - The Curse [duration: 46 minutes, and 25 seconds]
Wed Jun 26 20:19:48 2013: carrie watched: Dumb and Dumber [1994] [PG-13] [duration: 1 hour, 7 minutes, and 10 seconds]

 
* list watched shows - limit by TODAY only

/opt/git/plexWatch/plexWatch.pl --watched --start=today --start=tomorrow

======================================== Watched ========================================
Date Range: Fri Jun 28 00:00:00 2013 through Sat Jun 29 00:00:00 2013

User: jimbo
Fri Jun 28 09:18:22 2013: jimbo watched: Married ... with Children - Mr. Empty Pants [duration: 1 hour, 23 minutes, and 20 seconds]
 

 
* list watched shows - limit by a start and stop date

/opt/git/plexWatch/plexWatch.pl --watched --start="2 days ago" --stop="1 day ago"

======================================== Watched ========================================
Date Range: Fri Jun 26 00:00:00 2013 through Thu Jun 27 00:00:00 2013

User: Jimbo
Wed Jun 26 15:56:09 2013: rarflix watched: South Park - A Nightmare on FaceTime [duration: 22 minutes, and 15 seconds]
Wed Jun 26 20:18:34 2013: rarflix watched: The Following - Whips and Regret [duration: 46 minutes, and 45 seconds]
Wed Jun 26 20:55:02 2013: rarflix watched: The Following - The Curse [duration: 46 minutes, and 15 seconds]

User: Carrie
Wed Jun 26 20:19:48 2013: Carrie watched: Dumb and Dumber [1994] [PG-13] [duration: 1 hour, 7 minutes, and 10 seconds]

plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#3 war59312

war59312

    Member

  • Members
  • PipPip
  • 28 posts
  • Location: U.S.A

Posted 29 June 2013 - 09:06 AM

Your Readme needs an update, your Install instructions are bad.
 
Wrong folder path and file name.
 
Should be:
Install:

1) sudo wget -P /opt/plexWatch/ https://raw.github.com/ljunkie/plexWatch/master/plexWatch.pl

2) sudo chmod 755 /opt/plexWatch/plexWatch.pl

3) sudo nano /opt/plexWatch/plexWatch.pl 
And you really ought to notify the user of the commands to install the Perl requirements.
sudo apt-get install libwww-curl-perl

sudo apt-get install libxml-simple-perl

sudo apt-get install libtime-duration-perl

sudo apt-get install libtime-modules-perl    
Install SQLite via:
sudo perl -MCPAN -e shell

install DBD::SQLite

Then it works just fine.

 

Whoops, another Perl requirement:

sudo /opt/plexWatch/plexWatch.pl --help

You need to install the perl-doc package to use this program.  
So install it via:
sudo apt-get install perl-doc

 



#4 nhagyavi

nhagyavi

    Member

  • Members
  • PipPip
  • 77 posts
  • Location: Sweden

Posted 29 June 2013 - 10:30 AM

Very nice! But how can I use it on my Android device?



#5 bauerknight

bauerknight

    Dedicated Member

  • Members
  • PipPipPip
  • 117 posts

Posted 29 June 2013 - 06:41 PM

Im getting this error:

 

DBD::SQLite::db do failed: attempt to write a readonly database at /opt/plexWatch/plexWatch.pl line 571.
 
======================================== Watched ========================================
Date Range: Anytime through Now
 
* nothing watched
 
 
i chmod the folder to no avail.  Thanks in advance


#6 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 29 June 2013 - 07:23 PM

Your Readme needs an update, your Install instructions are bad.
 
Thank you for finding the issue and supplying the fix!
 
* I have pushed those changes
* I have also included instructions for RHEL/Centos (yum)
* apt-get also has libdbd-sqlite3-perl ( instead of the cpan install ) -- seems to work for me on my ubuntu box
 
I am surprised the perl-doc is not include in ubuntus base, but thanks again!

plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#7 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 29 June 2013 - 07:31 PM

Very nice! But how can I use it on my Android device?

 

I am limited on time right now or I would supply a more detailed answer. I will note that I should included instructions how to use on an android/ios device. If anyone uses this and wants to supply that, it would be much appreciated :)

 

Ugh, I just realized that prowl doesn't have an android app (it's what I use). I did includ pushover (pushover.net) as an option for notifications, but I have not been able to test it yet, as I haven't purchased the $4.99 app (since I used prowl). I will see if I can get pushover tested soon, or please report back to let me know if you have pushover working!

 

Are there any other push notification services like prowl or pushover I am missing? I am definitely not opposed to adding in my notification options.


plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#8 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 29 June 2013 - 07:37 PM

Im getting this error:

 

DBD::SQLite::db do failed: attempt to write a readonly database at /opt/plexWatch/plexWatch.pl line 571.
 
======================================== Watched ========================================
Date Range: Anytime through Now
 
* nothing watched
 
 
i chmod the folder to no avail.  Thanks in advance

 

Please refer to steps #5 and #6 @ https://github.com/l...aster/README.md

 

 

* it will not have anything logged as watched until the script logs something being watched. In turn it will not be marked as watched until you stop the video and the script runs once again. I have not run into the 'realonly' db error yet, so please let me know what your results are with steps #5.

 

Also note: this will have to be run on the PMS server if you have set the LAN to require authentication. The script has to access the PMS server as localhost


plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#9 bauerknight

bauerknight

    Dedicated Member

  • Members
  • PipPipPip
  • 117 posts

Posted 29 June 2013 - 07:40 PM

Please refer to steps #5 and #6 @ https://github.com/l...aster/README.md

 

 

* it will not have anything logged as watched until the script logs something being watched. In turn it will not be marked as watched until you stop the video and the script runs once again. I have not run into the 'realonly' db error yet, so please let me know what your results are with steps #5.

 

Also note: this will have to be run on the PMS server if you have set the LAN to require authentication. The script has to access the PMS server as localhost

 

Hi i got past this error.

 

A new issue is that  I've set up the pushover account and the notifications just says "hello world" for every notification entry from plexwatch.



#10 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 29 June 2013 - 07:42 PM

Hi i got past this error.

 

A new issue is that  I've set up the pushover account and the notifications just says "hello world" for every notification entry from plexwatch.

 

Yep. I fixed that error upstream - only happens the first time. It was trying to update something that wouldn't have existed on a 'new' install.

 

I am looking into the pushover notification now. I need to buckle down and purchase the $4.99 app. I am in the process of moving today, so hopefully I can quickly fix this, but I only have about 10 minutes right now. :) I'll keep you posted


plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#11 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 29 June 2013 - 07:52 PM

Hi i got past this error.

 

A new issue is that  I've set up the pushover account and the notifications just says "hello world" for every notification entry from plexwatch.

 

 

Yep. I fixed that error upstream - only happens the first time. It was trying to update something that wouldn't have existed on a 'new' install.

 

I am looking into the pushover notification now. I need to buckle down and purchase the $4.99 app. I am in the process of moving today, so hopefully I can quickly fix this, but I only have about 10 minutes right now. :) I'll keep you posted

 

ok, I believe I fixed the message, you will have to download a new copy of the perl script

 

sudo cp /opt/plexWatch/plexWatch.pl /opt/plexWatch/plexWatch.pl.bak

sudo wget -P /opt/plexWatch/ https://raw.github.com/ljunkie/plexWatch/master/plexWatch.pl

sudo nano /opt/plexWatch/plexWatch.pl  -- edit the notification section and add in your credentials again (in backup file for ease )

 

and follow step #5 @ https://github.com/l...aster/README.md

 

I hope it works. The prowl app sends much more info, like episode number, summary, etc.. that I have excluded until I test the pushover notification myself to verify they are not too verbose.


plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#12 war59312

war59312

    Member

  • Members
  • PipPip
  • 28 posts
  • Location: U.S.A

Posted 29 June 2013 - 11:01 PM

 
Thank you for finding the issue and supplying the fix!
 
* I have pushed those changes
* I have also included instructions for RHEL/Centos (yum)
* apt-get also has libdbd-sqlite3-perl ( instead of the cpan install ) -- seems to work for me on my ubuntu box
 
I am surprised the perl-doc is not include in ubuntus base, but thanks again!

 

Nicely done. :)



#13 bauerknight

bauerknight

    Dedicated Member

  • Members
  • PipPipPip
  • 117 posts

Posted 29 June 2013 - 11:15 PM

ok, I believe I fixed the message, you will have to download a new copy of the perl script

 

sudo cp /opt/plexWatch/plexWatch.pl /opt/plexWatch/plexWatch.pl.bak

sudo wget -P /opt/plexWatch/ https://raw.github.com/ljunkie/plexWatch/master/plexWatch.pl

sudo nano /opt/plexWatch/plexWatch.pl  -- edit the notification section and add in your credentials again (in backup file for ease )

 

and follow step #5 @ https://github.com/l...aster/README.md

 

I hope it works. The prowl app sends much more info, like episode number, summary, etc.. that I have excluded until I test the pushover notification myself to verify they are not too verbose.

 

 

I appreciate your hard work and It's now working with Pushover.  Next issue I've notice is that there's multiple notifications of someone 'stop watching' a video.  I've disabled stop watching notifications for now.

 

Also can you add the "platform" to the pushover notifications? I.E. User is watching: video name on Roku.

 

Thanks again



#14 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 30 June 2013 - 12:16 AM

I appreciate your hard work and It's now working with Pushover.  Next issue I've notice is that there's multiple notifications of someone 'stop watching' a video.  I've disabled stop watching notifications for now.
 
Also can you add the "platform" to the pushover notifications? I.E. User is watching: video name on Roku.
 
Thanks again


Added the platform upstream, please test an let me know! I am also not sure how dupes could happen, but anything is possible. I'll look into it. I might need to enable more debug logging so these things are easier to troubleshoot for others.
plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#15 bauerknight

bauerknight

    Dedicated Member

  • Members
  • PipPipPip
  • 117 posts

Posted 30 June 2013 - 12:49 AM

Added the platform upstream, please test an let me know! I am also not sure how dupes could happen, but anything is possible. I'll look into it. I might need to enable more debug logging so these things are easier to troubleshoot for others.

 

Platform info works great! thank you so much.



#16 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 01 July 2013 - 12:38 AM

Version 0.0.8 released

 

 * file locking was broken - multiple copies could run at the same time 

 * failed attempts to retrieve XML status could result in false stopped notifications and dupes
 * timeout was way too long any possibly indefinite for sessions status. now 20 seconds.
 
 This might fix the dupe stopped notifications. Will hopefully verify this after the new version has been tested for a while. 

plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#17 war59312

war59312

    Member

  • Members
  • PipPip
  • 28 posts
  • Location: U.S.A

Posted 01 July 2013 - 02:12 AM

By the way, any chance of adding support for BoxCar?

 

See: http://boxcar.io/help/api/providers



#18 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 01 July 2013 - 03:05 AM

By the way, any chance of adding support for BoxCar?
 
See: http://boxcar.io/help/api/providers


Added to my list. I also plan on email support. Any others?
plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto

#19 bauerknight

bauerknight

    Dedicated Member

  • Members
  • PipPipPip
  • 117 posts

Posted 01 July 2013 - 03:49 PM

Version 0.0.8 released

 

 * file locking was broken - multiple copies could run at the same time 

 * failed attempts to retrieve XML status could result in false stopped notifications and dupes
 * timeout was way too long any possibly indefinite for sessions status. now 20 seconds.
 
 This might fix the dupe stopped notifications. Will hopefully verify this after the new version has been tested for a while. 

 

It looks like this fixed my duplicated stopped notifications.  Thank you.



#20 ljunkie

ljunkie

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2021 posts
  • Location: Washington

Posted 01 July 2013 - 10:29 PM

Version 0.0.9 released

 

 * cli option '-watched' updated 

 * '-watched' will now show the accumulated duration (if a video has been started/stopped multiple time on the same day)
 * '-nogrouping' added as an option to '-watched'. It will show the same video multiple times if it has been started/stopped on the same day)
 
* without --nogrouping [default]

 

Sun Jun 30 15:12:01 2013: exampleUser watched: Your Highness [2011] [R] [duration: 1 hour, 56 minutes, and 53 seconds]
Sun Jun 30 15:46:02 2013: exampleUser watched: Star Trek [2009] [PG-13] [duration: 2 hours, 8 minutes, and 18 seconds]  

 

 * with --nogrouping

 

 Sun Jun 30 15:12:01 2013: exampleUser watched: Your Highness [2011] [R] [duration: 27 minutes and 54 seconds]
 Sun Jun 30 15:41:02 2013: exampleUser watched: Your Highness [2011] [R] [duration: 4 minutes and 59 seconds]
 Sun Jun 30 15:46:02 2013: exampleUser watched: Star Trek [2009] [PG-13] [duration: 24 minutes and 17 seconds]
 Sun Jun 30 17:48:01 2013: exampleUser watched: Star Trek [2009] [PG-13] [duration: 1 hour, 44 minutes, and 1 second]
 Sun Jun 30 19:45:01 2013: exampleUser watched: Your Highness [2011] [R] [duration: 1 hour and 24 minutes]
 

I still have boxcar and email notifications on my list


plexWatch (v0.2.8): GitHub :: plexForums: linux/osx/other :: windows

RARflix (v3.2.4) plex/Roku: rarflix.com :: help forum :: wishlist :: rarflix tools

Donations Welcome! roku logs howto




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users