Index: trunk/install/perl/singletranscode.pl =================================================================== --- trunk/install/perl/singletranscode.pl (リビジョン 94) +++ trunk/install/perl/singletranscode.pl (リビジョン 1) @@ -28,5 +28,4 @@ use DBI; use DBD::Pg; -use DBD::SQLite; use Schedule::At; use Time::Local; @@ -35,5 +34,5 @@ $path = $0; $path =~ s/singletranscode.pl$//i; -if ($path ne "./"){ +if ($pwd ne "./"){ push( @INC, "$path"); } @@ -64,11 +63,15 @@ #PSPトラコン必要かどうか -$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; + my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", + + $DBDriv,$DBName,$DBHost,$DBPort); + $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; if ($ARGV[1] != ""){ $pid = $ARGV[1] ; }else{ - $sth = $dbh->prepare($stmt{'singletranscode.1'}); - $sth->execute($ARGV[0]); +$DBQuery = "SELECT pid FROM foltia_subtitle WHERE m2pfilename = '$ARGV[0]' "; + $sth = $dbh->prepare($DBQuery); + $sth->execute(); @pidarray = $sth->fetchrow_array; unless ($pidarray[0] == "" ){ @@ -83,11 +86,13 @@ # 追加部分 -$sth = $dbh->prepare($stmt{'singletranscode.2'}); -$sth->execute($tid, $countno); +$query = "SELECT count(*) FROM foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; + $sth = $dbh->prepare($query); + $sth->execute(); @subticount= $sth->fetchrow_array; unless ($subticount[0] >= 1){ - $sth = $dbh->prepare($stmt{'singletranscode.3'}); - $sth->execute($tid); +$query = "SELECT count(*) FROM foltia_subtitle WHERE tid = '$tid' "; + $sth = $dbh->prepare($query); + $sth->execute(); @subticount= $sth->fetchrow_array; @@ -115,6 +120,7 @@ # PSP ------------------------------------------------------ #PSPトラコン必要かどうか -$sth = $dbh->prepare($stmt{'singletranscode.4'}); -$sth->execute($tid); +$DBQuery = "SELECT psp,aspect,title FROM foltia_program WHERE tid = '$tid' "; + $sth = $dbh->prepare($DBQuery); + $sth->execute(); @psptrcn= $sth->fetchrow_array; if ($psptrcn[0] == 1 ){#トラコン番組 @@ -221,5 +227,5 @@ my $newestmp4filename = `cd $pspdirname ; ls -t *.MP4 | head -1`; if ($newestmp4filename =~ /M4V$tid/){ - $nowcountno = $' ;#' + $nowcountno = $' ; $nowcountno++; $pspfilnameft = sprintf("%02d",$nowcountno); @@ -255,6 +261,7 @@ #最適化 - $sth = $dbh->prepare($stmt{'singletranscode.5'}); - $sth->execute($tid, $countno); +$DBQuery = "SELECT subtitle FROM foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; + $sth = $dbh->prepare($DBQuery); + $sth->execute(); @programtitle = $sth->fetchrow_array; @@ -278,5 +285,5 @@ if (-e "$pspdirname/M4V".$pspfilname.".THM"){ - $timestamp = strftime("%Y%m%d-%H%M%S", localtime); +$timestamp =`date "+%Y%m%d-%H%M%S"`; chomp $timestamp; system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V".$pspfilname.".THM.".$timestamp.".THM"); @@ -290,16 +297,26 @@ system("rm -rf $pspdirname/0000000*.jpg "); + + + # MP4ファイル名をPIDレコードに書き込み unless ($pid eq ""){ - $sth = $dbh->prepare($stmt{'singletranscode.6'}); - $sth->execute("M4V$pspfilname.MP4", $pid); - &writelog("singletranscode UPDATEsubtitleDB $stmt{'singletranscode.6'}"); + $DBQuery = " + UPDATE foltia_subtitle + SET PSPfilename = 'M4V$pspfilname.MP4' + WHERE pid = '$pid' "; + $sth = $dbh->prepare($DBQuery); + $sth->execute(); +&writelog("singletranscode UPDATEsubtitleDB $DBQuery"); }else{ &writelog("singletranscode PID not found"); } # MP4ファイル名をfoltia_mp4files挿入 - $sth = $dbh->prepare($stmt{'singletranscode.7'}); - $sth->execute($tid, "M4V$pspfilname.MP4"); - &writelog("singletranscode UPDATEmp4DB $stmt{'singletranscode.7'}"); + $DBQuery = "insert into foltia_mp4files values ('$tid','M4V$pspfilname.MP4') "; + $sth = $dbh->prepare($DBQuery); + $sth->execute(); +&writelog("singletranscode UPDATEmp4DB $DBQuery"); }#PSPトラコンあり + +