How to Install plexWatch on Ubuntu (14.04+ Trusty Tahr)
This guide will show you how to install and configure plex watch, Plex watch will Notify and Log ‘Now Playing’ and ‘Watched’ content from a Plex Media Server + ‘Recently Added’ (…and more)
What it does
- notify when a user starts watching a video
- notify when a user stops watching a video
- 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
- 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
- Limit output per user or exclude users
Perl Requirements
- LWP::UserAgent
- XML::Simple
- DBI
- Time::Duration;
- Time::ParseDate;
- JSON
Install
Download plexWatch.pl and config.pl-dist to /opt/plexWatch/
- WGET
sudo wget -P /opt/plexWatch/ https://raw.github.com/ljunkie/plexWatch/master/plexWatch.pl
sudo wget -P /opt/plexWatch/ https://raw.github.com/ljunkie/plexWatch/master/config.pl-dist
- CURL
sudo mkdir -p /opt/plexWatch/
sudo curl https://raw.github.com/ljunkie/plexWatch/master/plexWatch.pl -o /opt/plexWatch/plexWatch.pl
sudo curl https://raw.github.com/ljunkie/plexWatch/master/config.pl-dist -o /opt/plexWatch/config.pl-dist
Now lets change the Permission of the files
sudo chmod 777 /opt/plexWatch && sudo chmod 755 /opt/plexWatch/plexWatch.pl
sudo cp /opt/plexWatch/config.pl-dist /opt/plexWatch/config.pl
Lets edit the PlexWatch configuration file
sudo nano /opt/plexWatch/config.pl
$server = 'localhost'; ## IP of PMS - or localhost $port = 32400; ## port of PMS $notify_started = 1; ## notify when a stream is started (first play) $notify_stopped = 1; ## notify when a stream is stopped
$notify = {... * to enable a provider, i.e. file, prowl, pushover set 'enabled' => 1, under selected provider * Prowl : 'apikey' required * Pushover : 'token' and 'user' 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 * pushover : 'apikey' and 'device' required * GNTP : 'server', 'port' required. 'password' optional. You must allow network notifications on the Growl Server
Now lets install some of the perl requirements
sudo apt-get install libwww-perl libxml-simple-perl libtime-duration-perl libtime-modules-perl libdbd-sqlite3-perl perl-doc libjson-perl
run the script manually to verify it works: /opt/plexWatch/plexWatch.pl
- start video(s)
/opt/plexWatch/plexWatch.pl
- stop video(s)
/opt/plexWatch/plexWatch.pl
setup crontab to run the script every minute
sudo nano /etc/crontab
lets add
* * * * * YOUR_USERNAME /opt/plexWatch/plexWatch.pl
Now its setup and ready to go, now lets add some notifications
Supported Push Notifications
- https://pushover.net
- 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)
- https://boxcar.io/ & boxcar V2
- https://pushbullet.com
- SNARL/GROWL: GNTP notifications supported. Anything that uses GNTP should work
- External Scripts: home automation, pause download clients, etc (rudimentary plugins)
Twitter setup
- create a new app @ https://dev.twitter.com/apps
- click “Create New App”
- Name: unique name for for your app
- Description: fill something in…
- Website: you need some valid website..
- (read) and accept terms
- click “Create you Twitter Application”
- click “Modify app permission” under the Details Tab
- change to Read and Write
- update settings
- click the “API keys” tab
- click “create my access token”
- click “Test OAuth” button to view the required API keys need for config.pl
- Edit the config.pl
- enable notification for twitter in config.pl
- enter in the required keys, secrets and tokens