Index: trunk/install/perl/foltialib.pl =================================================================== --- trunk/install/perl/foltialib.pl (リビジョン 124) +++ trunk/install/perl/foltialib.pl (リビジョン 1) @@ -4,5 +4,5 @@ $path = $0; $path =~ s/foltialib.pl$//i; -if ($path ne "./"){ +if ($pwd ne "./"){ push( @INC, "$path"); } @@ -13,37 +13,18 @@ use DBI; use DBD::Pg; -use DBD::SQLite; -use POSIX qw(strftime); - -$DSN=$main::DSN; + + + $DBDriv=$main::DBDriv; + $DBHost=$main::DBHost; + $DBPort=$main::DBPort; + $DBName=$main::DBName; $DBUser=$main::DBUser; $DBPass=""; - - $FILESTATUSRESERVINGLONG = 10; - $FILESTATUSRESERVINGSHORT = 20; - $FILESTATUSRECORDING = 30; - $FILESTATUSRECTSSPLITTING = 40; - $FILESTATUSRECEND = 50; - $FILESTATUSWAITINGCAPTURE = 55; - $FILESTATUSCAPTURE = 60; - $FILESTATUSCAPEND = 70; - $FILESTATUSTHMCREATE = 72; - $FILESTATUSWAITINGTRANSCODE = 80; - $FILESTATUSTRANSCODETSSPLITTING = 90; - $FILESTATUSTRANSCODEFFMPEG = 100; - $FILESTATUSTRANSCODEWAVE = 110; - $FILESTATUSTRANSCODEAAC = 120; - $FILESTATUSTRANSCODEMP4BOX = 130; - $FILESTATUSTRANSCODEATOM = 140; - $FILESTATUSTRANSCODECOMPLETE = 150; - $FILESTATUSALLCOMPLETE = 200; - - #------------------------------ sub writelog{ my $messages = $_[0]; - my $timestump = strftime("%Y/%m/%d_%H:%M:%S", localtime); +my $timestump = `date +%Y/%m/%d_%H:%M:%S`; chomp($timestump); if ($debugmode == 1){ @@ -144,8 +125,9 @@ my $stationname = $_[0] ; my $stationid ; +my $DBQuery = "SELECT count(*) FROM foltia_station WHERE stationname = '$item{ChName}'"; my $sth; - $sth = $dbh->prepare($stmt{'foltialib.getstationid.1'}); - $sth->execute($item{'ChName'}); + $sth = $dbh->prepare($DBQuery); + $sth->execute(); my @stationcount; @stationcount= $sth->fetchrow_array; @@ -153,6 +135,7 @@ if ($stationcount[0] == 1){ #チャンネルID取得 - $sth = $dbh->prepare($stmt{'foltialib.getstationid.2'}); - $sth->execute($item{'ChName'}); +$DBQuery = "SELECT stationid,stationname FROM foltia_station WHERE stationname = '$item{ChName}'"; + $sth = $dbh->prepare($DBQuery); + $sth->execute(); @stationinfo= $sth->fetchrow_array; #局ID @@ -162,5 +145,6 @@ }elsif($stationcount[0] == 0){ #新規登録 - $sth = $dbh->prepare($stmt{'foltialib.getstationid.3'}); +$DBQuery = "SELECT max(stationid) FROM foltia_station"; + $sth = $dbh->prepare($DBQuery); $sth->execute(); @stationinfo= $sth->fetchrow_array; @@ -169,8 +153,10 @@ ##$DBQuery = "insert into foltia_station values ('$stationid' ,'$item{ChName}','0','','','','','','')"; #新規局追加時は非受信局をデフォルトに - $sth = $dbh->prepare($stmt{'foltialib.getstationid.4'}); - $sth->execute($stationid, $item{'ChName'}, -10); +$DBQuery = "insert into foltia_station (stationid , stationname ,stationrecch ) values ('$stationid' ,'$item{ChName}','-1')"; + + $sth = $dbh->prepare($DBQuery); + $sth->execute(); #print "Add station;$DBQuery\n"; - &writelog("foltialib Add station;$stmt{'foltialib.getstationid.4'}"); +&writelog("foltialib Add station;$DBQuery"); }else{ @@ -241,219 +227,4 @@ -sub getphpstyleconfig{ -my $key = $_[0]; -my $phpconfigpath = ""; -my $configline = ""; - # read -if (-e "$phptoolpath/php/foltia_config2.php"){ - $phpconfigpath = "$phptoolpath/php/foltia_config2.php"; -}elsif(-e "$toolpath/php/foltia_config2.php"){ - $phpconfigpath = "$toolpath/php/foltia_config2.php"; -}else{ - $phpconfigpath = `locate foltia_config2.php | head -1`; - chomp($phpconfigpath); -} - - -if (-r $phpconfigpath ){ -open (CONFIG ,"$phpconfigpath") || die "File canot read.$!"; -while(){ - if (/$key/){ - $configline = $_; - $configline =~ s/\/\/.*$//; - $configline =~ s/\/\*.*\*\///; - }else{ - } -} -close(CONFIG); -}#end if -r $phpconfigpath -return ($configline); -}#end sub getphpstyleconfig - - -sub getpidbympegfilename { -#引き数:m2pfilename -#戻り値:PID -my $m2pfilename = $_[0] ; -if ($m2pfilename eq ""){ - return 0 ; -} - -my $sth; - $sth = $dbh->prepare($stmt{'foltialib.getpidbympegfilename.1'}); - $sth->execute($m2pfilename); -#print "$stmt{'foltialib.getpidbympegfilename.1'}\n"; -my @pidinfo = $sth->fetchrow_array; -my $pid = $pidinfo[0]; - -if ($pid eq ""){ - return 0 ; -}else{ - return $pid; -} -}#end sub getpidbympegfilename - -sub changefilestatus { -#引き数:PID,updatestatus -#戻り値:エラーコード -my $pid = $_[0] ; -my $updatestatus = $_[1]; -if (($pid eq "" ) || ($updatestatus eq "")){ - return 0 ; -} - -if ($updatestatus > 0 ){ -my $sth; - $sth = $dbh->prepare($stmt{'foltialib.changefilestatus.1'}); - $sth->execute($updatestatus, $pid); -return 1; -}else{ - &writelog("foltialib changefilestatus ERR Sttus invalid:$updatestatus"); - return 0 ; -} -}# end sub changefilestatus - - -sub getfilestatus { -#引き数:PID -#戻り値:ステータス - -#10:予約中(5分以上先) -#20:予約中(5分以内) -#30:録画中 -#40:TSSplit中 -#50:MPEG2録画終了 -#55 静止画キャプチャ待 -#60:静止画キャプ中 -#70:静止画キャプ終了 -#72:サムネイル作成済み(.THM) -#80:トラコン待 -#90:トラコン中:TSsplit -#100:トラコン中:H264 -#110:トラコン中:WAVE -#120:トラコン中:AAC -#130:トラコン中:MP4Box -#140:トラコン中:ATOM -#150:トラコン完了 -#200:全完了 -my $pid = $_[0] ; -if ($pid eq "" ){ - return 0 ; -} - -my $sth; - $sth = $dbh->prepare($stmt{'foltialib.getfilestatus.1'}); - $sth->execute($pid); - -my @statusinfo = $sth->fetchrow_array; -my $status = $statusinfo[0]; - -if ($status eq ""){ - return 0 ; -}else{ - return $status; -} - - -}# end sub getfilestatus - - -sub makemp4dir{ -#TIDが100以上の3桁の場合はそのまま -my $pspfilnamehd = $_[0]; -my $tid = $_[0]; -my $pspdirname = "$tid.localized/"; -$pspdirname = $recfolderpath."/".$pspdirname; - -#なければ作る -unless (-e $pspdirname ){ - system("$toolpath/perl/mklocalizeddir.pl $tid"); - #&writelog("recwrap mkdir $pspdirname"); -} -$pspdirname = "$tid.localized/mp4/"; -$pspdirname = $recfolderpath."/".$pspdirname; -#なければ作る -unless (-e $pspdirname ){ - mkdir $pspdirname ,0777; - #&writelog("recwrap mkdir $pspdirname"); -} -return ("$pspdirname"); -}#endsub makemp4dir - -sub pid2sid{ -#番組IDからStation IDを取得 -my $pid = $_[0]; -my $sth; - $sth = $dbh->prepare($stmt{'foltialib.pid2sid.1'}); - $sth->execute($pid); -my @statusinfo = $sth->fetchrow_array; -my $sid = $statusinfo[0]; - -if ($sid eq ""){ - return 0 ; -}else{ - return $sid; -} - -}#end sub pid2sid - - -sub mp4filename2tid{ -#MPEG4ファイル名からTIDを得る -my $mp4filename = $_[0]; - -my $sth; - $sth = $dbh->prepare($stmt{'foltialib.mp4filename2tid.1'}); - $sth->execute($mp4filename); -my @statusinfo = $sth->fetchrow_array; -my $tid = $statusinfo[0]; - -if ($tid eq ""){ - return 0 ; -}else{ - return $tid; -} -}#end sub mp4filename2tid - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1;