I wish I had OSX. So I am confused.. I thought that script needed a -t for title.. how would it know it's a title without -t?
Per the usage info:
To be compatible with gNotify the following switch is accepted:
-t,--title Does nothing. Any text following will be treated as the
title because that's the default argument behaviour
So you can pass in the -t but it's not required and in fact it's just ignored. However, the reason it was causing a problem was because when you include the -t in the $extra_cmd variable and then pass that variable to the system call, it is actually encapsulating it with quotes so growl thinks the title is " -t Watching" when using the watching title as an example. You could still leave it in but not in the $extra_cmd. Instead, add it to the system call like this
To be compatible with gNotify the following switch is accepted:
-t,--title Does nothing. Any text following will be treated as the
title because that's the default argument behaviour
So you can pass in the -t but it's not required and in fact it's just ignored. However, the reason it was causing a problem was because when you include the -t in the $extra_cmd variable and then pass that variable to the system call, it is actually encapsulating it with quotes so growl thinks the title is " -t Watching" when using the watching title as an example. You could still leave it in but not in the $extra_cmd. Instead, add it to the system call like this
Development Branch Update. I have tested this a bit and it seems to work well ( at least for windows ). I am hoping this will work with any growl server including snarl since it utilizes GNTP.
As you will notice, the GNTP configuration in config.pl is a little different. It allows you to add as many destinations as you'd like. The config.pl-dist includes an example of using two destination servers.
New requirements for GNTP: Growl::GNTP
Centos/RHEL:
*CPAN install failed until I installed perl\(Data::UUID\)
yum install perl\(Data::UUID\)
cpan Growl::GNTP
Debian/Ubuntu and probably OSX
cpan Growl::GNTP
Last update for the night/morning... --recently_added=... allows comma separated list now. There is no need to run two cron jobs for movie,tv (however you still can - but you should not)
./plexWatch.pl --recently_added=movie,show
* any time you upgrade, please copy your plexWatch.db to a safe location for a backup.
installing Growl::GNTP via CPAN failed until i installed Crypt::CBC and Digest::SHA, after that it compiled without any issues, this is in CentOS 5.9 x86_64 mind you.
will be testing GNTP in a bit.
edit1: i can run the script "fine", currently refreshing my database with a couple more episodes to test if it works, i figured i'd try to use -test_notify=start (never used it before) and i got this error:
[root@WEBKSA01 plexWatch]# ./plexWatch.pl -test_notify=start -debug
format: {user} watching {title} [{year}] [{rating}] on {platform}
Use of uninitialized value in subroutine entry at ./plexWatch.pl line 733 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
Can't use string ("") as a subroutine ref while "strict refs" in use at
./plexWatch.pl line 733 (#2)
(F) Only hard references are allowed by "strict refs". Symbolic
references are disallowed. See perlref.
Uncaught exception from user code:
Can't use string ("") as a subroutine ref while "strict refs" in use at ./plexWatch.pl line 733.
at ./plexWatch.pl line 732
main::Notify('HASH(0xc15f0b0)') called at ./plexWatch.pl line 1705
main::RunTestNotify() called at ./plexWatch.pl line 155
[root@WEBKSA01 plexWatch]#
edit2: alright, database updated and i ran the script, it seems to be working just fine:
installing Growl::GNTP via CPAN failed until i installed Crypt::CBC and Digest::SHA, after that it compiled without any issues, this is in CentOS 5.9 x86_64 mind you.
will be testing GNTP in a bit.
edit1: i can run the script "fine", currently refreshing my database with a couple more episodes to test if it works, i figured i'd try to use -test_notify=start (never used it before) and i got this error:
[root@WEBKSA01 plexWatch]# ./plexWatch.pl -test_notify=start -debug
format: {user} watching {title} [{year}] [{rating}] on {platform}
Use of uninitialized value in subroutine entry at ./plexWatch.pl line 733 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl tells you what operation
you used the undefined value in. Note, however, that perl optimizes your
program and the operation displayed in the warning may not necessarily
appear literally in your program. For example, "that $foo" is
usually optimized into "that " . $foo, and the warning will refer to
the concatenation (.) operator, even though there is no . in your
program.
Can't use string ("") as a subroutine ref while "strict refs" in use at
./plexWatch.pl line 733 (#2)
(F) Only hard references are allowed by "strict refs". Symbolic
references are disallowed. See perlref.
Uncaught exception from user code:
Can't use string ("") as a subroutine ref while "strict refs" in use at ./plexWatch.pl line 733.
at ./plexWatch.pl line 732
main::Notify('HASH(0xc15f0b0)') called at ./plexWatch.pl line 1705
main::RunTestNotify() called at ./plexWatch.pl line 155
[root@WEBKSA01 plexWatch]#
edit2: alright, database updated and i ran the script, it seems to be working just fine:
1) CPAN seems to be hit and miss on Centos. I haven't bothered to look into why it fails to build dependencies (that's for another forum). I have always tried to keep all my installs through rpms, but that isn't always the easiest. Thanks for the update for Centos 5.9.
2) Sadly you ran into the one known issue I already have on my list, somewhere on my TODO list :) I broke --test_notify at some point when I consolidated the notify functions to make it easier to add new provider and edit existing one. I will be fixing that before this is release as final.
Thank you for testing it and including the images!
re: point 2, fair 'nuff, its typical for me to run into these kind of things ;)
out of curiosity, is there any chance any change you did today could be forcing pushover to ignore quiet hours?, i have it set up to not nag me between 12:00AM and 08:00AM and i just added a couple things to my library (12:41AM atm) and i got a few push notifications. i'm just asking since it could be an issue on pushover's side but i figured i'd mention it just in case.
re: point 2, fair 'nuff, its typical for me to run into these kind of things ;)
out of curiosity, is there any chance any change you did today could be forcing pushover to ignore quiet hours?, i have it set up to not nag me between 12:00AM and 08:00AM and i just added a couple things to my library (12:41AM atm) and i got a few push notifications. i'm just asking since it could be an issue on pushover's side but i figured i'd mention it just in case.
I did not change anything inside the actual notification sub routine for each provider. I only updated the code to call the routine for each provider instead of having duplicate code to call each routine.
well, whatever it was it fixed itself overnight, i had a bunch of notifications that did get trough silently.
Good deal. It seems it definitely is possible Pushover had some issue after reading their API a bit more. I don't send a priority with the message, so it defaults to 0, which will use your quiet time settings (should). A priority of 1 will ignore your settings for quiet time. A priority of 2 is just mean :) makes sense though for people on call. Interesting stuff over in their API docs: https://pushover.net/api#priority. I put it on the list to go through ALL the providers docs and extend them to allow *all* the allowed API calls. I will try not to overly complicate the config, but if someone would like to use an advanced or not normally used feature, they can.
I also fixed the '--test_notify=..' cli option last night. I plan to be pushing the DEV release final today.
yeah, i sent that post a few minutes after i shut down my desktop so i didn't check out much myself anyways.
i'll give the dev build a go when you throw that in.
i use the priority stuff for Nagios push notifications (that's how i used Pushover before finding this script) and i knew there was a way to bypass quiet hours, that's why i asked in the first place ;)
yeah, i sent that post a few minutes after i shut down my desktop so i didn't check out much myself anyways.
i'll give the dev build a go when you throw that in.
i use the priority stuff for Nagios push notifications (that's how i used Pushover before finding this script) and i knew there was a way to bypass quiet hours, that's why i asked in the first place ;)
SAD! you have to deal with Nagios too :) I recently switched over to using Prowl for all my Nagios events as the sms email gateway for ATT was becoming too unreliable (too many 452's). I liked prowl because I can set 5 different priorities all with the own setting for sound / vibrate / none, set quiet hours from within the app (and allow emergencies) or go completely offline with DND --- and it has a clear all button, my favorite!
SAD! you have to deal with Nagios too :) I recently switched over to using Prowl for all my Nagios events as the sms email gateway for ATT was becoming too unreliable (too many 452's). I liked prowl because I can set 5 different priorities all with the own setting for sound / vibrate / none, set quiet hours from within the app (and allow emergencies) or go completely offline with DND --- and it has a clear all button, my favorite!
look at twilio for SMS's, i have it working in ~15 countries and all in 20 or so lines of bash, their prices are excellent too :)
When I try to run /opt/plexWatch/plexWatch.pl I get th following error.
DBI connect('dbname=/opt/plexWatch//plexWatch.db','',...) failed: unable to open database file at /opt/plexWatch/plexWatch.pl line 904
Can't call method "prepare" on an undefined value at /opt/plexWatch/plexWatch.pl line 905
plexWatch.pl line 904,905 says:
my $dbh = DBI->connect("dbi:SQLite:dbname=$data_dir/plexWatch.db","","");
my $sth = $dbh->prepare("SELECT name FROM SQLITE_MASTER");
I followed the install steps and hasn't got any errors. But when I try to test if it works, it gives me this error.
Thx jasonlh, that made the trick! I used 777, don't know if there is another better combination to use.
I've another question. Why do I need to run a cron job every minute? I only want a log file and don't need to be pushed any notifications.
because you are running a script and not a standalone application. if you want it to log things then you still need to run the cronjob for it to keep an eye on PMS
Thx jasonlh, that made the trick! I used 777, don't know if there is another better combination to use.
I've another question. Why do I need to run a cron job every minute? I only want a log file and don't need to be pushed any notifications.
The script has to be run every minute to query the PLEX API to see if a user is watching or not watching a show. Depending on the outcome, it will insert this information into the plexWatch database.
Do note, the log file can be pretty messy and I suggest you use the cli to retrieve information. I do have it on the todo list to clean the log file a bit more and move any debug messages to a debug log file.
I seem to be having an issue related to the "--recently_added" command, which prevents Pushover alerting. I get this error every time I call it:
./plexWatch.pl -recently_added=show
Use of uninitialized value in division (/) at ./plexWatch.pl line 293.
However, if I run the same command with the -debug flag, the script alerts just fine.
P.S.
This is fantastic stuff. Far cry from my little python script. Great work!
It should still be sending the notification (I think) even with that error. Also, the recently added will only send a notification the first time. If it thinks the notification has been sent successfully, it will not send it again. When you add --debug, it should not send it again, but it should explain in stdout what it believes it has done :)
I have cleaned that error (and some others) in the dev version. I will push that shortly and you can see if the new version helps. I will update the thread when the new version is ready.