# Now Playing (more PHP code) - Part II



## windracer (Jan 3, 2003)

Now that TTG has been enabled for the Series3 platform I thought I'd try to revive a really old thread in case any of the new S3/THD owners were interested.

Every now and then I get PM'ed asking how I make the Now Playing pages linked to in my sig. Here's how:

The PHP code that generates the NPLs for each TiVo can be found in this old thread:

http://archive2.tivocommunity.com/tivo-vb/showthread.php?t=218365

In a nutshell:



clam729 said:


> This will allow you to retrieve your Now Playing data from your TiVo(s) and display it as either HTML, XML or RSS.


The PHP program connects to the TiVo web server, then parses out the XML into what you see in my sig. It can also create RSS feeds, so you can actually "subscribe" to your own feeds and get updates when any of your TiVo boxes record a show during the day (why? why not?). 

I have my own little web server at home, running Linux (which is the same server I run Galleon and pyTiVo on). Every hour, a scheduled job runs the PHP code and refreshes the Now Playing Files.

Check it out, it's pretty cool. :up:


----------



## windracer (Jan 3, 2003)

I guess no one else thinks this is cool?


----------



## greg_burns (May 22, 2004)

windracer said:


> I guess no one else thinks this is cool?


I do, but PHP just ain't my thing.


----------



## clam729 (Nov 28, 2004)

I still think it's cool  I have a new version with bug fixes, new features, new urls, prelim channel logos, etc.

Give me a day or two to give it a final check and I'll upload a copy to this thread...


----------



## windracer (Jan 3, 2003)

Excellent! :up:


----------



## gonzotek (Sep 24, 2004)

clam729 said:


> I still think it's cool  I have a new version with bug fixes, new features, new urls, prelim channel logos, etc.
> 
> Give me a day or two to give it a final check and I'll upload a copy to this thread...


Awesome!


----------



## clam729 (Nov 28, 2004)

Status update. I am away from home, so editing has been limited.

The following changes have been made:
-alot of cosmetic fixes/changes
-display of the <highdefinition> tag
-PHP updates (still on 4, haven't switch to 5 yet)
-channel logo downloads from the TiVo, however, I still haven't made the channel logo <-> XML connection

Still in progress
-need to update the URLs for IMDB and Zap2It support
-update the "forum" copy of the code


----------



## JohnBrowning (Jul 15, 2004)

windracer said:


> I guess no one else thinks this is cool?


Sure they do! They just don't want everyone to see what porn they're watching!!


----------



## windracer (Jan 3, 2003)

Note to clam729: ability to filter pr0n out of NPL.


----------



## Airey001 (Oct 20, 2005)

LOL alway must hide those videos. 

And this is something i was interested in also thanks for posting this and thank those that are updating the code.

I have been busy playing with and hacking my new iPod Touch! And really haven't been playing with my tivos all the much recently. Epically since 9.1 broke alot of stuff.


----------



## clam729 (Nov 28, 2004)

windracer said:


> Note to clam729: ability to filter pr0n out of NPL.


Already in there 
I have an array that you can put keywords, titles, etc. in that you want filtered out.


----------



## windracer (Jan 3, 2003)

Brilliant!


----------



## windracer (Jan 3, 2003)

*bump*

Hey clam729, did you ever release that newer version you were working on late last year? 

I just noticed the other day that the old (original) version I am using is missing an icon for an in-progress transfer (i.e., the blue dot) and it made me think of this. I'd like to have those HD and filter enhancements.


----------



## clam729 (Nov 28, 2004)

Been a while since I replied to this and even looked at my PHP code. I had an idea tonight, fired up the editor and added some new/more code/features. 

The previous version of the PHP script would pull back the basic XML data from your TiVo(s) and display it in a webpage. Each show has more XML data - you can see this when you click the title link from my page. Now my PHP script will pull down the basic XML data - THEN - loop through each show and pull it's XML data down as well - process it and expand/enhance the show's listing on the webpage.

The new listing will include ratings, series and show genres, actors, advisorys, director, producer, etc. - I even have the images linked for advisory's and ratings.

Data pulling is fairly quick. I was able to pull the initial data and 80 shows/movies split between 2 TiVos in less than one minute.


----------



## windracer (Jan 3, 2003)

Sounds cool ... where can we get the new code?


----------



## windracer (Jan 3, 2003)

*bump for clam729*

I'm back from vacation and would like to try out the new stuff. Ready to share it?


----------



## clam729 (Nov 28, 2004)

windracer said:


> *bump for clam729*
> 
> I'm back from vacation and would like to try out the new stuff. Ready to share it?


Not quite yet - still some kinks to work out. Still trying to get the new parser 100% working. I am able to pull all data I need, now I'm at the part of "prettying it up" for the web output.


----------



## windracer (Jan 3, 2003)

Some mods I made (with azitnay's help) to index.php include the addition of a header to the main file, stripping out the Tribune notification from each description, and adding a breakdown of sizes (Suggestions, freespace, etc.) to the end. Check the links in my sig for examples and let me know if you want any of that code (I can't remember if you've added that since or not).


----------



## wmcbrine (Aug 2, 2003)

How are you doing the Season Passes?


----------



## windracer (Jan 3, 2003)

Excel. 

Sorry, no magic there.


----------



## clam729 (Nov 28, 2004)

Very nice. I have some of those added already - this is how I am doing it (from index.php)

```
$tivoarray[$i]['content'] = str_replace("amp;", "", $tivoarray[$i]['content']);
$tivoarray[$i]['title'] = str_replace("amp;", "", $tivoarray[$i]['title']);
$tivoarray[$i]['episodetitle'] = str_replace("amp;", "", $tivoarray[$i]['episodetitle']);
$tivoarray[$i]['description'] = str_replace("Copyright Tribune Media Services, Inc.", "", $tivoarray[$i]['description']);
```
I'll try and work on it a little tonight.


----------



## HomeUser (Jan 12, 2003)

I added some updates to the version in the link that *windracer* pointed to.

Some of the changes I made

- The collapse cookies now work if you have more than one DVR.

- I added a Summery page useful if you have more than one TiVo DVR.

- Free space is also displayed as a percent with color warnings when the FS gets below a set level.

- Modified the code to continue on to the next DVR instead of trapping out if one of the DVR's is off-line.

- Changed to use GB's instead of MB.

I only tested the code with Linux and did nothing with the RSS.










Code refresh attached


----------



## windracer (Jan 3, 2003)

Very cool ... thanks for the updates! :up::up: I had written a custom shell script wrapper to try and check for "offline" TiVos but it never worked reliably and inevitably wget would get hung up somewhere. Your new solution is a lot nicer, and works! 

Just a few things I wanted to point out:

- you misspelled "Available" in index.php (line 14, for the summary page)
- you should add your new .pgid, .srid, .epnum class elements to line 9 of tivo.css so the text is formatted in a similar manner to the other elements there

Thanks again!


----------



## windracer (Jan 3, 2003)

Note to others who may upgrade to HomeUser's new version: if you use the check_tivo plugin for Nagios to monitor free space, you'll need to update the plugin code to look for GB instead of MB in the regular expression and also account for the decimal place in the free space number. To do this, I changed the following line:


```
if (!preg_match("/Available Space \(including Suggestions\)\: (\d+) MB/",$response, $matches)) {
```
to:


```
if (!preg_match("/Available Space \(including Suggestions\)\: (\d+.\d+) GB\s.*/",$response, $matches)) {
```


----------



## HomeUser (Jan 12, 2003)

I used Percent Free instead of the free space for the Nagios check_tivo_freespace script.


```
if (!preg_match("/Available Space \(including Suggestions\)\: \d+.\d+\sGB\s\((\d+.\d+).\)*/",
                $response, $matches)) {
```
Changed the output messages to reflect Percent also

```
if (!preg_match("/Available Space \(including Suggestions\)\: \d+.\d+\sGB\s\((\d+.\d+).\)*/",
                $response, $matches)) {
  echo "CRITICAL - Unable to find match in $url\n";
  exit(2);
}

$freespace = intval($matches[1]);
if ($freespace < $critical) {
  echo "CRITICAL - $freespace% is less than $critical% Free\n";
  exit(2);
} else if ($freespace < $warning) {
  echo "WARNING - $freespace% is less than $warning% Free\n";
  exit(1);
} else {
  echo "OK - $freespace% is at least $warning% Free\n";
  exit(0);
}
```


----------



## HomeUser (Jan 12, 2003)

windracer said:


> Very cool ... thanks for the updates! :up::up: I had written a custom shell script wrapper to try and check for "offline" TiVos but it never worked reliably and inevitably wget would get hung up somewhere. Your new solution is a lot nicer, and works!
> 
> Just a few things I wanted to point out:
> 
> ...


Good catch, When I started I knew nothing and now know very little about CSS.
I tried to get _ProgramId_ and _SeriesId_ on the same line like _Size_ and _Duration_. I think one or both of the ID parameters could be used to organize the programs into folders. Not sure if they are really any use in the output.

Made you're suggestions and re-uploaded the tivo_now_playing.zip file in the previous message
Just the two updated files are attached in the zip file this message


----------



## windracer (Jan 3, 2003)

HomeUser said:


> I used Percent Free instead of the free space for the Nagios check_tivo_freespace script.


Ah, I like that idea! I made your changes to the plugin, but the regex doesn't seem to work if the percentage is a whole number (ex. 38% instead of 37.8%).


----------



## HomeUser (Jan 12, 2003)

windracer said:


> Ah, I like that idea! I made your changes to the plugin, but the regex doesn't seem to work if the percentage is a whole number (ex. 38% instead of 37.8%).


I just discovered that problem also. Change the second "\d+" one or more of to "\d*" zero or more of.

```
f (!preg_match("/Available Space \(including Suggestions\)\: \d+.\d*\sGB\s\((\d+.\d*).\)*/",
                $response, $matches)) {
```


----------



## windracer (Jan 3, 2003)

Perfect, thanks!


----------



## gonzotek (Sep 24, 2004)

Cool, glad to see that people are still using and improving this! The first version (which clam729, et al, then improved upon) was written over a long weekend the month TTG was released, while sick and feverish, so I apologize if the code is ugly .


----------



## windracer (Jan 3, 2003)

I wonder if clam729 ever finished those other cool mods he was working on back in 2008?


----------



## HomeUser (Jan 12, 2003)

windracer said:


> Note to others who may upgrade to HomeUser's new version: if you use the check_tivo plugin for Nagios to monitor free space, you'll need to update the plugin code to look for GB instead of MB in the regular expression and also account for the decimal place in the free space number. To do this, I changed the following line:


If you have Nagios sending e-mail alerts I found that "In Progress Recordings" cause the free space warning to send out false alerts. The "In Progress Recording" suggestions are not counted as suggestions and are being calculated as part of the used space then freeing up space when they become suggestions after recording has completed.

This free space flapping is especially annoying if you have the Elite with 4 tuners recording suggestions.

I don't see any indicator that shows a in progress recording is a suggestion so I came up with this hack.


```
[COLOR="Silver"]foreach($tivos as $tivo) {
	unset($tivoarray, $totalsize, $totallength, $customicon, $sc, $totalitems, $freespace, $rssheader, $rsscontent, $rssfooter, $header, $content, $footer, $fp1, $fp2, $totalsuggestions, $percent_free, $fpt, $auto_size_gb[/COLOR] , $recording_suggestion);

	[COLOR="Blue"]// both requested and suggestions show now_recording when in progress. Any in progress
	// recordings before the first non suggestion should be counted as used space.[/COLOR]
	$recording_suggestion = false;
```
At the start of the TiVo loop I added a new boolean *$recording_suggestion* and set it to *false* I also included it in the unset list JIC.


```
[COLOR="Silver"]		// # compute suggestions added 10/28/2011 
		if($customicon[3] == "suggestion-recording") {
			$totalsuggestions += $tivoarray[$i]['sourcesize'];
		}[/COLOR]

[COLOR="Blue"]		// Fix Nagios free space flapping 04/11/12 VW>
		// Requested in progress recordings are listed first[/COLOR]
		if($customicon[3] != "in-progress-recording"){
			[COLOR="Blue"]//All in progress recordings should now be suggestions[/COLOR]
			$recording_suggestion = true;
		}
		if($recording_suggestion == true){
			if($customicon[3] == "in-progress-recording"){
				$totalsuggestions += $tivoarray[$i]['sourcesize'];
			}
 		}
```
Added new code that checks for any non in progress recording I added it just after the space used by suggestions is computed *$customicon[3] == "suggestion-recording"*. The new code sets the new Boolean true.
Next add any additional "In Progress Recordings" to the space used by suggestions.


----------



## bshrock (Jan 6, 2012)

Thanks works great.
Maybe a little more efficient coding?


```
[COLOR="Blue"]// Fix Nagios free space flapping 04/11/12 VW>[/COLOR]
	[COLOR="Blue"]// Requested in progress recordings are listed first
[/COLOR]
	if($recording_suggestion == true){
		if($customicon[3] == "in-progress-recording"){
			$totalsuggestions += $tivoarray[$i]['sourcesize'];
		}
	} else {
		if($customicon[3] != "in-progress-recording"){
			[COLOR="Blue"]//All in progress recordings should now be suggestions[/COLOR]
			$recording_suggestion = true;
		}
 	}
```


----------



## bshrock (Jan 6, 2012)

Is there an easy way to get the data sorted into folders?


----------



## windracer (Jan 3, 2003)

So ... I upgraded my Linux server to Ubuntu 12.10 (Quantal Quetzal) on Friday night and today noticed that this script wasn't working anymore. I have it set via cron to run hourly and the last time it ran successfully was Friday before the upgrade.

I'm thinking it has something to do with PHP 5.4, as I see other folks on the Ubuntu forums mentioning PHP problems. I'm not certain I want to rollback to 5.3 yet since other stuff (like WordPress) is working fine.

If I manually run 'php index.php' it just does nothing. No errors, no output, even with error_reporting set to -1.

Anyone have any ideas?

_edit:_ ahh, fixed it! I found a tivo_errors.txt file that contained this:


```
[22-Oct-2012 20:57:01 UTC] PHP Notice:  Undefined index: OS in /usr/local/tivo/now_playing/tivo_settings.php on line 8
[22-Oct-2012 20:57:01 UTC] PHP Fatal error:  Call-time pass-by-reference has been removed in /usr/local/tivo/now_playing/class_tivo_xml.php on line 111
```
I commented out the check for $_ENV["OS"] in tivo_settings.php to get past the first error (I'm on Linux so I don't need to check for Windows to set the delimiter), but the second one was a little different. After a little Google searching, I determined that line 111 in class_tivo_xml.php needed to be changed from this:


```
xml_set_object($this->parser, &$this);
```
to this:


```
xml_set_object($this->parser, $this);
```
Basically, remove the ampersand (&) before $this.

That fixed it, the script is working again! :up:


----------



## gonzotek (Sep 24, 2004)

windracer said:


> So ... I upgraded my Linux server to Ubuntu 12.10 (Quantal Quetzal) on Friday night and today noticed that this script wasn't working anymore. I have it set via cron to run hourly and the last time it ran successfully was Friday before the upgrade.
> 
> I'm thinking it has something to do with PHP 5.4, as I see other folks on the Ubuntu forums mentioning PHP problems. I'm not certain I want to rollback to 5.3 yet since other stuff (like WordPress) is working fine.
> 
> ...


 Just as an amusing point of historical fact: That ampersand bug goes all the way back to my first release of the script... and exists because I lifted the xml parsing routine from comments in the php documentation without fully understanding what it did (at the time) . Thanks for fixing it!


----------



## HomeUser (Jan 12, 2003)

Any one still using or made any updates?


----------



## gonzotek (Sep 24, 2004)

HomeUser said:


> Any one still using or made any updates?


Anything you're looking for specifically? Other than windracer's fix last year, there hasn't been much interest in this in a quite a while.


----------



## windracer (Jan 3, 2003)

I still use it!


----------



## HomeUser (Jan 12, 2003)

gonzotek said:


> Anything you're looking for specifically? Other than windracer's fix last year, there hasn't been much interest in this in a quite a while.


Looking to see if there is any interest or any important changes b4 cleaning up and posting new code.

Over the past year I have made many changes.
When I thought the DVR was deleting programs early I modified the program to save a history of the playlists. Click on the number of suggestions in the summery table to bring up a table linking to the play lists of that DVR for the current month.

When I was searching the DVR's for a BBCA program that did not record (was set to record only new) and hoping that the program was recorded as a suggestion I added a combined play list to make searching all of the DVRs easy.

Changes that I recall
 Auto size adjustment for drives.
 Archiving "now playing" lists.
 Sorting of summery table.
 Added field deleted to summery table (space not used by programs or suggestions). 
 Combined now playing for all DVR's.
 URL path allowing generation when HTML files are not published on local computer some guru probably can find a better solution to this.
 Other changes that I have forgot about.
- I added something to the program information like series ID.
- Toggle all button.

Almost live webpage with the modifications See HomeUser's Now Playing List

Notes:
The archive history is saved only when the program is run during the first 15 minutes of each hour it may take an hour before the history pages are generated.
For sorting the tables I used sortable.js table code from http://www.kryogenix.org/code/browser/sorttable/
My updated files attached. I moved all the js and php files except index.php to a bin directory and made lots of changes to tivo_settings.php and will not %100 compatible with the previous tivo_settings.php.


----------



## windracer (Jan 3, 2003)

That reminds me ... I put together some new image files for the Premiere, Elite, and Roamio models (attached).

Premiere: tivo_746 (can also copy as tivo_748)









Elite/XL4: tivo_750 (can also copy as tivo_750)









Roamio: tivo_840 (can also copy as tivo_848)


----------



## HomeUser (Jan 12, 2003)

I tried adding them to the zip file and that makes the file over the 100K limit.


----------



## bshrock (Jan 6, 2012)

HomeUser said:


> Combined now playing for all DVR's.


I have added a few more DVRs and used this the other day when the end of show was cut off because of an overrun shift with CBS I searched and found the next program that just happened to be recorded as a suggestion.

Any hope of getting groups? I've tried, my programming skills are just not good enough.


----------



## windracer (Jan 3, 2003)

There's probably a way but I haven't looked at this (code) in a long time ... maybe if I have some free time I can take a look at it.


----------



## Dan203 (Apr 17, 2000)

I did this in pyTivo Desktop. Might be easier in python though. In python I use a multi-dimensional collection. The upper most collection is keyed off of the series ID. Then each entry in that collection is another collection with all the show data keyed off the episode ID. If I run into something like a movie that doesn't have one of those values then I just use a counter value that I tick up 1 every time it's used. 

You can't depend on the pre-grouped data from the TiVo. It gets all messed up when the user has streaming only 1Ps.


----------



## windracer (Jan 3, 2003)

Sounds like you've already talked me out of it.


----------



## Dan203 (Apr 17, 2000)

I haven't done PHP in years, and I've never even looked at this code, so I'm not offering to do it. I'm just offering a strategy as to how to do it.


----------



## HomeUser (Jan 12, 2003)

bshrock said:


> I have added a few more DVRs and used this the other day when the end of show was cut off because of an overrun shift with CBS I searched and found the next program that just happened to be recorded as a suggestion.
> 
> Any hope of getting groups? I've tried, my programming skills are just not good enough.


I experimented with a table containing Series and Episode data using a java script routine Stuart Langridge's sorttable.js.
My results view-able online here TNPL sort 

There are 4 sections of code added to index.php

Header: Before the main loop of DVRs
Loop: in the loop after the xml data has been collected

Footer: after the loop.
Write: At the end where the other writes are


```
// Header:
$sort_header .= "<!DOCTYPE html>\n"; // PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n\n";
$sort_header .= "<html><head>\n";
$sort_header .= "<LINK REL=\"shortcut icon\" HREF=\"" . $images . "favicon.ico\" TYPE=\"image/x-icon\">\n\n";
$sort_header .= "<sh>\n<title> SORT </title><link href=\"" . $summary_css . "\" rel=\"stylesheet\" type=\"text/css\"></sh>\n\n";
$sort_header .= "<h2> Last Update: " . date ( "F j, Y, g:i a e" ) . " </h2>\n";
$sort_header .= "<script src=\"" . $mysorttable . "\" type=\"text/javascript\"></script>\n";
$sort_header .= "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n";

// Sortable Table of episodes, series,etc.
$sort_table .= "<h4>\n<br><table id=\"Summary\" class=\"sortable\" border=\"2\" cellspacing = \"2\" cellpadding = \"4\" align = \"center\" >\n";
$sort_table .= " <tr>
        <th> TiVo </th>
        <th class=\"sorttable\"> Series Name </th>
        <th class=\"sorttable\"> Episode </th>
        <th class=\"sorttable\"> Program ID </th>
        <th class=\"sorttable\"> Series ID </th>
        <th class=\"sorttable_numeric\"> Record Date </th>
        </tr>\n";
```


```
// Loop: for each DVR:
               // Add  a  row to the sort table
               $sort_table .= "<tr>";                                       // add the TiVo's name for the first field in the sort table
               $sort_table .= "<td>" . $tivo ['name'] ."</td>";           // Add shows title to sort table
               $sort_table .= "<td>" . $tivoarray [$i] ['title'] ."</td>";   // Add shows title to sort table
               $sort_table .= "<td>" . $tivoarray [$i] ['episodetitle'] ."</td>";
               $sort_table .= "<td>" . $tivoarray [$i] ['programid'] ."</td>";
               $sort_table .= "<td>" . $tivoarray [$i] ['seriesid'] ."</td>";
               //$sort_table .= "<td>" . tivoDate ( "g:i a - F j, Y", $tivoarray [$i] ['capturedate'] ) ."</td>";               

               //$sort_table .= "<td>" .
               //    tivoDate ( "Y.m.d.H.i", $tivoarray [$i] ['capturedate'] ) . "\n" .
               //    $tivoarray [$i] ['capturedate'].
               //"</td>";
               
               $sort_table .=
                       "<td sorttable_customkey=\"" . tivoDate ( "YmdHi", $tivoarray [$i] ['capturedate'] ) . "\">" .
                           tivoDate("g:i a - F j, Y", $tivoarray [$i] ['capturedate'] ) .
                           //$tivoarray [$i] ['capturedate'].
                       "</td>";
```


```
// Footer:
$sort_table .= "</table>\n</h4>\n";
$sort_footer .= "</body></html>";
```


```
// Write:
$fp1 = @fopen ( "sort.htm", "w" );
fwrite ( $fp1, $sort_header . $sort_table . $sort_footer );
fclose ( $fp1 );
```


----------



## windracer (Jan 3, 2003)

Nice! I'll have to check that out. Once it's in a sorted table making it collapsible shouldn't be that difficult.

Also forgot to post that I put together a GitHub repo for this the other week and updated the graphics/icons.

GitHub - jradwan/tivo_now_playing: Retrieve the Now Playing data from your TiVo(s) and display it as either HTML, XML or RSS.


----------



## windracer (Jan 3, 2003)

HomeUser said:


> I experimented with a table containing Series and Episode data using a java script routine Stuart Langridge's sorttable.js.


I added this to my repo, thanks! Now that I see what it's doing, I decided that making the sorted table "collapsible" to mimic folders wasn't really feasible (or worth the effort at this point). But this new page does give the user a quick way to sort by all show or episode names across multiple TiVos so in a way that's a workaround to real groups/folders.

You can see my live version here.


----------



## HomeUser (Jan 12, 2003)

Created an array indexed by seriesid allowing episodes to be concatenated to sortable tables
two additions to index.php

1: In the loop after the xml data has been collected

```
$folders[$tivoarray [$i] ['seriesid']] .= "<tr>";                                       // add the TiVo's name for the first field in the sort table
           $folders[$tivoarray [$i] ['seriesid']] .= "<td>" . $tivo ['shorttitle'] ."</td>";       // Add shows title to sort table
           $folders[$tivoarray [$i] ['seriesid']] .= "<td>" . $tivoarray [$i] ['title'] ."</td>";   // Add shows title to sort table
           $folders[$tivoarray [$i] ['seriesid']] .= "<td>" . $tivoarray [$i] ['episodetitle'] ."</td>";
           $folders[$tivoarray [$i] ['seriesid']] .="<td sorttable_customkey=\"" .
                   tivoDate ( "YmdHi", $tivoarray [$i] ['capturedate'] ) . "\">" .                       // Record date index on sortable numeric value
                   tivoDate("g:i a - F j, Y", $tivoarray [$i] ['capturedate'] ) ."</td>";                   // Record date viewable format
           // Note: ProgrameID and Series are for testing may be removed one or both in the future
           $folders[$tivoarray [$i] ['seriesid']] .= "<td>" . $tivoarray [$i] ['programid'] ."</td>";
           $folders[$tivoarray [$i] ['seriesid']] .= "<td>" . $tivoarray [$i] ['seriesid'] ."</td>";
```
2: At the end where the other writes are.

```
$fp1 = @fopen ( "folders.htm", "w" );
fwrite($fp1, $sort_header);   // Reused the sort header from b4
foreach($folders as $x => $x_value) {   // Process the entire array
   // header for each series put in loop to give each table a unique ID from the seriesid
   fwrite($fp1, "<h4>\n<br><table id=\"$x\" class=\"sortable\" border=\"2\" cellspacing = \"2\" cellpadding = \"4\" align = \"center\" >\n");
   fwrite($fp1, "   <tr>
                   <th> TiVo </th>
                   <th class=\"sorttable\"> Series Name </th>
                   <th class=\"sorttable\"> Episode </th>
                   <th class=\"sorttable_numeric\"> Record Date </th>
                   <th class=\"sorttable\"> Program ID </th>
                   <th class=\"sorttable\"> Series ID </th>
                   </tr>\n");

   fwrite($fp1, $x_value . "\n");   // write the rows of the table collected and formatted in the tivo loop
   fwrite($fp1, "</table>\n</h4>\n");
}
// footer
fwrite($fp1, "<a href=\"" . $myurl . "summary.htm\" >&larr; back to Summary page </a>");
fwrite($fp1, "</body></html>");
fclose ( $fp1 );
```
Links to the new folders.htm from the other pages need to be added where needed.
created a new branch "folders" on windracers GitHub.

 My live TNPL


----------



## windracer (Jan 3, 2003)

Neat! I'll have to figure out how to do a PR now.


----------



## HomeUser (Jan 12, 2003)

I think I have to do the PR ... anyway I just did to see how it works. Also added the status icons to the table.

Where the folders table data is collected

```
$folders[$tivoarray [$i] ['seriesid']] .= "<tr>";                                       // add the TiVo's name for the first field in the sort table
           $folders[$tivoarray [$i] ['seriesid']] .= "<td>" . $tivo ['shorttitle'] ."</td>";       // Add shows title to sort table

 // New   vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv  
           if ($customicon[3] != "") {
               $folders[$tivoarray [$i] ['seriesid']] .= "<td><img src=\"" .$images. "" .
                $customicon[3] . ".png\" width=\"16\" height=\"16\"></td>\n";
           }
           else {
               $folders[$tivoarray [$i] ['seriesid']] .= "<td><img src=\"" .$images. "" .
                "regular-recording.png\" width=\"16\" height=\"16\"></td>\n";
           }
 // ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

           $folders[$tivoarray [$i] ['seriesid']] .= "<td>" . $tivoarray [$i] ['title'] ."</td>";   // Add shows title to sort table
```
in write change the table header adding the Status column

```
fwrite($fp1, "   <tr>
                   <th> TiVo </th>
                   <th class=\"sorttable\"> Status </th>
                   <th class=\"sorttable\"> Series Name </th>
                   <th class=\"sorttable\"> Episode </th>
                   <th class=\"sorttable_numeric\"> Record Date </th>
                   <th class=\"sorttable\"> Program ID </th>
                   <th class=\"sorttable\"> Series ID </th>
                   </tr>\n");
```


----------



## windracer (Jan 3, 2003)

Cool, thanks! I went ahead and merged it ... looks good.

Although what was the .project file for?


----------



## HomeUser (Jan 12, 2003)

Must be from Eclipse a project was created when I imported the files. I deleted it from the branch.


----------



## windracer (Jan 3, 2003)

I merged in the branch, thanks!


----------



## HomeUser (Jan 12, 2003)

Added groups to each DVR accessible through (Grouped) next to the TiVo's name








 [url=http://vicw.us/tnpl/summary.htm]My Live TNPL


----------



## windracer (Jan 3, 2003)

Can you create a PR so I can add that to my repo?


----------



## HomeUser (Jan 12, 2003)

Done


----------



## windracer (Jan 3, 2003)

I see it ... thanks! I hope you don't mind my continuing to tweak your contributions.


----------



## HomeUser (Jan 12, 2003)

No problem still finding my way around GitHub I think I've got you're changes merged into my branch.

Nice touch replace the text "Groups" with the blue folder icon. I see you called it folder (not folder.png). You're live demo works because /images has a file named folder (no extension) was this intentional? If you don't want to replace the old folder.png may I suggest folder_thumb.png


----------



## windracer (Jan 3, 2003)

HomeUser said:


> Nice touch replace the text "Groups" with the blue folder icon. I see you called it folder (not folder.png). You're live demo works because /images has a file named folder (no extension) was this intentional? If you don't want to replace the old folder.png may I suggest folder_thumb.png


That was definitely a typo (forgot the .png). Strange that it worked because there definitely was no file called just "folder" in my local images subdirectory. I'm not sure how that worked but I fixed it, thanks.


----------



## HomeUser (Jan 12, 2003)

Update 06/15/2017 Mostly when a DVR goes off-line

 Cleanup some Html syntax errors missing closing tags
 Fixed the corrupt summary table with missing DVR(s)
 *Added wget timeouts to tivo_settings.php wgetpath*
 Group displays off-line for the off-line DVR same as NowPlaying
 Total drive size in summary now excludes off-line DVR's in it's calculations


----------



## HomeUser (Jan 12, 2003)

Tables now are now collapsible


----------



## windracer (Jan 3, 2003)

Merged. I'll take a look at the CSS formatting and cleanup tomorrow. I like the collapsible tables for the ALL list, very cool, thanks!

Since there are no groups on the sortable episode list, we don't need the "expand/collapse all" link on that page, right?


----------



## HomeUser (Jan 12, 2003)

Not if/until the description and the other info is hidden in the tables. My goal is to make groups and folders replace the original page.
probably should comment it out from the sortable episode list, folders and groups since collapse_all doesn't work anyway I was going to do that B4 I pushed it today then I got side tracked by the group dates all displaying 1969 or 1970 (As I recall they were both good years for me).


----------



## HomeUser (Jan 12, 2003)

Latest update 06/20/2017 of index.php with collapsible tables.


----------



## windracer (Jan 3, 2003)

I did the CSS and formatting cleanup for the collapsible groups pages tonight ... new commit to the repo. Let me know what you think.

I looked for an "open folder" icon because I thought on these pages it might be nicer to have an open/closed folder icon instead of the checkbox for expanding but couldn't find one. May have to make it myself.

_edit:_ I made the image and updated the collapsible folder pages to use the open/closed folder image toggle instead of the checkboxes.


----------



## HomeUser (Jan 12, 2003)

I like the open and closed folder icons. Nice touch.
Not sure where to go next... that is after I get Eclipse current with GitHub. What do you think about replacing the episode and series columns with the episode's description? That would loose the sort by episode alto I am sure that we can get rid of the Series ID column maybe the Series ID could be displayed as a flyover on the episode column or better yet on the series name.


----------



## HomeUser (Jan 12, 2003)

I've added the tooltips to both groups and folders, what do you think?
TiVo Disk Space - Summary
index.php on my branch is up-to-date. still in debugging mode not ready to push it yet.


----------



## windracer (Jan 3, 2003)

As you say, nice touch. 

I see that expand/collapse all isn't working on the folders/groups pages. Also, on your Premier folder page, how/why is "Movies and Specials" highlighted in yellow? Something about the and _ tags?_


----------



## HomeUser (Jan 12, 2003)

I don't know why the expand/collapse all for groups isn't working, there might be a conflict with sorttable.js or an out of place tag.

Yes the Yellow is the tag. For debugging I wanted to highlight the new group and the entire page appears to be bold so * was not doing anything  was not very noticeable. I'd like the group to be a little noticeable because that is where you find programs that are missing the guide data maybe not so much as the Yellow highlight. Like PHP I am a novice with HTML and CSS.*


----------



## HomeUser (Jan 12, 2003)

windracer said:


> As you say, nice touch.
> 
> I see that expand/collapse all isn't working on the folders/groups pages.


 Expand/collapse is fully functional all pages with Today's 20170625 build and I removed it from the sortable episode list


----------



## bshrock (Jan 6, 2012)

Bug?
I downloaded index.php from github when I open All TiVos - Now Playing then click to open an item at the bottom it opens on of the items at the top of the page instead.


----------



## HomeUser (Jan 12, 2003)

bshrock said:


> Bug?
> I downloaded index.php from github when I open All TiVos - Now Playing then click to open an item at the bottom it opens on of the items at the top of the page instead.


 That should be fixed with 20170625. There was an indexing problem with the expand_all I just put 20170626 up there with that fix and in addition it fixes most of the HTML errors that I created.


----------



## windracer (Jan 3, 2003)

Sorry I've been quiet ... busy weekend, work this week, and then long road trip for the holiday weekend coming up. Haven't had a chance to look at your changes code-wise.

Vic, I noticed in your live site some of the graphics are still the old ones (like the recording status). Is this just a caching issue on your side (or mine?)?


----------



## HomeUser (Jan 12, 2003)

That would be on my side. I have not updated the remote web site's image directory.


----------



## bshrock (Jan 6, 2012)

HomeUser said:


> That should be fixed with 20170625. There was an indexing problem with the expand_all I just put 20170626 up there with that fix and in addition it fixes most of the HTML errors that I created.


Yep it's fixed Thanks.


----------



## HomeUser (Jan 12, 2003)

20170903 update to index.php.
Added new folder Movies for programs that the Series ID starts with "MV" and Uncategorized for programs that do not have a Series ID.

Changed the "Program ID" tooltip to display the "Episode Number" if one exists. Anyone know where KMTTG gets the "Episode Number" it seems have it on more shows.

The update can be downloaded from GitHub -> TiVoHomeUser -> tivo_now_playing


----------



## windracer (Jan 3, 2003)

Thanks! Once I have some time (prepping for Hurricane Irma) I'll check it out and merge ...


----------



## HomeUser (Jan 12, 2003)

5 years later .... I'm trying to move my Network and Video stuff off an antiquated server on to one or more Raspberry Pi(s) I have managed to get Plex and Kmttg moved and working I am stuck with this php program "TiVo Now PLaying" when run after some tweeking wget is only downloading the first page terminating with "(The TLS connection was non-properly terminated.).Giving up." I have tried the 2 versions of wget for raspbian "Wget 1.21" and "Wget2 1.99.1" any one know of other versions that might work?


----------



## windracer (Jan 3, 2003)

Man, sorry! I haven't used this in so long and don't have any more TiVos I could even test it on.

I checked two of my Pis and they both have wget 1.20.1 ... but who knows if that would even work.


----------



## HomeUser (Jan 12, 2003)

Thanks for the reply Windracer happy to see you are still around these parts. I was hoping someone had all-ready done it.
I found the archives of sources for the previous versions of wget having fun now learning how to build for this version of Linux probably should not of chosen the 64 bit version of raspbain for this.


----------

