チェンジセット 94: trunk/install/perl/addatq.pl

差分発生行の前後
無視リスト:
コミット日時:
2010/02/28 22:28:26 (14 年前)
コミッタ:
sorshi
ログメッセージ:

SQLite採用

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • trunk/install/perl/addatq.pl

    r1 r94  
    1616use DBI; 
    1717use DBD::Pg; 
     18use DBD::SQLite; 
    1819use Schedule::At; 
    1920use Time::Local; 
     
    2122$path = $0; 
    2223$path =~ s/addatq.pl$//i; 
    23 if ($pwd ne "./"){ 
     24if ($path ne "./"){ 
    2425push( @INC, "$path"); 
    2526} 
     
    3839 
    3940#DB検索(TIDとStationIDからPIDへ) 
    40  $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    41                 $DBDriv,$DBName,$DBHost,$DBPort); 
    42          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     41$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    4342 
    4443if ($station == 0){ 
    45         $DBQuery =  "SELECT count(*) FROM  foltia_tvrecord WHERE tid = '$tid'  "; 
     44    $sth = $dbh->prepare($stmt{'addatq.1'}); 
     45    $sth->execute($tid); 
    4646}else{ 
    47         $DBQuery =  "SELECT count(*) FROM  foltia_tvrecord WHERE tid = '$tid' AND stationid  = '$station' "; 
     47    $sth = $dbh->prepare($stmt{'addatq.2'}); 
     48    $sth->execute($tid, $station); 
    4849} 
    49          $sth = $dbh->prepare($DBQuery); 
    50         $sth->execute(); 
    5150 @titlecount = $sth->fetchrow_array; 
    5251#件数数える 
     
    5453#2以上だったら 
    5554if ($titlecount[0]  >= 2){ 
    56         #全曲取りが含まれているか調べる 
    57         $DBQuery =  "SELECT count(*) FROM  foltia_tvrecord WHERE tid = '$tid'  AND  stationid  ='0' "; 
    58         $kth = $dbh->prepare($DBQuery); 
    59         $kth->execute(); 
     55    #全局録りが含まれているか調べる 
     56    $kth = $dbh->prepare($stmt{'addatq.3'}); 
     57    $kth->execute($tid); 
    6058        @reservecounts = $kth->fetchrow_array; 
    6159 
     
    6361                if($tid == 0){ 
    6462                #今回の引き数がSID 0だったら 
    65                #全局取りだけ予約 
    66 #               &writelog("addatq  DEBUG; ALL STATION RESERVE. TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     63            #全局録りだけ予約 
     64#               &writelog("addatq  DEBUG; ALL STATION RESERVE. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    6765                &addcue; 
    6866                }else{ 
    6967                #ほかの全局録画addatqが予約入れてくれるからなにもしない 
    70 #               &writelog("addatq  DEBUG; SKIP OPERSTION. TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     68#               &writelog("addatq  DEBUG; SKIP OPERSTION. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    7169                exit; 
    7270                }#end if ふくまれていたら 
     
    7573                &addcue; 
    7674}else{ 
    77 &writelog("addatq  error; reserve impossible . TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     75    &writelog("addatq  error; reserve impossible . TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    7876} 
    7977 
     
    8280#       & addcue; 
    8381# }else{ 
    84 #&writelog("addatq  error record TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     82#&writelog("addatq  error record TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    8583#} 
    8684 
     
    8886 
    8987if ($station == 0){ 
    90         $DBQuery =  "SELECT * FROM  foltia_tvrecord WHERE tid = '$tid'  "; 
     88        $sth = $dbh->prepare($stmt{'addatq.addcue.1'}); 
     89        $sth->execute($tid); 
    9190}else{ 
    92         $DBQuery =  "SELECT * FROM  foltia_tvrecord WHERE tid = '$tid' AND stationid  = '$station' "; 
     91        $sth = $dbh->prepare($stmt{'addatq.addcue.2'}); 
     92        $sth->execute($tid, $station); 
    9393} 
    94  $sth = $dbh->prepare($DBQuery); 
    95 $sth->execute(); 
    9694 @titlecount= $sth->fetchrow_array; 
    9795$bitrate = $titlecount[2];#ビットレート取得 
    9896 
    9997#PID抽出 
    100 $now = &epoch2foldate(`date +%s`); 
    101 $twodaysafter = &epoch2foldate(`date +%s` + (60 * 60 * 24 * 2)); 
     98    $now = &epoch2foldate(time()); 
     99    $twodaysafter = &epoch2foldate(time() + (60 * 60 * 24 * 2)); 
    102100#キュー入れは直近2日後まで 
    103101if ($station == 0 ){ 
    104         $DBQuery =  " 
    105 SELECT * from foltia_subtitle WHERE tid = '$tid'  AND startdatetime >  '$now'  AND startdatetime < '$twodaysafter' "
     102        $sth = $dbh->prepare($stmt{'addatq.addcue.3'}); 
     103       $sth->execute($tid, $now, $twodaysafter)
    106104}else{ 
    107         $DBQuery =  " 
    108 SELECT * from foltia_subtitle WHERE tid = '$tid' AND stationid  = '$station'  AND startdatetime >  '$now'  AND startdatetime < '$twodaysafter' "; 
    109105#stationIDからrecch 
    110 $getrecchquery="SELECT stationid , stationrecch  FROM foltia_station where stationid  = '$station' "; 
    111  $stationh = $dbh->prepare($getrecchquery); 
    112         $stationh->execute(); 
     106        $stationh = $dbh->prepare($stmt{'addatq.addcue.4'}); 
     107        $stationh->execute($station); 
    113108@stationl =  $stationh->fetchrow_array; 
    114109$recch = $stationl[1]; 
    115 } 
    116110 
    117  $sth = $dbh->prepare($DBQuery); 
    118         $sth->execute(); 
     111        $sth = $dbh->prepare($stmt{'addatq.addcue.5'}); 
     112        $sth->execute($tid, $station, $now, $twodaysafter); 
     113    } 
    119114  
    120115while (($pid , 
     
    131126if ($station == 0 ){ 
    132127#stationIDからrecch 
    133 $getrecchquery="SELECT stationid , stationrecch  FROM foltia_station where stationid  = '$stationid' "; 
    134  $stationh = $dbh->prepare($getrecchquery); 
    135         $stationh->execute(); 
     128            $stationh = $dbh->prepare($stmt{'addatq.addcue.6'}); 
     129            $stationh->execute($stationid); 
    136130@stationl =  $stationh->fetchrow_array; 
    137131$recch = $stationl[1]; 
track feed