plexWatch/Web - A web front-end for plexWatch

I installed this on my windows machine, and PlexWatchWeb seems to basically work as advertised now. Thanks!

I did find a bit of an issue with PlexWatch or PlexWatchWeb (my thinking is maybe plexWatch should handle this issue, but what do I know? lol...). I added a few videos today to a section, and then decided to move them to a different PMS section, obviously deleting them from the initial section. This caused all kinds of errors on the plexWatchWeb Home page where it displays new content. Basically the errors were stating they couldn't find the metadata for the shows, which is correct, because those shows don't exist anymore. Just thought I'd mention it.

Here's the errors received from plexWatchWeb...

Glad to hear you got things working. :)

I have recently experienced this problem too. plexWatch creates new entries in the "recently_added" table in the database but it does not continuously check for changes made afterwards in your PMS db. I see no reason to have ljunkie change this when I can pull all recently added data from PMS itself. It's on my list to fix for the next version of plexWatch/Web.  Thanks for the feedback.

Glad to hear you got things working. :)

I have recently experienced this problem too. plexWatch creates new entries in the "recently_added" table in the database but it does not continuously check for changes made afterwards in your PMS db. I see no reason to have ljunkie change this when I can pull all recently added data from PMS itself. It's on my list to fix for the next version of plexWatch/Web.  Thanks for the feedback.

Yep, the DB for this is just so I don't re-send a notification :) Pulling recently added content would be better from the PMS api. 

Finally got this working, although I´m getting some errors on the index site. Under recently Added I get the newly added media, but also these: 

 

Warning: simplexml_load_file(http://192.168.1.50:32400/library/metadata/14635): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in C:\xampp\htdocs\plexWatchWeb\index.php on line 154

Warning: simplexml_load_file(): I/O warning : failed to load external entity “http://192.168.1.50:32400/library/metadata/14635” in C:\xampp\htdocs\plexWatchWeb\index.php on line 154

Notice: Trying to get property of non-object in C:\xampp\htdocs\plexWatchWeb\index.php on line 156

Notice: Trying to get property of non-object in C:\xampp\htdocs\plexWatchWeb\index.php on line 180

Warning: simplexml_load_file(http://192.168.1.50:32400/library/metadata/14634): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in C:\xampp\htdocs\plexWatchWeb\index.php on line 154

Warning: simplexml_load_file(): I/O warning : failed to load external entity “http://192.168.1.50:32400/library/metadata/14634” in C:\xampp\htdocs\plexWatchWeb\index.php on line 154

Notice: Trying to get property of non-object in C:\xampp\htdocs\plexWatchWeb\index.php on line 156

Ideas?

EDIT: Found it, it's trying to retrieve metadata from a file ID that doesn't exist. The strange thing is I never changed the metadata since this file was detected, but I did change the metadata of other recent files. Wierd. I guess this wont happen when it will look at the PMS DB itself for recenty added :)

This looks really good. Here's a couple of issues i've found so far:

1. On the History page i was getting "Divide by zero" errors due to line 163 in history.php. It looks to happen when the $duration is zero. I fixed it by changing

$percentComplete = sprintf("%2d", ($viewOffset / $duration) * 100);

to

$percentComplete = ($duration == 0 ? 0 : sprintf("%2d", ($viewOffset / $duration) * 100));

2. On the main page it says no one is currently streaming (which is correct) but on the history page it says someone is currently watching a movie. Fixed

3. IPAddress is n/a on the history tab

4. The time is incorrect. I just started playing a video at 7:31pm and the history page says it was started at 4:31AM. Looks to be a timezone problem

5. On the main page under Current Activity, when a movie is playing via Direct Play, the info dropdown says Direct Stream. Looking at the code in current_activity.php line 95, you are really only checking whether the key "TranscodeSession" exists. If it doesn't exist, it should say Direct Play, not Direct Stream. Direct Stream is when the audio and video is not transcoded but remuxed into a different format that the client can play.

6. When i click on either the movie currently playing from the main page or a movie title from the history page, it takes me to a info page. The first time this page loads, the artwork for the movie or show is sized incorrectly. It is only about 6 pixels wide. If i reload the page, then the artwork loads correctly. This appears to be just an issue with Safari as on Chrome on OSX it loads correctly. The easy way to fix this is change the css for .summary-content-poster to include the width and height:

.summary-content-poster {
position: relative;
top: -10px;
float: left;
margin-left: 20px;
width: 200px;
height: 300px;
} 

That's all for now. Keep up the good work.

4. The time is incorrect. I just started playing a video at 7:31pm and the history page says it was started at 4:31AM. Looks to be a timezone problem

I was just coming here to report the same issue. I was wondering if maybe a manual Time Zone offset could be added to the config file, or somehow make it use system time? Or something like that. But it seems like its set to UTC currently, and not local time.

This looks really good. Here's a couple of issues i've found so far:

1. On the History page i was getting "Divide by zero" errors due to line 163 in history.php. It looks to happen when the $duration is zero. I fixed it by changing

$percentComplete = sprintf("%2d", ($viewOffset / $duration) * 100);

to

$percentComplete = ($duration == 0 ? 0 : sprintf("%2d", ($viewOffset / $duration) * 100));

2. On the main page it says no one is currently streaming (which is correct) but on the history page it says someone is currently watching a movie. Fixed

3. IPAddress is n/a on the history tab

4. The time is incorrect. I just started playing a video at 7:31pm and the history page says it was started at 4:31AM. Looks to be a timezone problem

5. On the main page under Current Activity, when a movie is playing via Direct Play, the info dropdown says Direct Stream. Looking at the code in current_activity.php line 95, you are really only checking whether the key "TranscodeSession" exists. If it doesn't exist, it should say Direct Play, not Direct Stream. Direct Stream is when the audio and video is not transcoded but remuxed into a different format that the client can play.

6. When i click on either the movie currently playing from the main page or a movie title from the history page, it takes me to a info page. The first time this page loads, the artwork for the movie or show is sized incorrectly. It is only about 6 pixels wide. If i reload the page, then the artwork loads correctly. This appears to be just an issue with Safari as on Chrome on OSX it loads correctly. The easy way to fix this is change the css for .summary-content-poster to include the width and height:

.summary-content-poster {
position: relative;
top: -10px;
float: left;
margin-left: 20px;
width: 200px;
height: 300px;
} 

That's all for now. Keep up the good work.

rcork, 

Thanks for the feedback and fixes. I will add them to the next commit.

For item 3, do you have IP Address tracking setup and working properly in plexWatch? The only time the IP Address field will show "n/a" is if the table entry result for that row is empty. Also, if your database has been running for awhile, the IP Address feature was added later on in plexWatch so older entries will be empty.

For item 4, I am checking the web server's timezone and setting it for each page so make sure you have the correct timezone set for your server.

I was just coming here to report the same issue. I was wondering if maybe a manual Time Zone offset could be added to the config file, or somehow make it use system time? Or something like that. But it seems like its set to UTC currently, and not local time.

Nope, I had this issue come up from an early tester and resolved it by running a check for the web server's timezone and setting it from there so ensure your server is set to your current timezone.

Found a couple other issues on the user profile pages. In the cases where a user doesn't have any history for the current day or week, the $userStatsDailyTimeViewedTimeRowLength and $userStatsWeeklyTimeViewedTimeRowLength are uninitialized because no rows are returned in the SQL query. Here's the fixes:

In user.php, line 197 change:

if ($userStatsDailyTimeViewedTimeRowLength == 10) {
    echo "";

to


if (empty($userStatsDailyTimeViewedTimeRowLength)){
   echo "

/

0

mins

"; }else if ($userStatsDailyTimeViewedTimeRowLength == 10) { echo "";

The same changes are needed for $userStatsWeeklyTimeViewedTimeRowLength on line 236, $userStatsMonthlyTimeViewedTimeRowLength on line 273 and $userStatsAlltimeTimeViewedTimeRowLength on 310

Nope, I had this issue come up from an early tester and resolved it by running a check for the web server's timezone and setting it from there so ensure your server is set to your current timezone.

Fixed. Thank you.

Pruitt62,

Glad to hear you got the timezone issue worked out.

rcork,

Thanks again for all your troubleshooting. I will probably have a new dev commit available by the end of the weekend.

I am on the Dev branch and the only thing that appears to not work is the history,

When I go tot hat page it displays the following message:

"Failed to access plexWatch database. Please check your server and config.php settings."

Now the main page displays fine and show what is being watch

I am on the Dev branch and the only thing that appears to not work is the history,

When I go tot hat page it displays the following message:

"Failed to access plexWatch database. Please check your server and config.php settings."

Now the main page displays fine and show what is being watch

We'll need some more details on your setup.

I'll assume Windows, yes? Where is your plexWatch database located? 

Do you have the correct path and file name set for the variable $plexWatch['plexWatchDb'] in config.php? For example..... 'C:\plexWatch\plexWatch.db';

On the  info pages, if the media doesn't have genre, actor or writers, you get php errors about invalid variables. I added some checking to make sure they exist and display only if the metadata is available. In info.php starting on line 420 i changed your code to the following:

$genreCount = 0;
foreach($xml->Video->Genre as $xmlGenres) {
  $genres[] = "" .$xmlGenres['tag']. "";
  if (++$genreCount == 4) break;
}
if ($genreCount != 0){
  echo "
Genres
  • "; echo implode('
  • ', $genres); echo "
"; }

$roleCount = 0;
foreach($xml->Video->Role as $Roles) {
$actors[] = “” .$Roles[‘tag’]. “”;
if (++$roleCount == 4) break;
}
if ($roleCount != 0) {
echo “

Starring
  • ”;
    echo implode(’
  • ’, $actors);
    echo “
”;
}

$writerCount = 0;
foreach($xml->Video->Writer as $xmlWriters) {
$writers[] = “” .$xmlWriters[‘tag’]. “”;
if (++$writerCount == 4) break;
}
if ($writerCount != 0) {
echo “

Written by
  • ”;
    echo implode(’
  • ’, $writers);
    echo “
”;
}

Sorry for all the inline fixes. Maybe i'll finally learn how to use github correctly and fork your project

We'll need some more details on your setup.

I'll assume Windows, yes? Where is your plexWatch database located? 

Do you have the correct path and file name set for the variable $plexWatch['plexWatchDb'] in config.php? For example..... 'C:\plexWatch\plexWatch.db';

My PMS is on Windows 7

plexwatch and plexwatchweb are both on a VM on that same box running on ubuntu.

Plexwatch runs fine (I get notifications properly sent to me)

$plexWatch['plexWatchDb'] is set to /opt/plexWatch/plexWatch.db in the config.php

I may possibly be a permission issue in ubunutu not allowing the web user to see the plexwatch.db.

I will play with that

Edit: permissions seem to be set correctly 

What are the 

My PMS is on Windows 7

plexwatch and plexwatchweb are both on a VM on that same box running on ubuntu.

Plexwatch runs fine (I get notifications properly sent to me)

$plexWatch['plexWatchDb'] is set to /opt/plexWatch/plexWatch.db in the config.php

I may possibly be a permission issue in ubunutu not allowing the web user to see the plexwatch.db.

I will play with that

What are your permissions set to for plexWatch.db? Is it readable by the user your web server is run as (www-data?) ? 

What are the 

What are your permissions set to for plexWatch.db? Is it readable by the user your web server is run as (www-data?) ? 

This morning I quickly installed LAMP to get plexwatchweb running.

It looks as though root owns everything; my "/var/www" folder as well as everything in the "/opt/plexWatch" folder

Edit: I spoke to soon, it is indeed www-data, I will ave to give it right to the /opt/plexwatch area

This morning I quickly installed LAMP to get plexwatchweb running.

It looks as though root owns everything; my "/var/www" folder as well as everything in the "/opt/plexWatch" folder

Edit: I spoke to soon, it is indeed www-data, I will ave to give it right to the /opt/plexwatch area

What are the actual permissions for the database file?

What user is the apache service running as? Typically on Ubuntu it's www-data. Use this command to receive a list: ps aux | grep apache

What are the actual permissions for the database file?

What user is the apache service running as? Typically on Ubuntu it's www-data. Use this command to receive a list: ps aux | grep apache

running that shows that www-data is the user.

so I also did "chown -R www-data:www-data /opt/plexWatch"

But that did not make a difference either, still can not see history 

running that shows that www-data is the user.


chmod -R a+r /opt/plexWatch

It's what I did I think a long time ago :)

chmod -R a+r /opt/plexWatch

It's what I did I think a long time ago :)

Tried that too, still no go

Also, on the main page when it displays what is currently being watch the image is broken

here is the image url info of one of the broke images:

http://192.168.1.89:32400/photo/:/transcode?url=http://127.0.0.1:32400/library/metadata/2897/art/1381266229&width=300&height=169

Also, to clarify, I am opening a web browser on the host windows 7 pc to see the plexWatchweb which is hosted on a VM.

If I edit the above referenced url and change the 198.168.1.89 to 127.0.0.1 the url will return an image correctly

Edit:  I was able to fix the image problem.  It was related to having the "require users to authenticate" selected in the PMS settings.  

When that is selected I had to add my windows 7 box IP address as well as the address on the VM.  For the Windows 7 box 127.0.0.1 wasn't enough.  I had to add 192.168.1.89 to make it work.

The history page still does not showing though. 

I can though see the history of the currently playing movie when I click on that movie