[mythtv] [PATCH] Add recording length to MythWeb
mythtv at slackassbastards.org
mythtv at slackassbastards.org
Sun Apr 6 07:28:34 EDT 2003
Attached are patches for MythWeb that will display the recording length for programs under the recorded programs list. Total recording time for all programs is also displayed.
On a related subject, does anyone else have problems with the filesizes being displayed properly in the recorded programs list in MythWeb? On some programs I get negative file sizes. I've checked and the problem appears to come from the results that MythWeb gets from the backend when doing "QUERY_RECORDINGS Delete". It's very strange as the file sizes are displayed properly in Mythfrontend.
-------------- next part --------------
Index: recorded.php
===================================================================
RCS file: /var/lib/cvs/mythweb/recorded.php,v
retrieving revision 1.2
diff -u -r1.2 recorded.php
--- recorded.php 21 Mar 2003 17:46:18 -0000 1.2
+++ recorded.php 6 Apr 2003 11:00:24 -0000
@@ -49,7 +49,7 @@
print "<TR><TD BGCOLOR=\"$list_fg_colour\">" . $recs['offset'][0] . " Recorded Programs</TD></TR><TR><TD>";
print "<TABLE BGCOLOR=\"$list_bg_colour\" CELLSPACING=\"5\" CELLPADDING=\"5\">";
-print "<TH>Title</TH><TH>Station</TH><TH>Air Date</TH><TH>Description</TH><TH>Size</TH><TH>Action</TH></TH>";
+print "<TH>Title</TH><TH>Station</TH><TH>Air Date</TH><TH>Length</TH><TH>Description</TH><TH>Size</TH><TH>Action</TH></TH>";
foreach($recs as $t => $v)
{
@@ -60,8 +60,15 @@
print "<TR VALIGN=\"TOP\"><TD BGCOLOR=\"$list_fg_colour\">" . $recs[$t][0] . "</TD>";
print "<TD BGCOLOR=\"$list_fg_colour\">" . $recs[$t][6] . "</TD>";
print "<TD BGCOLOR=\"$list_fg_colour\">" . $recs[$t][11] . "</TD>";
- print "<TD BGCOLOR=\"$list_fg_colour\">" . $recs[$t][2] . "</TD>";
+ list($dow,$mon,$dom,$time,$year) = explode(" ",$recs[$t][12]); // Get end time
+ $prog_end = strtotime("$dom $mon $year $time");
+ list($dow,$mon,$dom,$time,$year) = explode(" ",$recs[$t][11]); // Get start time
+ $prog_begin = strtotime("$dom $mon $year $time");
+ $prog_length[$t] = ($prog_end - $prog_begin); // Get the difference and dump results in array
+ print "<TD BGCOLOR=\"$list_fg_colour\">" . my_time($prog_length[$t]) . "</TD>";
+
+ print "<TD BGCOLOR=\"$list_fg_colour\">" . $recs[$t][2] . "</TD>";
print "<TD BGCOLOR=\"$list_fg_colour\">" . my_filesize($recs[$t][10]) ."</TD>";
print "<TD><input type=\"submit\" name=\"deletebutton\" value=\"Delete\"></TD></form>";
print "</TR>\n";
@@ -69,5 +76,12 @@
print "</table><br><br>";
print "</td></tr>";
+// Get total recording time
+$total_length = 0;
+foreach($prog_length as $t => $v) {
+ $total_length = $total_length + $prog_length[$t];
+}
+
+print "<TR><TD BGCOLOR=\"$list_fg_colour\">Total recording time: " . my_time($total_length) . "</TD></TR>\n";
print "<TR><TD BGCOLOR=\"$list_fg_colour\">$df</TD></TR>\n";
print "$recmesg\n";
-------------- next part --------------
Index: functions.php
===================================================================
RCS file: /var/lib/cvs/mythweb/functions.php,v
retrieving revision 1.18
diff -u -r1.18 functions.php
--- functions.php 2 Apr 2003 19:49:23 -0000 1.18
+++ functions.php 6 Apr 2003 11:00:24 -0000
@@ -839,7 +839,20 @@
mysql_free_result($inputresult);
return $idStatus;
}
-
+
+// Adapted from my_filesize (see below)
+function my_time($time) {
+ $min = 60; // Minute
+ $hr = 60 * $min; // Hour
+ if($time < $hr) {
+ return round($time/$min,1)." mins";
+ } else if($time > $hr) {
+ return round($time/$hr,1)." hrs";
+ } else if($time = $hr) {
+ return "1 hr";
+ }
+}
+
// JS: adapted from php.net: sponger 10-Jun-2002 12:28
function my_filesize($size) {
// Setup some common file size measurements.
More information about the mythtv-dev
mailing list