チェンジセット 94: trunk/install/perl/addatq.pl
- コミット日時:
- 2010/02/28 22:28:26 (15 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
trunk/install/perl/addatq.pl
r1 r94 16 16 use DBI; 17 17 use DBD::Pg; 18 use DBD::SQLite; 18 19 use Schedule::At; 19 20 use Time::Local; … … 21 22 $path = $0; 22 23 $path =~ s/addatq.pl$//i; 23 if ($p wdne "./"){24 if ($path ne "./"){ 24 25 push( @INC, "$path"); 25 26 } … … 38 39 39 40 #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;; 43 42 44 43 if ($station == 0){ 45 $DBQuery = "SELECT count(*) FROM foltia_tvrecord WHERE tid = '$tid' "; 44 $sth = $dbh->prepare($stmt{'addatq.1'}); 45 $sth->execute($tid); 46 46 }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); 48 49 } 49 $sth = $dbh->prepare($DBQuery);50 $sth->execute();51 50 @titlecount = $sth->fetchrow_array; 52 51 #件数数える … … 54 53 #2以上だったら 55 54 if ($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); 60 58 @reservecounts = $kth->fetchrow_array; 61 59 … … 63 61 if($tid == 0){ 64 62 #今回の引き数が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'}"); 67 65 &addcue; 68 66 }else{ 69 67 #ほかの全局録画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'}"); 71 69 exit; 72 70 }#end if ふくまれていたら … … 75 73 &addcue; 76 74 }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'}"); 78 76 } 79 77 … … 82 80 # & addcue; 83 81 # }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'}"); 85 83 #} 86 84 … … 88 86 89 87 if ($station == 0){ 90 $DBQuery = "SELECT * FROM foltia_tvrecord WHERE tid = '$tid' "; 88 $sth = $dbh->prepare($stmt{'addatq.addcue.1'}); 89 $sth->execute($tid); 91 90 }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); 93 93 } 94 $sth = $dbh->prepare($DBQuery);95 $sth->execute();96 94 @titlecount= $sth->fetchrow_array; 97 95 $bitrate = $titlecount[2];#ビットレート取得 98 96 99 97 #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)); 102 100 #キュー入れは直近2日後まで 103 101 if ($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); 106 104 }else{ 107 $DBQuery = "108 SELECT * from foltia_subtitle WHERE tid = '$tid' AND stationid = '$station' AND startdatetime > '$now' AND startdatetime < '$twodaysafter' ";109 105 #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); 113 108 @stationl = $stationh->fetchrow_array; 114 109 $recch = $stationl[1]; 115 }116 110 117 $sth = $dbh->prepare($DBQuery); 118 $sth->execute(); 111 $sth = $dbh->prepare($stmt{'addatq.addcue.5'}); 112 $sth->execute($tid, $station, $now, $twodaysafter); 113 } 119 114 120 115 while (($pid , … … 131 126 if ($station == 0 ){ 132 127 #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); 136 130 @stationl = $stationh->fetchrow_array; 137 131 $recch = $stationl[1];