1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Now Playing (more PHP code) - Part II

Discussion in 'TiVo Home Media Features & TiVoToGo' started by windracer, Oct 26, 2007.

  1. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    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)
    [​IMG]

    Elite/XL4: tivo_750 (can also copy as tivo_750)
    [​IMG]

    Roamio: tivo_840 (can also copy as tivo_848)
    [​IMG]
     

    Attached Files:

  2. HomeUser

    HomeUser Active Member

    2,406
    5
    Jan 12, 2003
    A2 Michigan
    I tried adding them to the zip file and that makes the file over the 100K limit.
     
  3. bshrock

    bshrock Member

    266
    0
    Jan 6, 2012
    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.
     
  4. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    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.
     
  5. Dan203

    Dan203 Super Moderator Staff Member TCF Club

    40,557
    1,220
    Apr 17, 2000
    Nevada
    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.
     
  6. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    Sounds like you've already talked me out of it. ;)
     
  7. Dan203

    Dan203 Super Moderator Staff Member TCF Club

    40,557
    1,220
    Apr 17, 2000
    Nevada
    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. :)
     
  8. HomeUser

    HomeUser Active Member

    2,406
    5
    Jan 12, 2003
    A2 Michigan
    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
    1. Header: Before the main loop of DVRs
    2. Loop: in the loop after the xml data has been collected
    3. Footer: after the loop.
    4. Write: At the end where the other writes are

    Code:
    // 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";
    
    
    
    Code:
    // 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>";
    
    
    Code:
    // Footer:
    $sort_table .= "</table>\n</h4>\n";
    $sort_footer .= "</body></html>";
    
    
    Code:
    // Write:
    $fp1 = @fopen ( "sort.htm", "w" );
    fwrite ( $fp1, $sort_header . $sort_table . $sort_footer );
    fclose ( $fp1 );
    
    
     
    gonzotek likes this.
  9. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
  10. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    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 and gonzotek like this.
  11. HomeUser

    HomeUser Active Member

    2,406
    5
    Jan 12, 2003
    A2 Michigan
    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
    Code:
               $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.
    Code:
    $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
     
    Last edited: May 24, 2017
    bshrock and gonzotek like this.
  12. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    Neat! I'll have to figure out how to do a PR now. ;)
     
  13. HomeUser

    HomeUser Active Member

    2,406
    5
    Jan 12, 2003
    A2 Michigan
    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
    Code:
               $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
    Code:
        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");
    
    
     
  14. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    Cool, thanks! I went ahead and merged it ... looks good.

    Although what was the .project file for?
     
  15. HomeUser

    HomeUser Active Member

    2,406
    5
    Jan 12, 2003
    A2 Michigan
    Must be from Eclipse a project was created when I imported the files. I deleted it from the branch.
     
  16. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    I merged in the branch, thanks!
     
  17. HomeUser

    HomeUser Active Member

    2,406
    5
    Jan 12, 2003
    A2 Michigan
    Added groups to each DVR accessible through (Grouped) next to the TiVo's name
    Screen Shot 2017-06-07 at 9.53.30 PM.png

    My Live TNPL
     
  18. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    Can you create a PR so I can add that to my repo?
     
  19. HomeUser

    HomeUser Active Member

    2,406
    5
    Jan 12, 2003
    A2 Michigan
    Done
     
  20. windracer

    windracer joined the 10k club

    11,775
    37
    Jan 3, 2003
    St. Pete, FL
    I see it ... thanks! I hope you don't mind my continuing to tweak your contributions. :)
     

Share This Page