[mythtv] tv.com perl script

Webmaaschter at gmx.de Webmaaschter at gmx.de
Tue Mar 14 13:52:20 UTC 2006


Hello,
I made some changes and hope, they can improve your script.
My Series are stored that way:
/Path/to/videofiles/SERIE/SSxEE - NAME.avi

All changes should work with any combination of naming. 

44a45
> use File::Spec;
104a106
>       $inputfile = File::Spec->rel2abs( $inputfile ) ;
110c112,117
<               $filename =~ s/.*\///;
---
>
>               #Convert from Serie/Episode to Serie.Episode (Possible Formats 
for Episode: S00E00, 123 and 00x00)
>               if ( $filename =~ /.*\/.\d[\w\.]*/ ) {
>               $filename =~ s/^.*\/(\w*)\/([\w\.]*)/\1\.\2/;
>               }else{$filename =~ s/.*\///; }
>
226a234,240
>       # Convert " - " to "." as Delimiter
>       if ( $filename =~ / - /) {
>               if ($opt_v) { print "(V1) Show name has \" - \" as 
delimiter\n"; }
>               $filename =~ s/ - /\./g;
>               if ($opt_v) { print "(V1) New show name: $filename\n"; }
>       }
>
233a248,254
>       # Convert 00x00 format to S00E00. format
>       if ( $filename =~ /\.[0-9][0-9][xX][0-9][0-9]\./) {
>               if ($opt_v) { print "(V1) Show name is 00x00 format\n"; }
>               $filename =~ s/\.(\d\d)([xX])(\d\d)/\.S\1E\3\./g;
>               if ($opt_v) { print "(V1) New show name: $filename\n"; }
>       }
>



Peter Kornhuld made this changes because he do not want to update the 
recording-database but the videometadatabase. He assumes the files are 
already in the DB only an update is needed (only works with the first lines 
of the patch above, because the absolute filename is important):

584c602
<               my $i = "insert into recorded (chanid, starttime, endtime, 
title, subtitle, description, category, hostname, autoexpire, recgroup, 
programid, originalairdate, basename, progstart, progend) values ((?), (?), 
(?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?))";
---
>               my $i = "update videometadata set title=(?), plot=(?) where 
filename=(?)";
587c605
<               $sth->execute($chanid, $starttime, $endtime, $showname, 
$title, $plot, $category, $host, $autoexpire, $recgroup, $programid, 
$originalairdate, $inputfile, $starttime, $endtime)
---
>               $sth->execute($title, $plot, $inputfile)
593c611
<               print("  Query params: $chanid, $starttime, $endtime, 
$realname, $title, $plot, $category, $host, $autoexpire, $recgroup, 
$programid, $originalairdate, $inputfile, $starttime, $endtime\n");
---
>               print("  Query params: $title, $plot, $inputfile\n");


Greets 
Christoph Holzbaur

P.s. 
> I'd like to see some mysql error checking to make sure the show hasn't been 
> added already, this is beyond my knowledge at this point.
I did this once with bash, it should be no prob to use the idea in perl
.... i think it was something like that:

TEST=`mysql blablabla -e "SELECT title FROM  recorded WHERE title='$title'"`
if [ $TEST = "" ]
then
  echo "File is not in db"
else
  echo "File is already in db"
fi


More information about the mythtv-dev mailing list