チェンジセット 94: trunk/install/perl
- コミット日時:
- 2010/02/28 22:28:26 (15 年前)
- ファイル:
-
- trunk/install/perl/addatq.pl (更新) (9 diffs)
- trunk/install/perl/addpidatq.pl (更新) (5 diffs)
- trunk/install/perl/captureimagemaker.pl (更新) (4 diffs)
- trunk/install/perl/changestbch.pl (更新) (2 diffs)
- trunk/install/perl/db (追加)
- trunk/install/perl/db/Pg.pl (追加)
- trunk/install/perl/db/SQLite.pl (追加)
- trunk/install/perl/deletemovie.pl (更新) (1 diff)
- trunk/install/perl/digitaltvrecording.pl (更新) (5 diffs)
- trunk/install/perl/envpolicyupdate.pl (更新) (2 diffs)
- trunk/install/perl/folprep.pl (更新) (1 diff)
- trunk/install/perl/foltia_conf1.pl.template (更新) (1 diff)
- trunk/install/perl/foltialib.pl (更新) (10 diffs)
- trunk/install/perl/getxml2db.pl (更新) (10 diffs)
- trunk/install/perl/ipodtranscode.pl (更新) (11 diffs)
- trunk/install/perl/mklocalizeddir.pl (更新) (2 diffs)
- trunk/install/perl/recwrap.pl (更新) (12 diffs)
- trunk/install/perl/schedulecheck.pl (更新) (4 diffs)
- trunk/install/perl/singletranscode.pl (更新) (9 diffs)
- trunk/install/perl/tvrecording.pl (更新) (3 diffs)
- trunk/install/perl/updatem2pfiletable.pl (更新) (3 diffs)
- trunk/install/perl/xmltv2foltia.pl (更新) (7 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
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]; trunk/install/perl/addpidatq.pl
r83 r94 14 14 use DBI; 15 15 use DBD::Pg; 16 use DBD::SQLite; 16 17 use Schedule::At; 17 18 use Time::Local; … … 19 20 $path = $0; 20 21 $path =~ s/addpidatq.pl$//i; 21 if ($p wdne "./"){22 if ($path ne "./"){ 22 23 push( @INC, "$path"); 23 24 } … … 36 37 37 38 #DB検索(PID) 38 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 39 $DBDriv,$DBName,$DBHost,$DBPort); 40 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 39 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 41 40 42 $DBQuery = "SELECT count(*) FROM foltia_subtitle WHERE pid = '$pid' "; 43 $sth = $dbh->prepare($DBQuery); 44 $sth->execute(); 41 $sth = $dbh->prepare($stmt{'addpidatq.1'}); 42 $sth->execute($pid); 45 43 @titlecount= $sth->fetchrow_array; 46 44 47 45 if ($titlecount[0] == 1 ){ 48 49 $DBQuery = "SELECT bitrate,digital FROM foltia_tvrecord , foltia_subtitle WHERE foltia_tvrecord.tid = foltia_subtitle.tid AND pid='$pid' "; 50 $sth = $dbh->prepare($DBQuery); 51 $sth->execute(); 46 $sth = $dbh->prepare($stmt{'addpidatq.2'}); 47 $sth->execute($pid); 52 48 @titlecount= $sth->fetchrow_array; 53 49 $bitrate = $titlecount[0];#ビットレート取得 … … 59 55 60 56 #PID抽出 61 $now = &epoch2foldate(`date +%s`);57 $now = &epoch2foldate(time()); 62 58 63 59 #stationIDからrecch 64 $DBQuery = "SELECT stationrecch,digitalch ,digitalstationband ,foltia_station.stationid FROM foltia_station,foltia_subtitle WHERE foltia_subtitle.pid = '$pid' AND foltia_subtitle.stationid = foltia_station.stationid "; 65 66 $stationh = $dbh->prepare($DBQuery); 67 $stationh->execute(); 68 @stationl = $stationh->fetchrow_array; 60 $stationh = $dbh->prepare($stmt{'addpidatq.3'}); 61 $stationh->execute($pid); 62 @stationl = $stationh->fetchrow_array(); 69 63 $recch = $stationl[0]; 70 64 if ($recch eq ""){ 71 &writelog("addpidatq ERROR recch is NULL:$ DBQuery.");65 &writelog("addpidatq ERROR recch is NULL:$stmt{'addpidatq.3'}."); 72 66 exit 1; 73 67 } … … 82 76 $digitalstationband = 0; 83 77 } 84 $DBQuery = "SELECT * FROM foltia_subtitle WHERE pid='$pid' "; 85 $sth = $dbh->prepare($DBQuery); 86 $sth->execute(); 78 $sth = $dbh->prepare($stmt{'addpidatq.4'}); 79 $sth->execute($pid); 87 80 ($pid , 88 81 $tid , trunk/install/perl/captureimagemaker.pl
r83 r94 14 14 $path = $0; 15 15 $path =~ s/captureimagemaker.pl$//i; 16 if ($p wdne "./"){16 if ($path ne "./"){ 17 17 push( @INC, "$path"); 18 18 } … … 56 56 $date =~ s/[^0-9]//ig; 57 57 if ($date eq "" ){ 58 $date = `date +%Y%m%d` 58 $date = strftime("%Y%m%d", localtime); 59 59 } 60 60 # print "DATE:$date\n"; … … 65 65 $time =~ s/[^0-9]//ig; 66 66 if ($time eq "" ){ 67 $time = `date +%H%M` 67 $time = strftime("%H%M", localtime); 68 68 } 69 69 # print "TIME:$time\n"; … … 119 119 # 10秒ごとに 120 120 if ($filename =~ /m2t$/){ 121 &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 122 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 121 &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 $recfolderpath/$filename"); 122 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 $recfolderpath/$filename"); 123 if(-e "$capimgdirname/$captureimgdir/00000001.jpg" ){ #$capimgdirname/$captureimgdir/があったらなにもしない 124 }else{ #空っぽなら再試行 125 &writelog("captureimagemaker DEBUG RETRY mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf framestep=300step,scale=192:108 -ao null $recfolderpath/$filename"); 126 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf framestep=300step,scale=192:108 -ao null $recfolderpath/$filename"); 127 } 128 123 129 }else{ 124 130 &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 125 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 131 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 $recfolderpath/$filename"); 132 if(-e "$capimgdirname/$captureimgdir/00000001.jpg" ){ #$capimgdirname/ 133 }else{ 134 system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf framestep=300step,crop=690:460:12:10,scale=160:120 -ao null $recfolderpath/$filename"); 135 } 126 136 } 127 137 trunk/install/perl/changestbch.pl
r1 r94 26 26 use DBI; 27 27 use DBD::Pg; 28 use DBD::SQLite; 28 29 29 30 $path = $0; 30 31 $path =~ s/changestbch.pl$//i; 31 if ($p wdne "./"){32 if ($path ne "./"){ 32 33 push( @INC, "$path"); 33 34 } … … 54 55 # pidから局(送出コマンド)調べる 55 56 #DB初期化 56 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 57 $DBDriv,$DBName,$DBHost,$DBPort); 58 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 57 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 59 58 60 $DBQuery = "SELECT foltia_station.tunertype,foltia_station.tunerch ,foltia_station.stationrecch ,foltia_station.stationid FROM foltia_subtitle,foltia_station WHERE foltia_subtitle.stationid = foltia_station.stationid AND foltia_subtitle.pid = '$pid' "; 61 $sth = $dbh->prepare($DBQuery); 62 $sth->execute(); 59 $sth = $dbh->prepare($stmt{'changestbch.1'}); 60 $sth->execute($pid); 63 61 @chstatus = $sth->fetchrow_array; 64 62 $tunertype = $chstatus[0]; trunk/install/perl/deletemovie.pl
r83 r94 17 17 $path = $0; 18 18 $path =~ s/deletemovie.pl$//i; 19 if ($p wdne "./"){19 if ($path ne "./"){ 20 20 push( @INC, "$path"); 21 21 } trunk/install/perl/digitaltvrecording.pl
r91 r94 25 25 $path = $0; 26 26 $path =~ s/digitaltvrecording.pl$//i; 27 if ($p wdne "./"){27 if ($path ne "./"){ 28 28 push( @INC, "$path"); 29 29 } … … 112 112 &writelog("digitaltvrecording: DEBUG FILENAME ne null \$outputfile $outputfile "); 113 113 }else{ 114 $outputfile .= `date +%Y%m%d-%H%M --date "1 min "`;114 $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60)); 115 115 chomp($outputfile); 116 116 $outputfile .= ".m2t"; … … 193 193 } 194 194 }else{ # エラー b25とrecfriioがありません 195 &writelog("digitaltvrecording :ERROR :recfriio or b25 not found. You must install $toolpath/ b25 and $toolpath/recfriio.");195 &writelog("digitaltvrecording :ERROR :recfriio or b25 not found. You must install $toolpath/perl/tool/b25 and $toolpath/perl/tool/recfriio."); 196 196 exit 1; 197 197 } … … 387 387 } 388 388 }else{ # エラー recpt1がありません 389 &writelog("digitaltvrecording :ERROR :recpt1 not found. You must install $toolpath/ b25 and $toolpath/recpt1.");389 &writelog("digitaltvrecording :ERROR :recpt1 not found. You must install $toolpath/tool/b25 and $toolpath/tool/recpt1."); 390 390 $errorflag = 1; 391 391 } … … 409 409 } 410 410 }else{ # エラー recfriioがありません 411 &writelog("digitaltvrecording :ERROR :recfriio not found. You must install $toolpath/ b25 and $toolpath/recfriio.");411 &writelog("digitaltvrecording :ERROR :recfriio not found. You must install $toolpath/perl/tool/b25 and $toolpath/perl/tool/recfriio."); 412 412 exit 1; 413 413 } trunk/install/perl/envpolicyupdate.pl
r70 r94 16 16 use DBI; 17 17 use DBD::Pg; 18 use DBD::SQLite; 18 19 19 20 $path = $0; 20 21 $path =~ s/envpolicyupdate.pl$//i; 21 if ($p wdne "./"){22 if ($path ne "./"){ 22 23 push( @INC, "$path"); 23 24 } … … 33 34 eval "$returnparam\n"; 34 35 35 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 36 $DBDriv,$DBName,$DBHost,$DBPort); 37 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 36 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 38 37 39 $DBQuery = "SELECT userclass,name,passwd1 FROM foltia_envpolicy "; 40 41 $envph = $dbh->prepare($DBQuery); 38 $envph = $dbh->prepare($stmt{'envpolicyupdate.1'}); 42 39 $envph->execute(); 43 40 trunk/install/perl/folprep.pl
r1 r94 23 23 $path = $0; 24 24 $path =~ s/folprep.pl$//i; 25 if ($p wdne "./"){25 if ($path ne "./"){ 26 26 push( @INC, "$path"); 27 27 } trunk/install/perl/foltia_conf1.pl.template
r83 r94 28 28 29 29 #以下はデフォルトでインストールしてればいじらなくてもいい 30 $main::DBDriv="Pg"; 31 $main::DBHost="localhost"; 32 $main::DBPort="5432"; 33 $main::DBName="foltia"; 30 31 ## for postgresql 32 #$main::DSN="dbi:Pg:dbname=foltia;host=localhost;port=5432"; 33 #require 'db/Pg.pl'; 34 35 ## for sqlite 36 $main::DSN="dbi:SQLite:dbname=/home/foltia/foltia.sqlite"; 37 require 'db/SQLite.pl'; 38 34 39 $main::DBUser="foltia"; 35 40 $main::DBPass=""; trunk/install/perl/foltialib.pl
r83 r94 4 4 $path = $0; 5 5 $path =~ s/foltialib.pl$//i; 6 if ($p wdne "./"){6 if ($path ne "./"){ 7 7 push( @INC, "$path"); 8 8 } … … 13 13 use DBI; 14 14 use DBD::Pg; 15 16 17 $DBDriv=$main::DBDriv; 18 $DBHost=$main::DBHost; 19 $DBPort=$main::DBPort; 20 $DBName=$main::DBName; 15 use DBD::SQLite; 16 use POSIX qw(strftime); 17 18 $DSN=$main::DSN; 21 19 $DBUser=$main::DBUser; 22 20 $DBPass=""; … … 47 45 sub writelog{ 48 46 my $messages = $_[0]; 49 my $timestump = `date +%Y/%m/%d_%H:%M:%S`;47 my $timestump = strftime("%Y/%m/%d_%H:%M:%S", localtime); 50 48 chomp($timestump); 51 49 if ($debugmode == 1){ … … 146 144 my $stationname = $_[0] ; 147 145 my $stationid ; 148 my $DBQuery = "SELECT count(*) FROM foltia_station WHERE stationname = '$item{ChName}'";149 146 150 147 my $sth; 151 $sth = $dbh->prepare($DBQuery);152 $sth->execute();148 $sth = $dbh->prepare($stmt{'foltialib.getstationid.1'}); 149 $sth->execute($item{'ChName'}); 153 150 my @stationcount; 154 151 @stationcount= $sth->fetchrow_array; … … 156 153 if ($stationcount[0] == 1){ 157 154 #チャンネルID取得 158 $DBQuery = "SELECT stationid,stationname FROM foltia_station WHERE stationname = '$item{ChName}'"; 159 $sth = $dbh->prepare($DBQuery); 160 $sth->execute(); 155 $sth = $dbh->prepare($stmt{'foltialib.getstationid.2'}); 156 $sth->execute($item{'ChName'}); 161 157 @stationinfo= $sth->fetchrow_array; 162 158 #局ID … … 166 162 }elsif($stationcount[0] == 0){ 167 163 #新規登録 168 $DBQuery = "SELECT max(stationid) FROM foltia_station"; 169 $sth = $dbh->prepare($DBQuery); 164 $sth = $dbh->prepare($stmt{'foltialib.getstationid.3'}); 170 165 $sth->execute(); 171 166 @stationinfo= $sth->fetchrow_array; … … 174 169 ##$DBQuery = "insert into foltia_station values ('$stationid' ,'$item{ChName}','0','','','','','','')"; 175 170 #新規局追加時は非受信局をデフォルトに 176 $DBQuery = "insert into foltia_station (stationid , stationname ,stationrecch ) values ('$stationid' ,'$item{ChName}','-10')"; 177 178 $sth = $dbh->prepare($DBQuery); 179 $sth->execute(); 171 $sth = $dbh->prepare($stmt{'foltialib.getstationid.4'}); 172 $sth->execute($stationid, $item{'ChName'}, -10); 180 173 #print "Add station;$DBQuery\n"; 181 &writelog("foltialib Add station;$DBQuery");174 &writelog("foltialib Add station;$stmt{'foltialib.getstationid.4'}"); 182 175 }else{ 183 176 … … 287 280 } 288 281 289 my $DBQuery = "SELECT pid FROM foltia_subtitle WHERE m2pfilename = '$m2pfilename' LIMIT 1 ";290 282 my $sth; 291 $sth = $dbh->prepare($DBQuery);292 $sth->execute();293 #print "$ DBQuery\n";283 $sth = $dbh->prepare($stmt{'foltialib.getpidbympegfilename.1'}); 284 $sth->execute($m2pfilename); 285 #print "$stmt{'foltialib.getpidbympegfilename.1'}\n"; 294 286 my @pidinfo = $sth->fetchrow_array; 295 287 my $pid = $pidinfo[0]; … … 312 304 313 305 if ($updatestatus > 0 ){ 314 my $DBQuery = "UPDATE foltia_subtitle SET filestatus = $updatestatus , lastupdate = now() WHERE pid = $pid ";315 306 my $sth; 316 $sth = $dbh->prepare($DBQuery);317 $sth->execute();307 $sth = $dbh->prepare($stmt{'foltialib.changefilestatus.1'}); 308 $sth->execute($updatestatus, $pid); 318 309 return 1; 319 310 }else{ … … 351 342 } 352 343 353 my $DBQuery = "SELECT filestatus FROM foltia_subtitle WHERE pid = $pid ";354 344 my $sth; 355 $sth = $dbh->prepare($DBQuery);356 $sth->execute();345 $sth = $dbh->prepare($stmt{'foltialib.getfilestatus.1'}); 346 $sth->execute($pid); 357 347 358 348 my @statusinfo = $sth->fetchrow_array; trunk/install/perl/getxml2db.pl
r82 r94 19 19 use DBI; 20 20 use DBD::Pg; 21 use DBD::SQLite; 21 22 use Digest::MD5 qw(md5_hex); 22 23 23 24 $path = $0; 24 25 $path =~ s/getxml2db.pl$//i; 25 if ($p wdne "./"){26 if ($path ne "./"){ 26 27 push( @INC, "$path"); 27 28 } … … 48 49 } 49 50 51 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 50 52 51 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 52 $DBDriv,$DBName,$DBHost,$DBPort); 53 54 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 55 56 #$dbh->{AutoCommit} = 0; 53 $dbh->{AutoCommit} = 0; 57 54 58 55 # If-Modified-Since使うように変更#2008/11/14 … … 105 102 $programtitlename =~ s/\>\;/>/gi; 106 103 $programtitlename =~ s/\&\;/\&/gi; 107 $programtitle = $dbh->quote($programtitlename); 104 # $programtitle = $dbh->quote($programtitlename); 105 $programtitle = $programtitlename; 108 106 109 107 Jcode::convert(\$item{ChName},'euc'); … … 115 113 $programSubTitle =~ s/\>\;/>/gi; 116 114 $programSubTitle =~ s/\&\;/\&/gi; 117 $programSubTitle = $dbh->quote($programSubTitle);115 # $programSubTitle = $dbh->quote($programSubTitle); 118 116 119 117 $offsetmin = $item{StOffset}/60; … … 127 125 #サブタイトル追加------------------------------------------------- 128 126 #番組があるか確認 129 $DBQuery = "SELECT count(*) FROM foltia_program WHERE tid = '$item{TID}'"; 130 $sth = $dbh->prepare($DBQuery); 131 $sth->execute(); 127 $sth = $dbh->prepare($stmt{'getxml2db.1'}); 128 $sth->execute($item{TID}); 132 129 @titlecount= $sth->fetchrow_array; 133 130 … … 137 134 #200412012359 138 135 $nomalstarttime = substr($sttime,8,4); 139 $DBQuery = "insert into foltia_program values ($item{TID},$programtitle,'','$nomalstarttime','$length','','','3','1','')";140 # $sth = $dbh->prepare($DBQuery);141 # $sth->execute();142 $oserr = $dbh->do($DBQuery);143 &writelog("getxml2db ADD TV Progtam:$item{TID}:$programtitle");144 136 145 137 $sth = $dbh->prepare($stmt{'getxml2db.2'}); 138 $oserr = $sth->execute($item{TID}, $programtitle, '', $nomalstarttime, $length, '', '', 3, 1, '', ''); 139 &writelog("getxml2db ADD TV Progtam:$item{TID}:$programtitle"); 146 140 }else{ 147 141 #2006/2/26 148 142 #あったら、タイトル確認して 149 $DBQuery = "SELECT title FROM foltia_program WHERE tid = '$item{TID}'"; 150 $sth = $dbh->prepare($DBQuery); 151 $sth->execute(); 143 $sth = $dbh->prepare($stmt{'getxml2db.3'}); 144 $sth->execute($item{TID}); 152 145 @titlearray = $sth->fetchrow_array; 153 146 #更新などされてたらupdate 154 147 #print "$titlearray[0] / $programtitle\n"; 155 148 if ($titlearray[0] ne "$programtitlename" ){ 156 $DBQuery = "UPDATE foltia_program SET title = $programtitle where tid = '$item{TID}' "; 157 # $sth = $dbh->prepare($DBQuery); 158 # $sth->execute(); 159 $oserr = $dbh->do($DBQuery); 149 $sth = $dbh->prepare($stmt{'getxml2db.4'}); 150 $oserr = $sth->execute($programtitle, $item{TID}); 160 151 &writelog("getxml2db UPDATE TV Progtam:$item{TID}:$programtitle"); 161 152 }#end if update … … 164 155 165 156 #PIDがあるか確認 166 $DBQuery = "SELECT count(*) FROM foltia_subtitle WHERE tid = '$item{TID}' AND pid = '$item{PID}' "; 167 $sth = $dbh->prepare($DBQuery); 168 $sth->execute(); 157 $sth = $dbh->prepare($stmt{'getxml2db.5'}); 158 $sth->execute($item{'TID'}, $item{'PID'}); 169 159 @subticount= $sth->fetchrow_array; 170 160 if ($subticount[0] >= 1){ … … 174 164 #UPDATE foltia_subtitle SET stationid = '42',countno = '8',subtitle = '京都行きます' ,startdatetime = '200503010035' ,enddatetime = '200503010050',startoffset = '0' ,lengthmin = '15' WHERE tid = '550' AND pid = '26000' 175 165 if ($item{Count} == ""){ 176 177 $DBQuery = "UPDATE foltia_subtitle SET 178 stationid = '$stationid', 179 countno = null, 180 subtitle = $programSubTitle , 181 startdatetime = '$recstartdate' , 182 enddatetime = '$recenddate', 183 startoffset = '$offsetmin' , 184 lengthmin = '$length' 185 WHERE tid = '$item{TID}' AND pid = '$item{PID}' "; 186 166 $sth = $dbh->prepare($stmt{'getxml2db.6'}); 167 $oserr = $sth->execute($stationid, undef, $programSubTitle, $recstartdate, $recenddate, $offsetmin, $length, $item{'TID'}, $item{'PID'}); 187 168 }else{ 188 189 $DBQuery = "UPDATE foltia_subtitle SET 190 stationid = '$stationid', 191 countno = '$item{Count}', 192 subtitle = $programSubTitle , 193 startdatetime = '$recstartdate' , 194 enddatetime = '$recenddate', 195 startoffset = '$offsetmin' , 196 lengthmin = '$length' 197 WHERE tid = '$item{TID}' AND pid = '$item{PID}' "; 198 } 199 # $sth = $dbh->prepare($DBQuery); 200 # $sth->execute(); 201 $oserr = $dbh->do($DBQuery); 202 169 $sth = $dbh->prepare($stmt{'getxml2db.7'}); 170 $oserr = $sth->execute($stationid, $item{'Count'}, $programSubTitle, $recstartdate, $recenddate, $offsetmin, $length, $item{'TID'}, $item{'PID'}); 171 } 203 172 }else{ 204 173 #なければ追加 … … 207 176 #そのままキューに入る形で 208 177 if ($item{Count} eq ""){ 209 $DBQuery = "insert into foltia_subtitle values ( '$item{PID}','$item{TID}','$stationid',null,$programSubTitle,'$recstartdate','$recenddate','$offsetmin' ,'$length')"; 178 $sth = $dbh->prepare($stmt{'getxml2db.8'}); 179 $oserr = $sth->execute($item{'PID'}, $item{'TID'}, $stationid, undef, $programSubTitle, $recstartdate, $recenddate, $offsetmin, $length); 210 180 }else{ 211 $DBQuery = "insert into foltia_subtitle values ( '$item{PID}','$item{TID}','$stationid','$item{Count}',$programSubTitle,'$recstartdate','$recenddate','$offsetmin' ,'$length')"; 181 $sth = $dbh->prepare($stmt{'getxml2db.9'}); 182 $oserr = $sth->execute($item{'PID'}, $item{'TID'}, $stationid, $item{'Count'}, $programSubTitle, $recstartdate, $recenddate, $offsetmin, $length); 212 183 } 213 # $sth = $dbh->prepare($DBQuery);214 # $sth->execute();215 $oserr = $dbh->do($DBQuery);216 217 184 } 218 219 185 220 186 #print "$DBQuery\n\n\n"; … … 226 192 }#foreach 227 193 228 #$oserr = $dbh->commit;194 $oserr = $dbh->commit; 229 195 ## $dbh->disconnect(); 230 231 trunk/install/perl/ipodtranscode.pl
r83 r94 13 13 use DBI; 14 14 use DBD::Pg; 15 use DBD::SQLite; 15 16 use Jcode; 16 17 17 18 $path = $0; 18 19 $path =~ s/ipodtranscode.pl$//i; 19 if ($p wdne "./"){20 if ($path ne "./"){ 20 21 push( @INC, "$path"); 21 22 } … … 35 36 36 37 #DB初期化 37 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 38 $DBDriv,$DBName,$DBHost,$DBPort); 39 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 38 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 40 39 41 40 # タイトル取得 … … 57 56 58 57 while ($counttranscodefiles >= 1){ 59 60 $DBQuery = "SELECT foltia_subtitle.pid,foltia_subtitle.tid,foltia_subtitle.m2pfilename,filestatus,foltia_program.aspect ,foltia_subtitle.countno 61 FROM foltia_subtitle, foltia_program, foltia_m2pfiles 62 WHERE filestatus >= $FILESTATUSRECEND AND filestatus < $FILESTATUSTRANSCODECOMPLETE AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1 AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename 63 ORDER BY enddatetime ASC 64 LIMIT 1 "; 65 66 $sth = $dbh->prepare($DBQuery); 67 $sth->execute(); 58 $sth = $dbh->prepare($stmt{'ipodtranscode.1'}); 59 $sth->execute($FILESTATUSRECEND, $FILESTATUSTRANSCODECOMPLETE, ); 68 60 @dbparam = $sth->fetchrow_array; 69 61 #print "$dbparam[0],$dbparam[1],$dbparam[2],$dbparam[3],$dbparam[4],$dbparam[5]\n"; 70 &writelog("ipodtranscode DEBUG $DBQuery");62 #&writelog("ipodtranscode DEBUG $DBQuery"); 71 63 &writelog("ipodtranscode DEBUG $dbparam[0],$dbparam[1],$dbparam[2],$dbparam[3],$dbparam[4],$dbparam[5]"); 72 64 $pid = $dbparam[0]; … … 86 78 # タイトル取得 87 79 if ($pid ne ""){ 88 89 $DBQuery = "SELECT title , countno , subtitle 90 FROM foltia_program, foltia_subtitle 91 WHERE foltia_program.tid = foltia_subtitle.tid 92 AND foltia_subtitle.pid = $pid "; 93 $sth = $dbh->prepare($DBQuery); 94 $sth->execute(); 80 $sth = $dbh->prepare($stmt{'ipodtranscode.2'}); 81 $sth->execute($pid); 95 82 @programtitle = $sth->fetchrow_array; 96 83 $programtitle[0] =~ s/\"/\\"/gi; … … 147 134 } 148 135 136 149 137 $filenamebody = $inputmpeg2 ; 150 138 $filenamebody =~ s/.m2t$|.ts$|.m2p$|.mpg$//gi; 139 151 140 #デジタルかアナログか 152 141 if ($inputmpeg2 =~ /m2t$|ts$/i){ … … 174 163 $ffmpegencopt = " -s 360x202 -deinterlace -r 24.00 -vcodec libx264 -g 300 -b 330000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 175 164 }elsif($trconqty == 2){ 176 $ffmpegencopt = " -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -g 300 -b 400000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 165 # $ffmpegencopt = " -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -g 300 -b 400000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 166 # for ffmpeg 0.5 or later 167 $ffmpegencopt = " -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -vpre default -g 300 -b 400000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 177 168 }elsif($trconqty == 3){#640x352 178 $ffmpegencopt = " -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -g 100 -b 600000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 169 # $ffmpegencopt = " -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -g 100 -b 600000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 170 # for ffmpeg 0.5 or later 171 $ffmpegencopt = " -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -vpre default -g 100 -b 600000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 179 172 } 180 173 &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG); … … 246 239 # MP4ビルド 247 240 unlink("${filenamebody}.base.mp4"); 248 &changefilestatus($pid,$FILESTATUSTRANSCODEMP4BOX); 249 &writelog("ipodtranscode MP4Box $filenamebody"); 250 system ("cd $recfolderpath ; MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 251 #$exit_value = $? >> 8; 252 #$signal_num = $? & 127; 253 #$dumped_core = $? & 128; 254 #&writelog("ipodtranscode DEBUG MP4Box -fps 29.97 -add:$exit_value:$signal_num:$dumped_core"); 255 256 if (-e "$filenamebody.base.mp4"){ 257 system ("cd $recfolderpath ; MP4Box -add $filenamebody.aac $filenamebody.base.mp4"); 258 #$exit_value = $? >> 8; 259 #$signal_num = $? & 127; 260 #$dumped_core = $? & 128; 261 #&writelog("ipodtranscode DEBUG MP4Box -add $filenamebody.aac:$exit_value:$signal_num:$dumped_core"); 241 if (-e "$toolpath/perl/tool/MP4Box"){ 242 &changefilestatus($pid,$FILESTATUSTRANSCODEMP4BOX); 243 &writelog("ipodtranscode MP4Box $filenamebody"); 244 # system ("cd $recfolderpath ; MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 245 system ("cd $recfolderpath ;$toolpath/perl/tool/MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 246 $exit_value = $? >> 8; 247 $signal_num = $? & 127; 248 $dumped_core = $? & 128; 249 &writelog("ipodtranscode DEBUG MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4:$exit_value:$signal_num:$dumped_core"); 250 251 252 if (-e "$filenamebody.base.mp4"){ 253 # system ("cd $recfolderpath ; MP4Box -add $filenamebody.aac $filenamebody.base.mp4"); 254 system ("cd $recfolderpath ;$toolpath/perl/tool/MP4Box -add $filenamebody.aac $filenamebody.base.mp4"); 255 $exit_value = $? >> 8; 256 $signal_num = $? & 127; 257 $dumped_core = $? & 128; 258 &writelog("ipodtranscode DEBUG MP4Box -add $filenamebody.aac:$exit_value:$signal_num:$dumped_core"); 259 }else{ 260 $filelist = `ls -lhtr $recfolderpath/${filenamebody}*`; 261 $debugenv = `env`; 262 &writelog("ipodtranscode ERR File not exist.$debugenv.$filelist ;$filenamebody.base.mp4;$filelist;cd $recfolderpath ;$toolpath/perl/tool/MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 263 } 262 264 }else{ 263 &writelog("ipodtranscode ERR File not exist.$filenamebody.base.mp4"); 264 } 265 266 } 267 268 if ($filestatus <= $FILESTATUSTRANSCODEATOM){ 269 unlink("${mp4outdir}MAQ${mp4filenamestring}.MP4"); 270 # iPodヘッダ付加 271 &changefilestatus($pid,$FILESTATUSTRANSCODEATOM); 272 &writelog("ipodtranscode ATOM $filenamebody"); 273 #system ("/usr/local/bin/ffmpeg -y -i $filenamebody.base.mp4 -vcodec copy -acodec copy -f ipod ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 274 system ("cd $recfolderpath ; MP4Box -ipod $filenamebody.base.mp4"); 275 $exit_value = $? >> 8; 276 $signal_num = $? & 127; 277 $dumped_core = $? & 128; 278 &writelog("ipodtranscode DEBUG MP4Box -ipod:$exit_value:$signal_num:$dumped_core"); 279 system("mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 280 &writelog("ipodtranscode mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 281 # ipodtranscode mv /home/foltia/php/tv/1329-21-20080829-0017.base.mp4 /home/foltia/php/tv/1329.localized/mp4/MAQ-/home/foltia/php/tv/1329-21-20080829-0017.MP4 282 265 &writelog("ipodtranscode WARN; Pls. install $toolpath/perl/tool/MP4Box"); 266 } 267 #} 268 269 #if ($filestatus <= $FILESTATUSTRANSCODEATOM){ 270 if (-e "$toolpath/perl/tool/MP4Box"){ 271 # iPodヘッダ付加 272 # &changefilestatus($pid,$FILESTATUSTRANSCODEATOM); 273 &writelog("ipodtranscode ATOM $filenamebody"); 274 #system ("/usr/local/bin/ffmpeg -y -i $filenamebody.base.mp4 -vcodec copy -acodec copy -f ipod ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 275 # system ("cd $recfolderpath ; MP4Box -ipod $filenamebody.base.mp4"); 276 system ("cd $recfolderpath ; $toolpath/perl/tool/MP4Box -ipod $filenamebody.base.mp4"); 277 $exit_value = $? >> 8; 278 $signal_num = $? & 127; 279 $dumped_core = $? & 128; 280 &writelog("ipodtranscode DEBUG MP4Box -ipod $filenamebody.base.mp4:$exit_value:$signal_num:$dumped_core"); 281 if (-e "$filenamebody.base.mp4"){ 282 unlink("${mp4outdir}MAQ${mp4filenamestring}.MP4"); 283 system("mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 284 &writelog("ipodtranscode mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 285 }else{ 286 &writelog("ipodtranscode ERR $filenamebody.base.mp4 Not found."); 287 } 288 # ipodtranscode mv /home/foltia/php/tv/1329-21-20080829-0017.base.mp4 /home/foltia/php/tv/1329.localized/mp4/MAQ-/home/foltia/php/tv/1329-21-20080829-0017.MP4 289 }else{ 290 &writelog("ipodtranscode WARN; Pls. install $toolpath/perl/tool/MP4Box"); 291 } 283 292 } 284 293 if ($filestatus <= $FILESTATUSTRANSCODECOMPLETE){ 294 if (-e "${mp4outdir}MAQ${mp4filenamestring}.MP4"){ 285 295 # 中間ファイル消す 286 296 &changefilestatus($pid,$FILESTATUSTRANSCODECOMPLETE); … … 293 303 294 304 &updatemp4file(); 295 305 }else{ 306 &writelog("ipodtranscode ERR ; Fail MAQ${mp4filenamestring}.MP4"); 307 } 296 308 } 297 309 … … 384 396 &writelog("ipodtranscode DEBUG thmfilename $thmfilename"); 385 397 386 system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3 -v 3 $outputfilename"); 387 388 &writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3 -v 3 $outputfilename"); 389 390 if (-e "$pspdirname/$thmfilename"){ 391 $timestamp =`date "+%Y%m%d-%H%M%S"`; 392 chomp $timestamp; 393 system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); 398 #system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3 -v 3 $outputfilename"); 399 # 400 #&writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3 -v 3 $outputfilename"); 401 if($outputfilename =~ /.m2t$/){ 402 #ハイビジョンTS 403 system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=160:90,expand=160:120 -frames 1 $outputfilename"); 404 &writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=160:90,expand=160:120 -frames 1 $outputfilename"); 394 405 }else{ 395 system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 396 } 397 &writelog("ipodtranscode DEBUG convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 398 399 system("rm -rf $pspdirname/0000000*.jpg "); 400 &writelog("ipodtranscode DEBUG rm -rf $pspdirname/0000000*.jpg"); 406 #アナログ 407 system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=165:126,crop=160:120 -frames 1 $outputfilename"); 408 &writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=165:126,crop=160:120 -frames 1 $outputfilename"); 409 } 410 #if (-e "$pspdirname/$thmfilename"){ 411 # $timestamp = strftime("%Y%m%d-%H%M%S", localtime); 412 #chomp $timestamp; 413 # system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); 414 #}else{ 415 # system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 416 #} 417 #&writelog("ipodtranscode DEBUG convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 418 419 #system("rm -rf $pspdirname/0000000*.jpg "); 420 #&writelog("ipodtranscode DEBUG rm -rf $pspdirname/0000000*.jpg"); 421 system("mv $pspdirname/00000001.jpg $pspdirname/$thmfilename"); 401 422 402 423 }#endsub makethumbnail … … 407 428 if (-e "${mp4outdir}MAQ${mp4filenamestring}.MP4"){ 408 429 # MP4ファイル名をPIDレコードに書き込み 409 $DBQuery = "UPDATE foltia_subtitle SET PSPfilename = '$mp4filename' WHERE pid = '$pid' "; 410 $sth = $dbh->prepare($DBQuery); 411 $sth->execute(); 412 &writelog("ipodtranscode UPDATEsubtitleDB $DBQuery"); 430 $sth = $dbh->prepare($stmt{'ipodtranscode.updatemp4file.1'}); 431 $sth->execute($mp4filename, $pid); 432 &writelog("ipodtranscode UPDATEsubtitleDB $stmt{'ipodtranscode.updatemp4file.1'}"); 413 433 414 434 # MP4ファイル名をfoltia_mp4files挿入 415 $DBQuery = "insert into foltia_mp4files values ('$tid','$mp4filename') "; 416 $sth = $dbh->prepare($DBQuery); 417 $sth->execute(); 418 &writelog("ipodtranscode UPDATEmp4DB $DBQuery"); 435 $sth = $dbh->prepare($stmt{'ipodtranscode.updatemp4file.2'}); 436 $sth->execute($tid, $mp4filename); 437 &writelog("ipodtranscode UPDATEmp4DB $stmt{'ipodtranscode.updatemp4file.2'}"); 419 438 420 439 &changefilestatus($pid,$FILESTATUSALLCOMPLETE); … … 427 446 428 447 sub counttranscodefiles(){ 429 my $DBQuery = "SELECT count(*) FROM foltia_subtitle, foltia_program, foltia_m2pfiles 430 WHERE filestatus >= $FILESTATUSRECEND AND filestatus < $FILESTATUSTRANSCODECOMPLETE AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1 AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename "; 431 $sth = $dbh->prepare($DBQuery); 432 $sth->execute(); 448 $sth = $dbh->prepare($stmt{'ipodtranscode.counttranscodefiles.1'}); 449 $sth->execute($FILESTATUSRECEND, $FILESTATUSTRANSCODECOMPLETE); 433 450 my @titlecount= $sth->fetchrow_array; 434 451 trunk/install/perl/mklocalizeddir.pl
r1 r94 16 16 use DBI; 17 17 use DBD::Pg; 18 18 use DBD::SQLite; 19 19 20 20 $path = $0; 21 21 $path =~ s/mklocalizeddir.pl$//i; 22 if ($p wdne "./"){22 if ($path ne "./"){ 23 23 push( @INC, "$path"); 24 24 } … … 43 43 44 44 #接続 45 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 46 $DBDriv,$DBName,$DBHost,$DBPort); 47 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 45 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 48 46 49 47 #検索 50 $DBQuery = "select title from foltia_program where tid=$tid "; 51 $sth = $dbh->prepare($DBQuery); 52 $sth->execute(); 48 $sth = $dbh->prepare($stmt{'mklocalizeddir.1'}); 49 $sth->execute($tid); 53 50 @subticount= $sth->fetchrow_array; 54 51 $title = $subticount[0] ; trunk/install/perl/recwrap.pl
r91 r94 15 15 use DBI; 16 16 use DBD::Pg; 17 use DBD::SQLite; 17 18 use Schedule::At; 18 19 use Time::Local; … … 21 22 $path = $0; 22 23 $path =~ s/recwrap.pl$//i; 23 if ($p wdne "./"){24 if ($path ne "./"){ 24 25 push( @INC, "$path"); 25 26 } … … 46 47 47 48 #DB初期化 48 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 49 $DBDriv,$DBName,$DBHost,$DBPort); 50 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 49 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 51 50 52 51 … … 57 56 } 58 57 59 $outputfile = `date +%Y%m%d-%H%M --date "1 min "`;58 $outputfile = strftime("%Y%m%d-%H%M", localtime(time + 60)); 60 59 chomp($outputfile); 61 60 … … 77 76 &writelog("recwrap RECSTART DIGITAL $digitalstationband $digitalch $reclength $stationid 0 $outputfilename $tid $countno friio"); 78 77 #録画 79 $starttime = (`date +%s`);78 $starttime = time(); 80 79 $oserr = system("$toolpath/perl/digitaltvrecording.pl $digitalstationband $digitalch $reclength $stationid 0 $outputfilename $tid $countno friio"); 81 80 $oserr = $oserr / 256; … … 119 118 #録画 120 119 #system("$toolpath/perl/tvrecording.pl $recch $reclength 0 $outputfile $bitrate $tid $countno"); 121 $starttime = (`date +%s`);120 $starttime = time(); 122 121 123 122 $oserr = system("$toolpath/perl/tvrecording.pl $recch $reclength 0 $outputfilename $bitrate $tid $countno"); … … 131 130 132 131 #デバイスビジーで即死してないか検出 133 $now = (`date +%s`);132 $now = time(); 134 133 if ($now < $starttime + 100){ #録画プロセス起動してから100秒以内に戻ってきてたら 135 $retrycounter == 0;134 $retrycounter = 0; 136 135 while($now < $starttime + 100){ 137 136 if($retrycounter >= 5){ … … 141 140 &writelog("recwrap retry recording $now $starttime"); 142 141 #アナログ録画 143 $starttime = (`date +%s`);142 $starttime = time(); 144 143 if($outputfilename =~ /.m2t$/){ 145 144 $outputfilename =~ s/.m2t$/.m2p/; 146 145 } 147 146 $oserr = system("$toolpath/perl/tvrecording.pl $recch $reclength N $outputfilename $bitrate $tid $countno"); 148 $now = (`date +%s`);147 $now = time(); 149 148 $oserr = $oserr / 256; 150 149 if ($oserr == 1){ … … 160 159 161 160 # m2pファイル名をPIDレコードに書き込み 162 $DBQuery = "UPDATE foltia_subtitle SET m2pfilename = '$outputfilename' WHERE pid = '$pid' "; 163 $sth = $dbh->prepare($DBQuery); 164 $sth->execute(); 165 &writelog("recwrap DEBUG UPDATEDB $DBQuery"); 161 $sth = $dbh->prepare($stmt{'recwrap.1'}); 162 $sth->execute($outputfilename, $pid); 163 &writelog("recwrap DEBUG UPDATEDB $stmt{'recwrap.1'}"); 166 164 &changefilestatus($pid,$FILESTATUSRECEND); 167 165 168 166 # m2pファイル名をPIDレコードに書き込み 169 $DBQuery = "insert into foltia_m2pfiles values ('$outputfilename')"; 170 $sth = $dbh->prepare($DBQuery); 171 $sth->execute(); 172 &writelog("recwrap DEBUG UPDATEDB $DBQuery"); 167 $sth = $dbh->prepare($stmt{'recwrap.2'}); 168 $sth->execute($outputfilename); 169 &writelog("recwrap DEBUG UPDATEDB $stmt{'recwrap.2'}"); 173 170 174 171 # Starlight breaker向けキャプチャ画像作成 … … 181 178 182 179 183 184 180 # MPEG4 ------------------------------------------------------ 185 181 #MPEG4トラコン必要かどうか 186 $DBQuery = "SELECT psp,aspect,title FROM foltia_program WHERE tid = '$tid' "; 187 $sth = $dbh->prepare($DBQuery); 188 $sth->execute(); 182 $sth = $dbh->prepare($stmt{'recwrap.3'}); 183 $sth->execute($tid); 189 184 @psptrcn= $sth->fetchrow_array; 190 185 if ($psptrcn[0] == 1 ){#トラコン番組 … … 192 187 exec ("$toolpath/perl/ipodtranscode.pl"); 193 188 exit; 194 #195 # ここから下は旧エンコード#2008/12/23196 # 新エンコードはDBを見て未完了MPEG2を順次トラコン処理、197 # 分散エンコードもきっとラクチンに対応可能198 # 新エンコードではXviD/M4VスタイルとPSPファイル名対応を廃止199 200 &changefilestatus($pid,80);201 #MPEG4ムービーディレクトリがあるかどうか202 203 #TIDが100以上の3桁の場合はそのまま204 my $pspfilnamehd = "";205 206 $pspfilnamehd = $tid;207 &makemp4dir($tid);208 $pspdirname = "$tid.localized/";209 $pspdirname = $recfolderpath."/".$pspdirname;210 211 #なければ作る212 #unless (-e $pspdirname ){213 # system("$toolpath/perl/mklocalizeddir.pl $tid");214 # #&writelog("recwrap mkdir $pspdirname");215 #}216 $pspdirname = "$tid.localized/mp4/";217 $pspdirname = $recfolderpath."/".$pspdirname;218 #なければ作る219 #unless (-e $pspdirname ){220 # mkdir $pspdirname ,0777;221 # #&writelog("recwrap mkdir $pspdirname");222 #}223 224 #ファイル名決定225 if ($mp4filenamestyle == 1){# 1;よりわかりやすいファイル名226 $pspfilname = $mp4newstylefilename ;227 228 }else{##0:PSP ファームウェアver.2.80より前と互換性を持つファイル名229 #・フォルダ名[100MNV01]の100の部分は変更可(100〜999)。230 # MP_ROOT ━ 100MNV01 ┳ M4V00001.MP4(動画)231 #┃ ┗ M4V00001.THM(サムネイル)※必須ではない232 233 #ファイル名決定234 #ファイル名決定 #新アルゴリズム235 #TID 0000-3599まで[3桁]236 #話数 00-999まで[2桁]237 238 my $pspfilnameft = "";239 my $pspfilnameyearhd = "";240 my $pspfilnameyearft = "";241 242 $btid = $tid % 3600;243 # print "$btid\n";244 245 if($btid >= 0 && $btid < 1000){246 247 $pspfilnamehd = sprintf("%03d",$btid);248 249 }elsif ($btid >= 1000 && $btid < 3600){250 $pspfilnameyearhd = substr($btid, 0, 2);251 $pspfilnameyearhd =~ s/10/A/;252 $pspfilnameyearhd =~ s/11/B/;253 $pspfilnameyearhd =~ s/12/C/;254 $pspfilnameyearhd =~ s/13/D/;255 $pspfilnameyearhd =~ s/14/E/;256 $pspfilnameyearhd =~ s/15/F/;257 $pspfilnameyearhd =~ s/16/G/;258 $pspfilnameyearhd =~ s/17/H/;259 $pspfilnameyearhd =~ s/18/I/;260 $pspfilnameyearhd =~ s/19/J/;261 $pspfilnameyearhd =~ s/20/K/;262 $pspfilnameyearhd =~ s/21/L/;263 $pspfilnameyearhd =~ s/22/M/;264 $pspfilnameyearhd =~ s/23/N/;265 $pspfilnameyearhd =~ s/24/O/;266 $pspfilnameyearhd =~ s/25/P/;267 $pspfilnameyearhd =~ s/26/Q/;268 $pspfilnameyearhd =~ s/27/R/;269 $pspfilnameyearhd =~ s/28/S/;270 $pspfilnameyearhd =~ s/29/T/;271 $pspfilnameyearhd =~ s/30/U/;272 $pspfilnameyearhd =~ s/31/V/;273 $pspfilnameyearhd =~ s/32/W/;274 $pspfilnameyearhd =~ s/33/X/;275 $pspfilnameyearhd =~ s/34/Y/;276 $pspfilnameyearhd =~ s/35/Z/;277 278 $pspfilnameyearft = substr($btid, 2, 2);279 $pspfilnameyearft = sprintf("%02d",$pspfilnameyearft);280 $pspfilnamehd = $pspfilnameyearhd . $pspfilnameyearft;281 282 }283 284 # 話数285 if (0 < $countno && $countno < 100 ){286 # 2桁287 $pspfilnameft = sprintf("%02d",$countno);288 }elsif(100 <= $countno && $countno < 1000 ){289 # 3桁290 $pspfilnameft = sprintf("%03d",$countno); # 話数3桁291 $pspfilnamehd = substr($pspfilnamehd, 0, 2); # TID 二桁 後ろ1バイト落とし292 }elsif(1000 <= $countno && $countno < 10000 ){293 # 4桁294 $pspfilnameft = sprintf("%04d",$countno); # 話数4桁295 $pspfilnamehd = substr($pspfilnamehd, 0, 1); # TID 1桁 後ろ2バイト落とし296 297 298 }elsif($countno == 0){299 #タイムスタンプが最新のMP4ファイル名取得300 my $newestmp4filename = `cd $pspdirname ; ls -t *.MP4 | head -1`;301 if ($newestmp4filename =~ /M4V$tid/){302 $nowcountno = $' ;303 $nowcountno++;304 $pspfilnameft = sprintf("%02d",$nowcountno);305 while (-e "$pspdirname/M4V".$pspfilnamehd.$pspfilnameft.".MP4"){306 $nowcountno++;307 $pspfilnameft = sprintf("%02d",$nowcountno);308 print "File exist:$nowcountno\n";309 }310 #print "NeXT\n";311 }else{312 # 0の場合 週番号を100から引いたもの313 # week number of year with Monday as first day of week (01..53)314 #だったけど常に0に315 # my $weeno = `date "+%V"`;316 # $weeno = 100 - $weeno ;317 # $pspfilnameft = sprintf("%02d",$weeno);318 $pspfilnameft = sprintf("%02d",0);319 #print "WEEKNO\n";320 }321 322 }323 324 my $pspfilname = $pspfilnamehd.$pspfilnameft ;325 # print "$pspfilname($pspfilnamehd/$pspfilnameft)\n";326 }# endif MP4ファイル名が新styleなら327 #2006/12/03_10:30:24 recwrap TRCNSTART vfr4psp.sh /home/foltia/php/tv/591-87-20061203-1000.m2p -591-87-20061203-1000 /home/foltia/php/tv/591.localized/mp4/ 3328 329 330 # トラコンキューイング #2007/7/10331 my $trcnprocesses = "";332 my $cpucores = `ls /proc/acpi/processor | wc -l`;333 $cpucores =~ s/[^0-9]//gi;334 unless ($cpucores >= 1 ){335 $cpucores = 1;336 }337 do {338 $trcnprocesses = `ps ax | grep ffmpeg | grep -v grep | wc -l `;339 $trcnprocesses =~ s/[^0-9]//gi;340 # 既にトラコンプロセスが走っているなら適当に待機341 if ($trcnprocesses >= $cpucores){342 if (-e "/proc/uptime" ){343 $loadaverage = `uptime`;344 chomp($loadaverage);345 }else{346 $loadaverage = "";347 }348 &writelog("recwrap TRCN WAITING :$trcnprocesses / $cpucores :$outputfilename $loadaverage");349 sleep 113;350 sleep ($recch)*5;351 }352 } until ($trcnprocesses < $cpucores);353 354 355 if (($trconqty eq "")||($trconqty == 0 )){356 &writelog("recwrap TRCNSTART vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]");357 system("$toolpath/perl/transcode/vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]");358 &writelog("recwrap TRCNEND vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]");359 #最適化360 $DBQuery = "SELECT subtitle FROM foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' ";361 $sth = $dbh->prepare($DBQuery);362 $sth->execute();363 @programtitle = $sth->fetchrow_array;364 if ( $countno == "0" ){365 $pspcountno = "";366 }else{367 $pspcountno = $countno ;368 }369 &writelog("recwrap OPTIMIZE mp4psp -p $pspdirname/M4V$pspfilname.MP4 -t '$psptrcn[2] $pspcountno $programtitle[0]' ");370 Jcode::convert(\$programtitle[0],'euc');371 system ("/usr/local/bin/mp4psp -p $pspdirname/M4V$pspfilname.MP4 -t '$psptrcn[2] $pspcountno $programtitle[0]'") ;372 $mp4filename = "M4V${pspfilname}.MP4";373 $thmfilename = "M4V${pspfilname}.THM";374 }else{# #2006/12/6 新エンコーダ375 376 &writelog("recwrap TRCNSTART ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $pid $psptrcn[1]");377 system("$toolpath/perl/ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $pid $psptrcn[1]");378 &writelog("recwrap TRCNEND ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]");379 380 if($trconqty >= 2){#H.264/AVCなら381 $mp4filename = "MAQ${pspfilname}.MP4";382 $thmfilename = "MAQ${pspfilname}.THM";383 }else{384 $mp4filename = "M4V${pspfilname}.MP4";385 $thmfilename = "M4V${pspfilname}.THM";386 }387 }388 389 #サムネール390 391 # mplayer -ss 00:01:20 -vo jpeg:outdir=/home/foltia/php/tv/443MNV01 -ao null -sstep 1 -frames 3 -v 3 /home/foltia/php/tv/443-07-20050218-0030.m2p392 #2005/02/22_18:30:05 recwrap TRCNSTART vfr4psp.sh /home/foltia/php/tv/447-21-20050222-1800.m2p 44721 /home/foltia/php/tv/447MNV01 3393 &writelog("recwrap THAMJ mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3 -v 3 $recfolderpath/$outputfilename ");394 system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3 -v 3 $recfolderpath/$outputfilename");395 &writelog("recwrap THAMI convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V$pspdirname.THM ");396 397 if (-e "$pspdirname/$thmfilename"){398 $timestamp =`date "+%Y%m%d-%H%M%S"`;399 chomp $timestamp;400 system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM");401 402 }else{403 system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename");404 }405 # rm -rf 00000001.jpg406 # convert -resize 160x120\! 00000002.jpg M4V44307.THM407 # rm -rf 00000002.jpg408 system("rm -rf $pspdirname/0000000*.jpg ");409 410 411 412 413 # MP4ファイル名をPIDレコードに書き込み414 $DBQuery = "UPDATE foltia_subtitle SET PSPfilename = '$mp4filename' WHERE pid = '$pid' ";415 $sth = $dbh->prepare($DBQuery);416 $sth->execute();417 &writelog("recwrap UPDATEsubtitleDB $DBQuery");418 419 # MP4ファイル名をfoltia_mp4files挿入420 $DBQuery = "insert into foltia_mp4files values ('$tid','$mp4filename') ";421 $sth = $dbh->prepare($DBQuery);422 $sth->execute();423 &writelog("recwrap UPDATEmp4DB $DBQuery");424 425 &changefilestatus($pid,200);426 189 }#PSPトラコンあり 427 190 428 191 sub continuousrecordingcheck(){ 429 my $now = `date +%s --date "2 min "`;192 my $now = time() + 60 * 2; 430 193 &writelog("recwrap DEBUG continuousrecordingcheck() now $now"); 431 194 my @processes =`ps ax | grep recfriio`; … … 474 237 $startdatetime = $startdate.$filenameparts[0]; 475 238 #DBから録画中番組のデータ探す 476 $DBQuery = " 477 SELECT foltia_subtitle.tid,foltia_subtitle.countno,foltia_subtitle.subtitle,foltia_subtitle.startdatetime ,foltia_subtitle.enddatetime ,foltia_subtitle.lengthmin ,foltia_tvrecord.bitrate , foltia_subtitle.startoffset , foltia_subtitle.pid ,foltia_tvrecord.digital 478 FROM foltia_subtitle ,foltia_tvrecord 479 WHERE 480 foltia_tvrecord.tid = foltia_subtitle.tid AND 481 foltia_tvrecord.tid = $tid AND 482 foltia_subtitle.startdatetime = $startdatetime AND 483 foltia_tvrecord.digital = 1"; 484 &writelog("recwrap DEBUG continuousrecordingcheck() $DBQuery"); 485 $sth = $dbh->prepare($DBQuery); 239 &writelog("recwrap DEBUG continuousrecordingcheck() $stmt{'recwrap.7'}"); 240 $sth = $dbh->prepare($stmt{'recwrap.7'}); 486 241 &writelog("recwrap DEBUG continuousrecordingcheck() prepare"); 487 $sth->execute();242 $sth->execute($tid, $startdatetime); 488 243 &writelog("recwrap DEBUG continuousrecordingcheck() execute"); 489 244 @recfile = $sth->fetchrow_array; trunk/install/perl/schedulecheck.pl
r1 r94 14 14 use DBI; 15 15 use DBD::Pg; 16 use DBD::SQLite; 16 17 use Schedule::At; 17 18 use Time::Local; … … 19 20 $path = $0; 20 21 $path =~ s/schedulecheck.pl$//i; 21 if ($p wdne "./"){22 if ($path ne "./"){ 22 23 push( @INC, "$path"); 23 24 } … … 29 30 30 31 #予約番組探し 31 $now = &epoch2foldate( `date +%s`);32 $now = &epoch2foldate(time()); 32 33 $now = &epoch2foldate($now); 33 34 $checkrangetime = $now + 15*60;#15分後まで 34 35 $checkrangetime = &epoch2foldate($checkrangetime); 35 36 36 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 37 $DBDriv,$DBName,$DBHost,$DBPort); 38 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 37 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 39 38 40 $DBQuery = "SELECT count(*) FROM foltia_tvrecord "; 41 42 43 $sth = $dbh->prepare($DBQuery); 39 $sth = $dbh->prepare($stmt{'schedulecheck.1'}); 44 40 $sth->execute(); 45 41 @titlecount= $sth->fetchrow_array; … … 48 44 exit; 49 45 }else{ 50 51 $DBQuery = "SELECT tid ,stationid FROM foltia_tvrecord "; 52 $sth = $dbh->prepare($DBQuery); 46 $sth = $dbh->prepare($stmt{'schedulecheck.2'}); 53 47 $sth->execute(); 54 48 while (($tid,$stationid ) = $sth->fetchrow_array()) { trunk/install/perl/singletranscode.pl
r1 r94 28 28 use DBI; 29 29 use DBD::Pg; 30 use DBD::SQLite; 30 31 use Schedule::At; 31 32 use Time::Local; … … 34 35 $path = $0; 35 36 $path =~ s/singletranscode.pl$//i; 36 if ($p wdne "./"){37 if ($path ne "./"){ 37 38 push( @INC, "$path"); 38 39 } … … 63 64 64 65 #PSPトラコン必要かどうか 65 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 66 67 $DBDriv,$DBName,$DBHost,$DBPort); 68 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 66 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 69 67 70 68 if ($ARGV[1] != ""){ 71 69 $pid = $ARGV[1] ; 72 70 }else{ 73 $DBQuery = "SELECT pid FROM foltia_subtitle WHERE m2pfilename = '$ARGV[0]' "; 74 $sth = $dbh->prepare($DBQuery); 75 $sth->execute(); 71 $sth = $dbh->prepare($stmt{'singletranscode.1'}); 72 $sth->execute($ARGV[0]); 76 73 @pidarray = $sth->fetchrow_array; 77 74 unless ($pidarray[0] == "" ){ … … 86 83 # 追加部分 87 84 88 $query = "SELECT count(*) FROM foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; 89 $sth = $dbh->prepare($query); 90 $sth->execute(); 85 $sth = $dbh->prepare($stmt{'singletranscode.2'}); 86 $sth->execute($tid, $countno); 91 87 @subticount= $sth->fetchrow_array; 92 88 unless ($subticount[0] >= 1){ 93 89 94 $query = "SELECT count(*) FROM foltia_subtitle WHERE tid = '$tid' "; 95 $sth = $dbh->prepare($query); 96 $sth->execute(); 90 $sth = $dbh->prepare($stmt{'singletranscode.3'}); 91 $sth->execute($tid); 97 92 @subticount= $sth->fetchrow_array; 98 93 … … 120 115 # PSP ------------------------------------------------------ 121 116 #PSPトラコン必要かどうか 122 $DBQuery = "SELECT psp,aspect,title FROM foltia_program WHERE tid = '$tid' "; 123 $sth = $dbh->prepare($DBQuery); 124 $sth->execute(); 117 $sth = $dbh->prepare($stmt{'singletranscode.4'}); 118 $sth->execute($tid); 125 119 @psptrcn= $sth->fetchrow_array; 126 120 if ($psptrcn[0] == 1 ){#トラコン番組 … … 227 221 my $newestmp4filename = `cd $pspdirname ; ls -t *.MP4 | head -1`; 228 222 if ($newestmp4filename =~ /M4V$tid/){ 229 $nowcountno = $' ;223 $nowcountno = $' ;#' 230 224 $nowcountno++; 231 225 $pspfilnameft = sprintf("%02d",$nowcountno); … … 261 255 #最適化 262 256 263 $DBQuery = "SELECT subtitle FROM foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; 264 $sth = $dbh->prepare($DBQuery); 265 $sth->execute(); 257 $sth = $dbh->prepare($stmt{'singletranscode.5'}); 258 $sth->execute($tid, $countno); 266 259 @programtitle = $sth->fetchrow_array; 267 260 … … 285 278 286 279 if (-e "$pspdirname/M4V".$pspfilname.".THM"){ 287 $timestamp =`date "+%Y%m%d-%H%M%S"`;280 $timestamp = strftime("%Y%m%d-%H%M%S", localtime); 288 281 chomp $timestamp; 289 282 system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V".$pspfilname.".THM.".$timestamp.".THM"); … … 297 290 system("rm -rf $pspdirname/0000000*.jpg "); 298 291 299 300 301 302 292 # MP4ファイル名をPIDレコードに書き込み 303 293 unless ($pid eq ""){ 304 $DBQuery = " 305 UPDATE foltia_subtitle 306 SET PSPfilename = 'M4V$pspfilname.MP4' 307 WHERE pid = '$pid' "; 308 $sth = $dbh->prepare($DBQuery); 309 $sth->execute(); 310 &writelog("singletranscode UPDATEsubtitleDB $DBQuery"); 294 $sth = $dbh->prepare($stmt{'singletranscode.6'}); 295 $sth->execute("M4V$pspfilname.MP4", $pid); 296 &writelog("singletranscode UPDATEsubtitleDB $stmt{'singletranscode.6'}"); 311 297 }else{ 312 298 &writelog("singletranscode PID not found"); 313 299 } 314 300 # MP4ファイル名をfoltia_mp4files挿入 315 $DBQuery = "insert into foltia_mp4files values ('$tid','M4V$pspfilname.MP4') "; 316 $sth = $dbh->prepare($DBQuery); 317 $sth->execute(); 318 &writelog("singletranscode UPDATEmp4DB $DBQuery"); 301 $sth = $dbh->prepare($stmt{'singletranscode.7'}); 302 $sth->execute($tid, "M4V$pspfilname.MP4"); 303 &writelog("singletranscode UPDATEmp4DB $stmt{'singletranscode.7'}"); 319 304 320 305 }#PSPトラコンあり 321 322 trunk/install/perl/tvrecording.pl
r83 r94 29 29 $path = $0; 30 30 $path =~ s/tvrecording.pl$//i; 31 if ($p wdne "./"){31 if ($path ne "./"){ 32 32 push( @INC, "$path"); 33 33 } … … 301 301 # $outputfile .= "$ARGV[3]"; 302 302 # }else{ 303 # $outputfile .= `date +%Y%m%d-%H%M --date "1 min "`;303 # $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60)); 304 304 # } 305 305 $outputfile = $ARGV[3]; … … 308 308 $outputfile = $outputpath.$outputfile ; 309 309 # $outputfile .= "$ARGV[3]"; 310 # $outputfile .= `date +%Y%m%d-%H%M --date "1 min "`;310 # $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60)); 311 311 &writelog("tvrecording: DEBUG ARGV[2] ne null \$outputfile $outputfile "); 312 312 }else{ 313 $outputfile .= `date +%Y%m%d-%H%M --date "1 min "`;313 $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60)); 314 314 chomp($outputfile); 315 315 $outputfile .= ".m2p"; trunk/install/perl/updatem2pfiletable.pl
r83 r94 16 16 use DBI; 17 17 use DBD::Pg; 18 use DBD::SQLite; 18 19 19 20 $path = $0; 20 21 $path =~ s/updatem2pfiletable.pl$//i; 21 if ($p wdne "./"){22 if ($path ne "./"){ 22 23 push( @INC, "$path"); 23 24 } 24 25 25 26 require "foltialib.pl"; 26 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 27 $DBDriv,$DBName,$DBHost,$DBPort); 28 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 27 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 29 28 30 29 $dbh->{AutoCommit} = 0; 31 30 # ひとまず消す 32 $query = "DELETE FROM foltia_m2pfiles "; 33 $sth = $dbh->prepare($query); 31 $sth = $dbh->prepare($stmt{'updatem2pfiletable.1'}); 34 32 $sth->execute(); 35 33 36 34 while ($file = glob("$recfolderpath/*.m2?")) { 37 35 $file =~ s/$recfolderpath\///; 38 $query = "insert into foltia_m2pfiles values ('$file')";39 $oserr = $dbh->do($query);36 $sth = $dbh->prepare($stmt{'updatem2pfiletable.2'}); 37 $sth->execute($file); 40 38 # print "$file\n"; 41 39 }#while … … 46 44 47 45 # ひとまず消す 48 $query = "DELETE FROM foltia_mp4files "; 49 $sth = $dbh->prepare($query); 46 $sth = $dbh->prepare($stmt{'updatem2pfiletable.3'}); 50 47 $sth->execute(); 51 48 … … 58 55 $filetid =~ s/[^0-9]//g; 59 56 if (($filetid ne "" )&& ($fileline[2] ne "" )){ 60 $ query = "insert into foltia_mp4files values ('$filetid','$fileline[2]')";61 $oserr = $ dbh->do($query);57 $sth = $dbh->prepare($stmt{'updatem2pfiletable.4'}); 58 $oserr = $sth->execute($filetid, $fileline[2]); 62 59 #print "$filetid;$fileline[2];$query\n" 63 60 # http://www.atmarkit.co.jp/fnetwork/rensai/sql03/sql1.html trunk/install/perl/xmltv2foltia.pl
r38 r94 30 30 use DBI; 31 31 use DBD::Pg; 32 use DBD::SQLite; 32 33 33 34 $path = $0; 34 35 $path =~ s/xmltv2foltia.pl$//i; 35 if ($p wdne "./"){36 if ($path ne "./"){ 36 37 push( @INC, "$path"); 37 38 } … … 40 41 $currentworkdate = "" ; 41 42 $currentworkch = "" ; 42 $today = `date "+%Y%m%d"`;43 $todaytime = `date "+%Y%m%d%H%M"`;43 $today = strftime("%Y%m%d", localtime); 44 $todaytime = strftime("%Y%m%d%H%M", localtime); 44 45 45 46 # DB Connect 46 my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 47 $DBDriv,$DBName,$DBHost,$DBPort); 48 $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 47 $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 48 $dbh->{AutoCommit} = 0; 49 49 50 50 while(<>){ … … 187 187 }elsif(/<\/programme>/){ 188 188 #登録処理はココで 189 #&writelog("xmltv2foltia DEBUG call chkerase $item{ start},$item{channel}");190 191 &chkerase($item{start},$item{channel});192 if ($item{subtitle} ne "" ){193 $registdesc = $item{subtitle}." ".$item{desc};189 #&writelog("xmltv2foltia DEBUG call chkerase $item{'start'},$item{'channel'}"); 190 191 &chkerase($item{'start'}, $item{'channel'}); 192 if ($item{'subtitle'} ne "" ){ 193 $registdesc = $item{'subtitle'}." ".$item{'desc'}; 194 194 }else{ 195 $registdesc = $item{desc};195 $registdesc = $item{'desc'}; 196 196 } 197 ®istdb($item{start},$item{stop},$item{channel},$item{title},$registdesc ,$item{category});197 ®istdb($item{'start'},$item{'stop'},$item{'channel'},$item{'title'},$registdesc ,$item{'category'}); 198 198 199 199 # print "$item{start} … … 216 216 }# while 217 217 218 $dbh->commit; 219 220 #end 221 ################ 222 218 223 sub chkerase{ 219 224 # xmltvからきた日付とチャンネルをfoltia epgと比較 … … 232 237 # 新規に入る予定の未来の番組表、全部いったん消す 233 238 # $DBQuery = "DELETE from foltia_epg where startdatetime > $epgstartdatetime AND ontvchannel = '$ontvepgchannel' "; 234 $DBQuery = "DELETE from foltia_epg where startdatetime > $todaytime AND ontvchannel = '$ontvepgchannel' "; 235 $sth = $dbh->prepare($DBQuery); 236 $sth->execute(); 237 &writelog("xmltv2foltia DELETE EPG $epgstartdatetime:$DBQuery"); 239 $sth = $dbh->prepare($stmt{'xmltv2foltia.chkerase.1'}); 240 $sth->execute($todaytime, $ontvepgchannel); 241 &writelog("xmltv2foltia DELETE EPG $epgstartdatetime:$stmt{'xmltv2foltia.chkerase.1'}"); 238 242 #$currentworkdate = "$today"; 239 243 $currentworkch = $ontvepgchannel ; … … 261 265 if($foltiastarttime > $todaytime){ 262 266 263 my $DBQuery = "SELECT max(epgid) FROM foltia_epg "; 264 $sth = $dbh->prepare($DBQuery); 267 $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); 265 268 $sth->execute(); 266 269 @currentepgid = $sth->fetchrow_array; … … 274 277 #&writelog("xmltv2foltia DEBUG $currentepgid[0] / $newepgid"); 275 278 my $lengthmin = &calclength($foltiastarttime , $foltiaendtime); 276 $newepgid = $dbh->quote($newepgid ); 277 $foltiastarttime = $dbh->quote($foltiastarttime); 278 $foltiaendtime = $dbh->quote($foltiaendtime ); 279 $lengthmin = $dbh->quote($lengthmin ); 280 $channel = $dbh->quote($channel ); 281 $title = $dbh->quote($title); 282 $desc = $dbh->quote($desc); 283 $category = $dbh->quote($category); 284 285 $DBQuery = "insert into foltia_epg values ($newepgid,$foltiastarttime,$foltiaendtime,$lengthmin,$channel,$title,$desc,$category)"; 286 # $DBQuery = $dbh->quote($DBQuery); 287 $sth = $dbh->prepare($DBQuery); 288 $sth->execute(); 289 279 # $newepgid = $dbh->quote($newepgid ); 280 # $foltiastarttime = $dbh->quote($foltiastarttime); 281 # $foltiaendtime = $dbh->quote($foltiaendtime ); 282 # $lengthmin = $dbh->quote($lengthmin ); 283 # $channel = $dbh->quote($channel ); 284 # $title = $dbh->quote($title); 285 # $desc = $dbh->quote($desc); 286 # $category = $dbh->quote($category); 287 288 $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); 289 $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || 290 warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; 290 291 291 292 # &writelog("xmltv2foltia DEBUG $DBQuery");