Index: trunk/install/perl/addatq.pl =================================================================== --- trunk/install/perl/addatq.pl (リビジョン 94) +++ trunk/install/perl/addatq.pl (リビジョン 1) @@ -16,5 +16,4 @@ use DBI; use DBD::Pg; -use DBD::SQLite; use Schedule::At; use Time::Local; @@ -22,5 +21,5 @@ $path = $0; $path =~ s/addatq.pl$//i; -if ($path ne "./"){ +if ($pwd ne "./"){ push( @INC, "$path"); } @@ -39,13 +38,15 @@ #DB検索(TIDとStationIDからPIDへ) -$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; + $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 ($station == 0){ - $sth = $dbh->prepare($stmt{'addatq.1'}); - $sth->execute($tid); + $DBQuery = "SELECT count(*) FROM foltia_tvrecord WHERE tid = '$tid' "; }else{ - $sth = $dbh->prepare($stmt{'addatq.2'}); - $sth->execute($tid, $station); + $DBQuery = "SELECT count(*) FROM foltia_tvrecord WHERE tid = '$tid' AND stationid = '$station' "; } + $sth = $dbh->prepare($DBQuery); + $sth->execute(); @titlecount = $sth->fetchrow_array; #件数数える @@ -53,7 +54,8 @@ #2以上だったら if ($titlecount[0] >= 2){ - #全局録りが含まれているか調べる - $kth = $dbh->prepare($stmt{'addatq.3'}); - $kth->execute($tid); + #全曲取りが含まれているか調べる + $DBQuery = "SELECT count(*) FROM foltia_tvrecord WHERE tid = '$tid' AND stationid ='0' "; + $kth = $dbh->prepare($DBQuery); + $kth->execute(); @reservecounts = $kth->fetchrow_array; @@ -61,10 +63,10 @@ if($tid == 0){ #今回の引き数がSID 0だったら - #全局録りだけ予約 -# &writelog("addatq DEBUG; ALL STATION RESERVE. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); + #全局取りだけ予約 +# &writelog("addatq DEBUG; ALL STATION RESERVE. TID=$tid SID=$station $titlecount[0] match:$DBQuery"); &addcue; }else{ #ほかの全局録画addatqが予約入れてくれるからなにもしない -# &writelog("addatq DEBUG; SKIP OPERSTION. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); +# &writelog("addatq DEBUG; SKIP OPERSTION. TID=$tid SID=$station $titlecount[0] match:$DBQuery"); exit; }#end if ふくまれていたら @@ -73,5 +75,5 @@ &addcue; }else{ - &writelog("addatq error; reserve impossible . TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); +&writelog("addatq error; reserve impossible . TID=$tid SID=$station $titlecount[0] match:$DBQuery"); } @@ -80,5 +82,5 @@ # & addcue; # }else{ -#&writelog("addatq error record TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); +#&writelog("addatq error record TID=$tid SID=$station $titlecount[0] match:$DBQuery"); #} @@ -86,30 +88,33 @@ if ($station == 0){ - $sth = $dbh->prepare($stmt{'addatq.addcue.1'}); - $sth->execute($tid); + $DBQuery = "SELECT * FROM foltia_tvrecord WHERE tid = '$tid' "; }else{ - $sth = $dbh->prepare($stmt{'addatq.addcue.2'}); - $sth->execute($tid, $station); + $DBQuery = "SELECT * FROM foltia_tvrecord WHERE tid = '$tid' AND stationid = '$station' "; } + $sth = $dbh->prepare($DBQuery); +$sth->execute(); @titlecount= $sth->fetchrow_array; $bitrate = $titlecount[2];#ビットレート取得 #PID抽出 - $now = &epoch2foldate(time()); - $twodaysafter = &epoch2foldate(time() + (60 * 60 * 24 * 2)); +$now = &epoch2foldate(`date +%s`); +$twodaysafter = &epoch2foldate(`date +%s` + (60 * 60 * 24 * 2)); #キュー入れは直近2日後まで if ($station == 0 ){ - $sth = $dbh->prepare($stmt{'addatq.addcue.3'}); - $sth->execute($tid, $now, $twodaysafter); + $DBQuery = " +SELECT * from foltia_subtitle WHERE tid = '$tid' AND startdatetime > '$now' AND startdatetime < '$twodaysafter' "; }else{ + $DBQuery = " +SELECT * from foltia_subtitle WHERE tid = '$tid' AND stationid = '$station' AND startdatetime > '$now' AND startdatetime < '$twodaysafter' "; #stationIDからrecch - $stationh = $dbh->prepare($stmt{'addatq.addcue.4'}); - $stationh->execute($station); +$getrecchquery="SELECT stationid , stationrecch FROM foltia_station where stationid = '$station' "; + $stationh = $dbh->prepare($getrecchquery); + $stationh->execute(); @stationl = $stationh->fetchrow_array; $recch = $stationl[1]; +} - $sth = $dbh->prepare($stmt{'addatq.addcue.5'}); - $sth->execute($tid, $station, $now, $twodaysafter); - } + $sth = $dbh->prepare($DBQuery); + $sth->execute(); while (($pid , @@ -126,6 +131,7 @@ if ($station == 0 ){ #stationIDからrecch - $stationh = $dbh->prepare($stmt{'addatq.addcue.6'}); - $stationh->execute($stationid); +$getrecchquery="SELECT stationid , stationrecch FROM foltia_station where stationid = '$stationid' "; + $stationh = $dbh->prepare($getrecchquery); + $stationh->execute(); @stationl = $stationh->fetchrow_array; $recch = $stationl[1];