[mythtv] Perl Fix for endtimes.
Patrick Pflaum
mythtv-dev@snowman.net
Tue Jan 7 21:44:14 EST 2003
This is a multi-part message in MIME format.
--------------070201020109070609060207
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Alot of my programs chop off around midnight in the database when they
shouldn't. ( Problem with zap2it and the way XMLTV pulls the data I think )
This perl hack makes the endtime of every program equal the starttime of
the next program. Use it at your own risk, it works for me, but yymv.
Bonus question: why in this script do I update starttime=starttime?
:-)
Pat
use DBI;
$driver = "mysql";
$database = 'mythconverg';
$hostname = 'localhost';
$user = 'mythtv';
$password = 'mythtv';
$dsn = "DBI:$driver:database=$database;host=$hostname";
$dbh = DBI->connect($dsn, $user, $password);
$stmt = "select
chanid,starttime,endtime,title,subtitle,description,category,starttime
from program order by chanid,starttime";
$sth = $dbh->prepare($stmt);
$sth ->execute;
while ( $ref = $sth->fetch() )
{
(
$chanid,$starttime,$endtime,$title,$subtitle,$description,$category,$newet
) = @{$ref} ;
if ( $contig != $starttime && $lastchan == $chanid && $contig)
{
@current = @{$ref};
print "-----------\n";
print "L:" . join (":",@last ) . "\n";
print "C:" . join (":",@current ) . "\n";
$stmt = "update program set endtime = " .
$dbh->quote($newet) ;
$stmt.= ", starttime = starttime ";
$stmt.=" where ";
$stmt.= " chanid = ". $dbh->quote(@last[0]);
$stmt.= " and starttime = ". $dbh->quote(@last[1]);
$stmt.= " and endtime = ". $dbh->quote(@last[2]);
$stmt.= " and title = ". $dbh->quote(@last[3]);
$stmt.= " and subtitle = ". $dbh->quote(@last[4]);
$stmt.= " and description = ". $dbh->quote(@last[5]);
$stmt.= " and category = ". $dbh->quote(@last[6]);
print "$stmt \n";
print "-----------\n";
$result = $dbh->do( $stmt );
print "RESULT: $result \n";
}
@last = @{$ref};
$contig = $endtime;
$lastchan = $chanid;
}
--------------070201020109070609060207
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
<small><tt><br>
<br>
<br>
Alot of my programs chop off around midnight in the database when they
shouldn't. ( Problem with zap2it and the way XMLTV pulls the data I
think )<br>
This perl hack makes the endtime of every program equal the starttime
of the next program. Use it at your own risk, it works for me, but
yymv.<br>
<br>
Bonus <a class="moz-txt-link-freetext" href="question: ">question: </a> why in this script do I update starttime=starttime?
:-) <br>
<br>
<br>
<br>
Pat<br>
<br>
<br>
<br>
<br>
<br>
use DBI;<br>
<br>
$driver = "mysql";<br>
$database = 'mythconverg';<br>
$hostname = 'localhost';<br>
$user = 'mythtv';<br>
$password = 'mythtv';<br>
<br>
$dsn = <a class="moz-txt-link-rfc2396E" href="DBI:$driver:database=$database;host=$hostname">"DBI:$driver:database=$database;host=$hostname"</a>;<br>
<br>
$dbh = DBI->connect($dsn, $user, $password);<br>
<br>
$stmt = "select
chanid,starttime,endtime,title,subtitle,description,category,starttime
from program order by chanid,starttime";<br>
<br>
$sth = $dbh->prepare($stmt);<br>
<br>
$sth ->execute;<br>
<br>
while ( $ref = $sth->fetch() )<br>
{<br>
(
$chanid,$starttime,$endtime,$title,$subtitle,$description,$category,$newet
) = @{$ref} ;<br>
<br>
if ( $contig != $starttime && $lastchan == $chanid
&& $contig)<br>
{<br>
@current = @{$ref};<br>
print "-----------\n";<br>
print "L:" . join (":<a class="moz-txt-link-rfc2396E" href="mailto:,@last).">",@last ) . "</a>\n";<br>
print "C:" . join (":<a class="moz-txt-link-rfc2396E" href="mailto:,@current).">",@current ) . "</a>\n";<br>
$stmt = "update program set endtime = " .
$dbh->quote($newet) ;<br>
$stmt.= ", starttime = starttime ";<br>
$stmt.=" where ";<br>
$stmt.= " chanid = ".
$dbh->quote(@last[0]);<br>
$stmt.= " and starttime = ".
$dbh->quote(@last[1]);<br>
$stmt.= " and endtime = ".
$dbh->quote(@last[2]);<br>
$stmt.= " and title = ".
$dbh->quote(@last[3]);<br>
$stmt.= " and subtitle = ".
$dbh->quote(@last[4]);<br>
$stmt.= " and description = ".
$dbh->quote(@last[5]);<br>
$stmt.= " and category = ".
$dbh->quote(@last[6]);<br>
print "$stmt \n";<br>
print "-----------\n";<br>
$result = $dbh->do( $stmt );<br>
print "RESULT: $result \n";<br>
}<br>
<br>
<br>
@last = @{$ref};<br>
$contig = $endtime;<br>
$lastchan = $chanid;<br>
}<br>
</tt></small><br>
</body>
</html>
--------------070201020109070609060207--
More information about the mythtv-dev
mailing list