[mythtv] mythweb patch: "movies" page, bugfixes
Grant Taylor
mythtv-dev@snowman.net
Sat, 07 Dec 2002 15:26:13 -0500
The patch below is against mythweb cvs from around 1pm today.
It implements:
- A "movies" page, which lists all movies in the database that start
in the future. There's a little [R] for ones already being
recorded, and an imdb search link for all.
I usually just scan the listings for interesting movies each week.
This makes it much easier to do this.
- The imdb link on the "single" page is presented as a GETted text
link, so that one can use the middle button to open a new
tab/window for imdb reading.
- The every 15 channel listings labels thing had an extra <td>.
It would be really nice if the xmltv schema had some logic to compute
the correct imdb number so we didn't have to search; typically it's
impossible to tell which of mayn hit a film is, since there is no
year, actor, director, etc information in the myth table entry. But
that's another day's bug.
[ For that matter, is there a "movie" bit in xmltv? The thing is just
guessing that shows over 70m are movies! ]
Index: body.php
===================================================================
RCS file: /var/lib/cvs/mythweb/body.php,v
retrieving revision 1.2
diff -u -r1.2 body.php
--- body.php 11 Sep 2002 04:08:52 -0000 1.2
+++ body.php 7 Dec 2002 20:12:42 -0000
@@ -39,6 +39,11 @@
include("listings.php");
break;
+ case "movies":
+
+ include("movies.php");
+ break;
+
case "single":
include("single.php");
Index: functions.php
===================================================================
RCS file: /var/lib/cvs/mythweb/functions.php,v
retrieving revision 1.4
diff -u -r1.4 functions.php
--- functions.php 7 Dec 2002 05:53:00 -0000 1.4
+++ functions.php 7 Dec 2002 20:12:43 -0000
@@ -343,6 +343,36 @@
return $programarray;
}
+# Fetch all listing after a timestamp; used for "movies" etc
+function fetchListings($after)
+{
+ $query = "SELECT channel.chanid, channel.channum, starttime, endtime, title, subtitle, description, category, ((UNIX_TIMESTAMP(endtime) - UNIX_TIMESTAMP(starttime)) / 60 ) as duration FROM program,channel WHERE program.chanid = channel.chanid AND starttime >= " . $after . " ORDER BY starttime;";
+
+
+ $result = mysql_query($query) or die("Gadzooks! I can't open the program table.");
+
+ $i = 0;
+ while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
+ {
+ $myprog = new ProgramInfo;
+ $myprog->title = $line["title"];
+ $myprog->subtitle = $line["subtitle"];
+ $myprog->chanid = $line["chanid"];
+ $myprog->chanstr = $line["channum"];
+ $myprog->startts = $line["starttime"];
+ $myprog->endts = $line["endtime"];
+ $myprog->progType = $line["category"];
+ $myprog->duration = $line["duration"];
+ $myprog->description = $line["description"];
+
+ $listingarray[$i++] = $myprog;
+ }
+
+ mysql_free_result($result);
+
+ return $listingarray;
+}
+
// Functions added by Russell Hatch
// gather info from the allrecord table
Index: listings.php
===================================================================
RCS file: /var/lib/cvs/mythweb/listings.php,v
retrieving revision 1.5
diff -u -r1.5 listings.php
--- listings.php 7 Dec 2002 05:53:00 -0000 1.5
+++ listings.php 7 Dec 2002 20:12:43 -0000
@@ -190,7 +190,7 @@
//
// Left arrow to go back in time
//
- print "<TD><A HREF=\"main.php?mode=listings&timeoffset=$pastOffset#anchor$anchor\"><IMG SRC=\"images/left.gif\" BORDER=\"0\" ALT=\"left\"></A></td>\n";
+ print "<A HREF=\"main.php?mode=listings&timeoffset=$pastOffset#anchor$anchor\"><IMG SRC=\"images/left.gif\" BORDER=\"0\" ALT=\"left\"></A></td>\n";
for ($timeslot = 0; $timeslot < $timeSlots; $timeslot += 1) {
$theTime = $timearray[$timeslot];
Index: menustrip.php
===================================================================
RCS file: /var/lib/cvs/mythweb/menustrip.php,v
retrieving revision 1.4
diff -u -r1.4 menustrip.php
--- menustrip.php 27 Sep 2002 20:06:20 -0000 1.4
+++ menustrip.php 7 Dec 2002 20:12:43 -0000
@@ -24,6 +24,7 @@
print("\t\t\t\t\t<TD ALIGN=\"left\">\n");
print("\t\t\t\t\t\t<FONT FACE=\"$main_fontface\" SIZE=\"$main_fontsize\" COLOR=\"$menu_fg_colour\"> Menu: </FONT>");
print("<A HREF=\"main.php?mode=listings\"><FONT FACE=\"$main_fontface\" SIZE=\"$main_fontsize\" COLOR=\"$menu_fg_colour\"><B>Listings</B></FONT></A> | ");
+ print("<A HREF=\"main.php?mode=movies\"><FONT FACE=\"$main_fontface\" SIZE=\"$main_fontsize\" COLOR=\"$menu_fg_colour\"><B>Movies</B></FONT></A> | ");
print("<A HREF=\"main.php?mode=favourites\"><FONT FACE=\"$main_fontface\" SIZE=\"$main_fontsize\" COLOR=\"$menu_fg_colour\"><B>Favourites</B></FONT></A> | ");
print("<A HREF=\"main.php?mode=recordings\"><FONT FACE=\"$main_fontface\" SIZE=\"$main_fontsize\" COLOR=\"$menu_fg_colour\"><B>Recordings</B></FONT></A> | ");
print("<A HREF=\"main.php?mode=conflicts\"><FONT FACE=\"$main_fontface\" SIZE=\"$main_fontsize\" COLOR=\"$menu_fg_colour\"><B>Fix Conflicts</B></FONT></A> | ");
Index: single.php
===================================================================
RCS file: /var/lib/cvs/mythweb/single.php,v
retrieving revision 1.5
diff -u -r1.5 single.php
--- single.php 7 Dec 2002 05:53:00 -0000 1.5
+++ single.php 7 Dec 2002 20:12:43 -0000
@@ -107,21 +107,21 @@
print("<TABLE WIDTH=\"100%\" BGCOLOR=\"$list_bg_colour\" CELLSPACING=\"10\" CELLPADDING=\"7\"><TR><TD>");
print("<CENTER>");
print("<TABLE BGCOLOR=\"$list_bg_colour\" CELLSPACING=\"5\" CELLPADDING=\"5\">");
- print("<TR VALIGN=\"TOP\"><TD>Program:</TD><TD BGCOLOR=\"$list_fg_colour\">$aRow[3] (Click for <A HREF=\"http://www.google.com/search?q=$aRow[3]\">Google Search</A>)</TD>");
+ print("<TR VALIGN=\"TOP\"><TD>Program:</TD><TD BGCOLOR=\"$list_fg_colour\">$aRow[3] ");
+
//
// If it's a movie, add an IMDB button
//
if(smellsLikeMovie($aRow[7], $aRow[6]))
{
- print("<TD BGCOLOR=\"$list_bg_colour\"><CENTER>");
- print("<FORM ACTION=\"http://www.imdb.com/Find\" method=\"post\">");
- print("<INPUT TYPE=\"HIDDEN\" NAME=\"select\" VALUE=\"Titles\">");
- print("<INPUT TYPE=\"HIDDEN\" NAME=\"for\" VALUE=\"$aRow[3]\">");
- print("<INPUT TYPE=\"SUBMIT\" NAME=\"Go\" VALUE=\"Search IMDB\">");
- print("</FORM>");
- print("</CENTER></TD>");
- }
+ print("(<a href=\"http://www.imdb.com/Find?select=Titles&for="
+ . urlencode($aRow[3]) . "\">IMDB Search</a>)");
+ } else {
+ print("(<A HREF=\"http://www.google.com/search?q=$aRow[3]\">Google Search</A>)");
+ }
+ print "</td>";
+
if(strlen($aRow[6]) > 0) print("</TR><TR VALIGN=\"TOP\"><TD>Category:</TD><TD BGCOLOR=\"$list_fg_colour\">$aRow[6]</TD></TR>");
if(strlen($aRow[4]) > 0) print("<TR VALIGN=\"TOP\"><TD>Episode:</TD><TD BGCOLOR=\"$list_fg_colour\">$aRow[4]</TD></TR>");
print("<TR VALIGN=\"TOP\"><TD>Channel:</TD><TD BGCOLOR=\"$list_fg_colour\">$aRow[10]</TD></TR>");
--- /dev/null Sun Mar 24 15:40:39 2002
+++ movies.php Sat Dec 7 15:06:16 2002
@@ -0,0 +1,82 @@
+<?php
+
+
+ //
+ // This file is part of MythWeb,
+ // a php-based interface into MythTV.
+ //
+ // (c) 2002 by Thor Sigvaldason and Isaac Richards
+ // MythWeb is distributed under the
+ // GNU GENERAL PUBLIC LICENSE version 2
+ // (see http://www.gnu.org)
+ //
+
+
+//
+// listings.php is the default mode that
+// shows current listings.
+//
+
+$sqlstarttime = date('YmdHis');
+
+//
+// Build some data structures
+// (channels, programs, etc.)
+//
+$timearray = setupTimes($sqlstarttime, $timeSlots);
+$channelarray = setupChannels();
+$recordArray = setupRecordings();
+$listingarray = fetchListings($sqlstarttime);
+
+
+print "<dl>\n";
+
+$pindex = 0;
+while ($proginfo = $listingarray[$pindex]) {
+ if ($proginfo == null) {
+ continue;
+ }
+
+ $movie = 0;
+ $recording = 0;
+
+ # Movie?
+ if(smellsLikeMovie($proginfo->duration, $proginfo->progType) && $proginfo->title != "Saturday Night Live") {
+ $movie = 1;
+ }
+
+ # Recording?
+ $recordArrayIndex = 0;
+ while($aRecord = $recordArray[$recordArrayIndex]) {
+ if($aRecord->chanid == $proginfo->chanid &&
+ $aRecord->starttime == $proginfo->startts)
+ {
+ $recording = 1;
+ }
+ $recordArrayIndex++;
+ }
+ if(isInAlwaysRecord($proginfo->title) ||
+ isInTimeslotRecord($proginfo->chanid, $proginfo->startts, $proginfo->endts, $proginfo->title))
+ {
+ $recording = 1;
+ }
+
+ if ($movie) {
+ print " <dt>";
+ if ($recording) {
+ print " <font color=\"#ff0000\">[R]</font>";
+ }
+ print "<a href=\"main.php?mode=single&channel=$proginfo->chanid&starttime=$proginfo->startts&endtime=$proginfo->endts\">$proginfo->title</a>";
+ if ($proginfo->subtitle) {
+ print ": $proginfo->subtitle";
+ }
+ print "\n <dd>$proginfo->description";
+ print(" (<a href=\"http://www.imdb.com/Find?select=Titles&for=" . urlencode($proginfo->title) . "\">IMDB</a>)");
+ }
+
+ $pindex++;
+}
+
+print "</dl>\n";
+
+?>
--
Grant Taylor - gtaylor<at>picante.com - http://www.picante.com/~gtaylor/
Linux Printing Website and HOWTO: http://www.linuxprinting.org/