[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.&nbsp;&nbsp; Use it at your own risk, it works for me, but
yymv.<br>
<br>
Bonus <a class="moz-txt-link-freetext" href="question:&nbsp;">question:&nbsp;</a> why in this script do I update starttime=starttime?&nbsp;&nbsp;
:-)&nbsp;&nbsp; <br>
<br>
<br>
<br>
Pat<br>
<br>
<br>
<br>
<br>
<br>
use DBI;<br>
<br>
&nbsp; $driver = "mysql";<br>
&nbsp; $database = 'mythconverg';<br>
&nbsp; $hostname = 'localhost';<br>
&nbsp; $user = 'mythtv';<br>
&nbsp; $password = 'mythtv';<br>
<br>
&nbsp; $dsn = <a class="moz-txt-link-rfc2396E" href="DBI:$driver:database=$database;host=$hostname">"DBI:$driver:database=$database;host=$hostname"</a>;<br>
<br>
&nbsp; $dbh = DBI-&gt;connect($dsn, $user, $password);<br>
<br>
&nbsp; $stmt = "select
chanid,starttime,endtime,title,subtitle,description,category,starttime
from program order by chanid,starttime";<br>
<br>
&nbsp; $sth = $dbh-&gt;prepare($stmt);<br>
<br>
&nbsp; $sth -&gt;execute;<br>
<br>
&nbsp; while ( $ref = $sth-&gt;fetch() )<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (
$chanid,$starttime,$endtime,$title,$subtitle,$description,$category,$newet
) = @{$ref} ;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( $contig != $starttime &amp;&amp; $lastchan == $chanid&nbsp;
&amp;&amp; $contig)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @current = @{$ref};<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "-----------\n";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "L:" . join (":<a class="moz-txt-link-rfc2396E" href="mailto:,@last).">",@last ) . "</a>\n";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "C:" . join (":<a class="moz-txt-link-rfc2396E" href="mailto:,@current).">",@current ) . "</a>\n";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt = "update program set endtime = " .
$dbh-&gt;quote($newet) ;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= ", starttime = starttime ";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.=" where ";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= "&nbsp;&nbsp;&nbsp;&nbsp; chanid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = ".
$dbh-&gt;quote(@last[0]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= " and starttime&nbsp;&nbsp;&nbsp; = ".
$dbh-&gt;quote(@last[1]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= " and endtime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = ".
$dbh-&gt;quote(@last[2]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= " and title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = ".
$dbh-&gt;quote(@last[3]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= " and subtitle&nbsp;&nbsp;&nbsp;&nbsp; = ".
$dbh-&gt;quote(@last[4]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= " and description&nbsp; = ".
$dbh-&gt;quote(@last[5]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $stmt.= " and category&nbsp;&nbsp;&nbsp;&nbsp; = ".
$dbh-&gt;quote(@last[6]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "$stmt \n";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "-----------\n";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $result = $dbh-&gt;do( $stmt );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "RESULT: $result \n";<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @last = @{$ref};<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $contig = $endtime;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $lastchan = $chanid;<br>
&nbsp; }<br>
</tt></small><br>
</body>
</html>

--------------070201020109070609060207--




More information about the mythtv-dev mailing list