Do the notifications not also work for audio?
Playing music does not show up in the Now Playing area so it won't trigger a notification
Do the notifications not also work for audio?
Playing music does not show up in the Now Playing area so it won't trigger a notification
ljunkie,
I'm trying to come up with a way to query what episodes, shows & movies are most viewed or "popular" (today, this week, this month, all time) but I'm not sure it can be done. I thought there was a "views" field available in the PMS API but the few examples I used didn't have that field available. Any thoughts on how this could be done or what might need to be added to the script & db to allow this type of query?
ljunkie,
I'm trying to come up with a way to query what episodes, shows & movies are most viewed or "popular" (today, this week, this month, all time) but I'm not sure it can be done. I thought there was a "views" field available in the PMS API but the few examples I used didn't have that field available. Any thoughts on how this could be done or what might need to be added to the script & db to allow this type of query?
The only API I have found is mainly from browsing the XML, so sadly I don't have any good pointers there. I also believe you'd would have to login to myplex as each user to get a valid token to be able to query the viewstate as each user, so that would be a hassle and potentially not possible depending on password accessibility.
Could you not just use the plexWatch.db? You can use the session_id and start field for the info you would need. The session_id, example: 31_/library/metadata/87583_frank is {session_key}_{pms_item_key}_{user} and the start field is in epoch. From there you would query the API with the {pms_item_key} for any info you need about the video.
Let me know if I am missing something and can point you in another direction.
I'm trying to install this script on my synology nas, but are having some difficulties.
Ive created a thread in the synology subforum hoping to find someone who actually got this script working on the synology, and how.
Any help is greatly appreciated :)
http://forums.plexapp.com/index.php/topic/78853-plexwatch-with-synology/
Quick question, I am trying to find out if there is any account sharing going on with my users. Is the IP addresses logged anywhere with the session IDs?
Thanks,
Quick question, I am trying to find out if there is any account sharing going on with my users. Is the IP addresses logged anywhere with the session IDs?
Thanks,
This is really awesome, I got it all working about 3am last night. I have been asking for the ability to log user behavior for what seems like forever, so thanks for taking it upon yourself to provide this functionality. I am primarily interested in using the sql db stats. I do have what is probably a real stupid question. How can I take the date time stamp format (1377449041) and transpose it to a readable format?
Thanks!
This is really awesome, I got it all working about 3am last night. I have been asking for the ability to log user behavior for what seems like forever, so thanks for taking it upon yourself to provide this functionality. I am primarily interested in using the sql db stats. I do have what is probably a real stupid question. How can I take the date time stamp format (1377449041) and transpose it to a readable format?
Thanks!
I am glad to know it's working for you. Hopefully it all started working at 3am after not much work :)
The timestamp format I used is epoch (linux epoch). There are many different way to convert it depending on the language. Here is an example of converting it in a selected statement.
SQLite: http://www.sqlite.org/lang_datefunc.html
# Your timezone select datetime(time,'unixepoch','localtime') from processedUTC
select datetime(time,‘unixepoch’) from processed
perl quickie: (many other ways in perl)
perl -e 'print localtime(1377449041) . " "' Sun Aug 25 09:44:01 2013
To be honest I had more trouble setting up the crontab job than anything else. For whatever reason I could not get it to save the edits in vim. I ended up resorting to making a text file and forcing "crontab /private/var/cron/tabs/plexWatcher". Also, as far as the crontab string is concerned I used "* * * * * /opt/plexWatch/plexWatch.pl" omitting the root verbiage specified in the read me. Not sure what the difference is, but it did not work when i used "* * * * * root /opt/plexWatch/plexWatch.pl". I will be the first to admit that this is a bit above my pay grade so this may be an obvious realization. Everything else was easy between the ReadMe and the helpful forum posts.
For those looking to convert epoch in excel the formula is: =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number). For other time zones: =((A1 +/- time zone adjustment) / 86400) + 25569.
Let me know if there are any creative ways to get the IP address into the sql db.
i just found an error with the Recently Added notifications (at least i think it's a bug). I added a new movie to my library this morning at 9:12am PST and it triggered a growl and prowl notification. However, in the notification the time added was 12 hours off. The notification i got was: "Red 111min [1080p 6ch] [9:12P 26 Aug 13]". It thinks the time added was 9PM, not AM. Not a big deal but something to look into.
Also, i tried the --help, --?, -help, -? options but couldn't get the usage to print out. Did that break in the latest version?
i just found an error with the Recently Added notifications (at least i think it's a bug). I added a new movie to my library this morning at 9:12am PST and it triggered a growl and prowl notification. However, in the notification the time added was 12 hours off. The notification i got was: "Red 111min [1080p 6ch] [9:12P 26 Aug 13]". It thinks the time added was 9PM, not AM. Not a big deal but something to look into.
Also, i tried the --help, --?, -help, -? options but couldn't get the usage to print out. Did that break in the latest version?
What version are you running? Even though this code didn't change, it would be good to know
./plexWatch.pl --version Version: 0.0.18 ########################################## # Author: Rob Reed # Created: 2013-06-26 # Modified: 2013-08-16 13:04 PST # # Version: 0.0.18 # https://github.com/ljunkie/plexWatch ##########################################
The time is taken from the xml on returned from the PMS api. Specifically the "addedAt=" -- take a look at the raw xml by visiting your PMS @ something like
http://localhost:32400/library/recentlyAdded
or if you know your section #
http://localhost:32400/library/sections/5/recentlyAdded
I have also checked and --help seems to work just fine for me.
I'm running 0.0.18. I just did a fresh pull from GitHub just in case but for some reason can't the help usage to show up. Oh well.
As for the time, i see in the xml for the movie i added "addedAt="1377533556". I think i saw a thread with code to convert to standard date/time format. I'll see if i can find it and then translate the time. Maybe it's a bug in PMS?
I'm running 0.0.18. I just did a fresh pull from GitHub just in case but for some reason can't the help usage to show up. Oh well.
As for the time, i see in the xml for the movie i added "addedAt="1377533556". I think i saw a thread with code to convert to standard date/time format. I'll see if i can find it and then translate the time. Maybe it's a bug in PMS?
I checked and that epoch does convert to "9:12am 26 Aug 13" for me.
Try running the code below just to verify the Date it returns
./plexWatch.pl --recently_added=movie,show --debug
EDIT: nm. I see you expected 9PM, but the PMS believes it was added at 9AM from the epoch it returned
I checked and that epoch does convert to "9:12am 26 Aug 13" for me.
Try running the code below just to verify the Date it returns
./plexWatch.pl --recently_added=movie,show --debugEDIT: nm. I see you expected 9PM, but the PMS believes it was added at 9AM from the epoch it returned
Mon Aug 26 09:12:51 2013: GROWL Red [9:12P 26 Aug 13] [Already Notified] Mon Aug 26 09:12:51 2013: PROWL Red [9:12P 26 Aug 13] [Already Notified]
This is what i get. I expected AM but the notification says PM "[ 9:12P 26 Aug 13]". I'm assuming the "P" stands for PM. Is that correct?Mon Aug 26 09:12:51 2013: GROWL Red [9:12P 26 Aug 13] [Already Notified] Mon Aug 26 09:12:51 2013: PROWL Red [9:12P 26 Aug 13] [Already Notified]
I need my coffee I guess. It's odd the result is missing the M, so something is definitely off here.. doesn't seem like it would be timezone due to the fact it's 12 hours off. I'll do some more research in a bit. Can you PM me the XML from the recently added section?
EDIT: ok, were is the code where it converts them time:
my $date = (strftime "%I:%M%P %d %b %y", localtime($epoch));
I believe perl on your machine is not interpretting the %P for timezone and instead just putting a capital P for some reason. The time zone should be am/pm (lower case).
* try replacing %P with %p in the twittime/rrtime sub routines
I need my coffee I guess. It's odd the result is missing the M, so something is definitely off here.. doesn't seem like it would be timezone due to the fact it's 12 hours off. I'll do some more research in a bit. Can you PM me the XML from the recently added section?
EDIT: ok, were is the code where it converts them time:
my $date = (strftime "%I:%M%P %d %b %y", localtime($epoch));
I believe perl on your machine is not interpretting the %P for timezone and instead just putting a capital P for some reason. The time zone should be am/pm (lower case).* try replacing %P with %p in the twittime/rrtime sub routines
The lowercase p fixed it.
When i do "man strftime" i see that
%p is replaced by national representation of either "ante meridiem" (a.m.) or "post meridiem" (p.m.) as
appropriate.
The lowercase p fixed it.
When i do "man strftime" i see that
%p is replaced by national representation of either "ante meridiem" (a.m.) or "post meridiem" (p.m.) as appropriate.
Yep. It looks as though %P is GNU only, so it's not included in OSX or FreeBSD.. among others. I will change the code to use %p instead. Thanks for pointing this out.
would be nice to integrate such features in the next version of pms
To be honest I had more trouble setting up the crontab job than anything else. For whatever reason I could not get it to save the edits in vim. I ended up resorting to making a text file and forcing "crontab /private/var/cron/tabs/plexWatcher". Also, as far as the crontab string is concerned I used "* * * * * /opt/plexWatch/plexWatch.pl" omitting the root verbiage specified in the read me. Not sure what the difference is, but it did not work when i used "* * * * * root /opt/plexWatch/plexWatch.pl". I will be the first to admit that this is a bit above my pay grade so this may be an obvious realization. Everything else was easy between the ReadMe and the helpful forum posts.
For those looking to convert epoch in excel the formula is: =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number). For other time zones: =((A1 +/- time zone adjustment) / 86400) + 25569.
Let me know if there are any creative ways to get the IP address into the sql db.
I have a new branch that includes searching the logfile for the clients IP address and inserting it into the DB field ip_address (only on the initial insert). This will not work going backwards as logs are rotated like mad in PMS. For now it will iterate through the first log specified and if no match is found it will try the next log as it's possible the log was rotated by PMS.
You may need to change your $server_log location in the config.pl
plexWatch.pl: https://raw.github.com/ljunkie/plexWatch/dev/plexWatch.pl
config.pl-dist: https://raw.github.com/ljunkie/plexWatch/dev/config.pl-dist
EDIT: updated link. Merged into DEV
I love the friendly name feature but am wondering if you might suggest the best way to retroactively change a name in the plexWatch db/logs. (I should probably just familiarize myself with SQLite...)
Also, I want to get your thoughts on a couple of feature requests:
Would it be possible to get more information out of the --stats command, such as:
media listed by popularity (e.i. "Breaking Bad s5e11 - 5 watches")
time listed by highest PMS traffic (e.i. "Sun 8/25, 8PM - 4 watchers")
These two stats would give valuable information to what content on your PMS is the most popular and when your server is at the highest demand.
Finally, what would you think about being able to give a friendly name to a user + client which would amount to "location"? For example:
JohnSmith + Roku HD = "The Smith's"
JohnSmith + iOS = "John"
This would help differentiate between household clients and personal clients.
I'm not sure what the interest level would be in the above, but I think it would be a fantastic addition to the already amazing plexWatch script.
Thanks again!