チェンジセット 111: trunk/install/perl
- コミット日時:
- 2010/08/17 01:12:56 (15 年前)
- ファイル:
- 
  - trunk/install/perl/channelscan.pl (追加)
- trunk/install/perl/cron_foltia_dayly.sh (更新) (1 diff)
- trunk/install/perl/db/Pg.pl (更新) (2 diffs)
- trunk/install/perl/digitaltvrecording.pl (更新) (2 diffs)
- trunk/install/perl/epgimport.pl (追加)
- trunk/install/perl/folprep.pl (更新) (2 diffs)
- trunk/install/perl/foltialib.pl (更新) (1 diff)
- trunk/install/perl/ipodtranscode.pl (更新) (2 diffs)
- trunk/install/perl/schedulecheck.pl (更新) (1 diff)
- trunk/install/perl/xmltv2foltia.pl (更新) (8 diffs)
 
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
- trunk/install/perl/cron_foltia_dayly.sh- r66 - r111 - 10 - 10 - # - 11 - 11 - 12 - # XMLTVをつかってEPG番組表インポート - 12 - #デジタル放送から一週間分のEPGを取得 - 13 - /home/foltia/perl/epgimport.pl long - 14 - 15 - # XMLTVをつかってEPG番組表インポート(アナログ専用旧仕様) - 13 - 16 - # - 14 - /usr/bin/perl /usr/bin/tv_grab_jp | /home/foltia/perl/xmltv2foltia.pl- 17 - #/usr/bin/perl /usr/bin/tv_grab_jp | /home/foltia/perl/xmltv2foltia.pl - 15 - 18 - # 2つの局設定使うような場合 - 16 - 19 - #/usr/bin/perl /usr/bin/tv_grab_jp --config-file ~/.xmltv/tv_grab_jp.conf.jcom | /home/foltia/perl/xmltv2foltia.pl 
- trunk/install/perl/db/Pg.pl- r97 - r111 - 27 - 27 - 'foltialib.changefilestatus.1' => "UPDATE foltia_subtitle SET filestatus = ?, lastupdate = now() WHERE pid = ?", - 28 - 28 - 'foltialib.getfilestatus.1' => "SELECT filestatus FROM foltia_subtitle WHERE pid = ?", - 29 - 'foltialib.pid2sid.1' => "SELECT stationid FROM foltia_subtitle WHERE pid = ?", - 29 - 30 - 30 - 31 - 'getxml2db.1' => "SELECT count(*) FROM foltia_program WHERE tid = ?", - … - … - 72 - 73 - 'updatem2pfiletable.4' => "INSERT into foltia_mp4files values (?, ?)", - 73 - 74 - 74 - 'xmltv2foltia.chkerase.1' => "DELETE FROM foltia_epg WHERE startdatetime > ? AND ontvchannel = ?", - 75 - 'xmltv2foltia.registdb.1' => "SELECT max(epgid) FROM foltia_epg", - 76 - 'xmltv2foltia.registdb.2' => "INSERT INTO foltia_epg VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - 75 - 'xmltv2foltia.replaceepg.1' => "SELECT * FROM foltia_epg WHERE enddatetime > ? AND startdatetime < ? AND ontvchannel = ?", - 76 - 'xmltv2foltia.commitdb.1' => "DELETE FROM foltia_epg WHERE epgid = ?", - 77 - 'xmltv2foltia.commitdb.2' => "INSERT INTO foltia_epg VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)" , - 78 - 79 - 'epgimport.1' => "SELECT count(*) FROM foltia_station WHERE stationid = ?" , - 80 - 'epgimport.2' => "SELECT digitalch,ontvcode FROM foltia_station WHERE stationid = ?" , - 81 - 'epgimport.3' => "SELECT digitalch,ontvcode FROM foltia_station WHERE ontvcode is not NULL AND digitalch >= 13 AND digitalch <= 62 ORDER BY digitalch ASC" , - 82 - 'epgimport.4' => "SELECT count(*) FROM foltia_station WHERE ontvcode is not NULL AND digitalch >= 100 AND digitalch <= 222 ORDER BY digitalch ASC" , - 83 - 'epgimport.5' => "SELECT count(*) FROM foltia_station WHERE ontvcode is not NULL AND digitalch >= 223 ORDER BY digitalch ASC" , - 84 - 'epgimport.6' => "SELECT - 85 - foltia_program.tid, stationname, foltia_program.title, - 86 - foltia_subtitle.countno, foltia_subtitle.subtitle, - 87 - foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, - 88 - foltia_tvrecord.bitrate, foltia_subtitle.startoffset, - 89 - foltia_subtitle.pid, foltia_subtitle.epgaddedby, - 90 - foltia_tvrecord.digital - 91 - FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord - 92 - WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid - 93 - AND foltia_subtitle.enddatetime >= ? AND foltia_subtitle.startdatetime < ? - 94 - UNION - 95 - SELECT - 96 - foltia_program.tid, stationname, foltia_program.title, - 97 - foltia_subtitle.countno, foltia_subtitle.subtitle, - 98 - foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, - 99 - foltia_tvrecord.bitrate, foltia_subtitle.startoffset, - 100 - foltia_subtitle.pid, foltia_subtitle.epgaddedby, - 101 - foltia_tvrecord.digital - 102 - FROM foltia_tvrecord - 103 - LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) - 104 - LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) - 105 - LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) - 106 - WHERE foltia_tvrecord.stationid = 0 AND - 107 - foltia_subtitle.enddatetime >= ? AND foltia_subtitle.startdatetime < ? " , - 77 - 108 - 78 - 109 - ); 
- trunk/install/perl/digitaltvrecording.pl- r99 - r111 - 32 - 32 - $extendrecendsec = 10; #recording end second. - 33 - 33 - #$startupsleeptime = 52; #process wait(MAX60sec) - 34 - $startupsleeptime = - 27; #process wait(MAX60sec)- 34 - $startupsleeptime = 32; #process wait(MAX60sec) - 35 - 35 - #------------------------------- - 36 - 36 - … - … - 373 - 373 - if ($recch == 333) { - 374 - 374 - $recch = "CS16";#333ch:アニメシアターX(AT-X) - 375 - }elsif($recch == 330){ - 376 - $recch = "CS22";#330ch:キッズステーション - 375 - #}elsif($recch == 330){ - 376 - # $recch = "CS22";#330ch:キッズステーション #HD化により2010/4変更 - 377 - }elsif($recch == 335){ - 378 - $recch = "CS8";#335ch:キッズステーション HD - 377 - 379 - }elsif($recch == 332){ - 378 - 380 - $recch = "CS20";#332ch:アニマックス 
- trunk/install/perl/folprep.pl- r94 - r111 - 29 - 29 - require "foltialib.pl"; - 30 - 30 - 31 - #XMLゲット & DB更新 - 32 - system("$toolpath/perl/getxml2db.pl"); - 31 - 32 - #PID探し - 33 - my $pid = $ARGV[0]; - 33 - 34 - 34 - 35 - #引き数がアルか? - 35 - $pid = $ARGV[0] ;- 36 - 36 - if ($pid eq "" ){ - 37 - 37 - #引き数なし出実行されたら、終了 - … - … - 40 - 40 - } - 41 - 41 - 42 - #PID探し - 43 - $pid = $ARGV[0]; - 42 - my $stationid = ""; - 43 - if ($pid <= 0){ - 44 - #EPG更新 & DB更新 - 45 - $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; - 46 - $stationid = &pid2sid($pid); - 47 - system("$toolpath/perl/epgimport.pl $stationid"); - 48 - }else{ - 49 - #XMLゲット & DB更新 - 50 - system("$toolpath/perl/getxml2db.pl"); - 51 - } - 44 - 52 - 45 - 53 - #キュー再投入 - 46 - 54 - &writelog("folprep $toolpath/perl/addpidatq.pl $pid"); - 47 - 55 - system("$toolpath/perl/addpidatq.pl $pid"); - 48 - 56 
- trunk/install/perl/foltialib.pl- r94 - r111 - 381 - 381 - }#endsub makemp4dir - 382 - 382 - 383 - 384 - 385 - 383 - sub pid2sid{ - 384 - #番組IDからStation IDを取得 - 385 - my $pid = $_[0]; - 386 - my $sth; - 387 - $sth = $dbh->prepare($stmt{'foltialib.pid2sid.1'}); - 388 - $sth->execute($pid); - 389 - my @statusinfo = $sth->fetchrow_array; - 390 - my $sid = $statusinfo[0]; - 391 - 392 - if ($sid eq ""){ - 393 - return 0 ; - 394 - }else{ - 395 - return $sid; - 396 - } - 397 - 398 - }#end sub pid2sid - 386 - 399 - 387 - 400 
- trunk/install/perl/ipodtranscode.pl- r97 - r111 - 306 - 306 - # 中間ファイル消す - 307 - 307 - &changefilestatus($pid,$FILESTATUSTRANSCODECOMPLETE); - 308 - &updatemp4file(); - 309 - }else{ - 310 - &writelog("ipodtranscode ERR ; Fail.Giving up! MAQ${mp4filenamestring}.MP4"); - 311 - &changefilestatus($pid,999); - 312 - } - 308 - 313 - unlink("${filenamebody}_HD.m2t"); - 309 - 314 - unlink("${filenamebody}_tss.m2t"); - … - … - 311 - 316 - unlink("$filenamebody.wav"); - 312 - 317 - unlink("$filenamebody.base.mp4"); - 313 - 314 - &updatemp4file(); - 315 - }else{ - 316 - &writelog("ipodtranscode ERR ; Fail MAQ${mp4filenamestring}.MP4"); - 317 - } - 318 - 318 - 319 - } - 319 - 320 
- trunk/install/perl/schedulecheck.pl- r94 - r111 - 53 - 53 - }#while - 54 - 54 - 55 - 55 - #EPG更新 - 56 - system("$toolpath/perl/epgimport.pl"); - 56 - 57 - } 
- trunk/install/perl/xmltv2foltia.pl- r94 - r111 - 4 - 4 - # http://www.dcc-jpl.com/soft/foltia/ - 5 - 5 - # - 6 - #xmltv2foltia.pl - 7 - #XMLTV日本語版の出力するXMLを受け取り、EPGデータベースに挿入します。 - 8 - # - 9 - #↓本家に取り込まれたっぽい(未確認) - 10 - # - 11 - #XMLTVは - 12 - # http://www.systemcreate-inc.com/gsxr/pc/mythtv.html#patches - 13 - #のパッチをあてたものを想定しています。オリジナルと比較して、サブタイトルや内容など - 14 - #より詳細な内容を取得できます。 - 15 - # - 16 - # usage;perl /usr/bin/tv_grab_jp | ./xmltv2foltia.pl - 17 - # - 6 - # xmltv2foltia.pl - 7 - # - 8 - # XMLTV日本語版形式のXMLを受け取り、EPGデータベースに挿入します。 - 9 - # アナログ時代はXMLTVを利用していましたが、現在はepgimport.plを使用します。 - 10 - # - 11 - # usage - 12 - # cat /tmp/__27-epg.xml | /home/foltia/perl/xmltv2foltia.pl - 18 - 13 - # - 19 - 14 - # DCC-JPL Japan/foltia project - … - … - 26 - 21 - # http://www.lr.pi.titech.ac.jp/~abekawa/perl/perl_unicode.html - 27 - 22 - use Jcode; - 28 - #use Data::Dumper;- 23 - use Data::Dumper; - 29 - 24 - use Time::Local; - 30 - 25 - use DBI; - … - … - 43 - 38 - $today = strftime("%Y%m%d", localtime); - 44 - 39 - $todaytime = strftime("%Y%m%d%H%M", localtime); - 40 - @deleteepgid = (); - 45 - 41 - 46 - 42 - # DB Connect - 47 - 43 - $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; - 48 - $dbh->{AutoCommit} = 0;- 49 - 44 - 50 - 45 - while(<>){ - 51 - 46 - #print $_; - 47 - s/\xef\xbd\x9e/\xe3\x80\x9c/g; #wavedash - 48 - s/\xef\xbc\x8d/\xe2\x88\x92/g; #hyphenminus - 49 - s/&#([0-9A-Fa-f]{2,6});/(chr($1))/eg; #'遊戯王5D's'とかの数値参照対応を - 50 - 52 - 51 - Jcode::convert(\$_,'euc','utf8'); - 53 - 52 - # from_to($_, "utf8","euc-jp"); - … - … - 69 - 68 - eval("$_"); - 70 - 69 - #print Dumper($_) ; - 71 - 72 - }elsif(/<display-name lang=\"ja_JP/){- 73 - s/^[\s]*//gio;- 74 - chomp();- 75 - $channel{ja} = &removetag($_);- 76 - #print Dumper($_) ;- 77 - #print "$result \n";- 78 - 79 - 70 - 80 - 71 - }elsif(/<display-name lang=\"ja_JP/){ - … - … - 136 - 127 - chomp(); - 137 - 128 - $item{title} = &removetag($_); - 129 - $item{title} =~ s/【.*】//g;#【解】とか - 130 - $item{title} =~ s/\[.*\]//g;#[二]とか - 138 - 131 - #print Dumper($_) ; - 139 - 132 - #print "$result \n"; - … - … - 188 - 181 - #登録処理はココで - 189 - 182 - #&writelog("xmltv2foltia DEBUG call chkerase $item{'start'},$item{'channel'}"); - 190 - 191 - & - chkerase($item{'start'}, $item{'channel'});- 183 - #旧仕様 #&chkerase($item{'start'}, $item{'channel'}); - 184 - &replaceepg($item{'start'}, $item{'channel'},$item{'stop'}); - 192 - 185 - if ($item{'subtitle'} ne "" ){ - 193 - 186 - $registdesc = $item{'subtitle'}." ".$item{'desc'}; - … - … - 215 - 208 - }# endif - 216 - 209 - }# while - 217 - 218 - $dbh->commit; - 210 - &commitdb; - 211 - 219 - 212 - 220 - 213 - #end - 221 - 214 - ################ - 222 - 215 - 223 - sub - chkerase{- 224 - # - xmltvからきた日付とチャンネルをfoltia epgと比較- 216 - sub replaceepg{ - 217 - #消すEPGのIDを配列に追加します - 225 - 218 - my $foltiastarttime = $_[0]; # 14桁 - 226 - 219 - my $ontvepgchannel = $_[1]; - 227 - my $epgstartdate = substr($foltiastarttime,0,8); # 8桁 20050807 - 228 - my @epgcounts = ""; - 229 - my $DBQuery = ""; - 230 - 231 - #if ($currentworkdate eq "" ){#初回起動なら - 232 - if ( $currentworkch ne $ontvepgchannel){ - 233 - 234 - 235 - if ($epgstartdate >= $today){# xmltvtvから今日以降のデータが来ていれば - 236 - my $epgstartdatetime = $today * 10000 ; # 200508070000 12桁 - 237 - # 新規に入る予定の未来の番組表、全部いったん消す - 238 - # $DBQuery = "DELETE from foltia_epg where startdatetime > $epgstartdatetime AND ontvchannel = '$ontvepgchannel' "; - 239 - $sth = $dbh->prepare($stmt{'xmltv2foltia.chkerase.1'}); - 240 - $sth->execute($todaytime, $ontvepgchannel); - 241 - &writelog("xmltv2foltia DELETE EPG $epgstartdatetime:$stmt{'xmltv2foltia.chkerase.1'}"); - 242 - #$currentworkdate = "$today"; - 243 - $currentworkch = $ontvepgchannel ; - 244 - }else{ - 245 - &writelog("xmltv2foltia ERROR EPG INVALID:$epgstartdate:$today"); - 246 - #exit(); - 247 - }# endif xmltvtvから今日のデータが来ていれば - 248 - }#end if 初回起動なら - 249 - 250 - } - 220 - my $foltiaendtime = $_[2]; # 14桁 - 221 - my @data = (); - 222 - 223 - $foltiastarttime = substr($foltiastarttime,0,12); # 12桁 200508072254 - 224 - $foltiaendtime = substr($foltiaendtime,0,12); # 12桁 200508072355 - 225 - 226 - $sth = $dbh->prepare($stmt{'xmltv2foltia.replaceepg.1'}); - 227 - $sth->execute($foltiastarttime , $foltiaendtime , $ontvepgchannel); - 228 - 229 - while (@data = $sth->fetchrow_array()) { - 230 - push(@deleteepgid,$data[0]); - 231 - #&writelog("xmltv2foltia DEBUG push(\@deleteepgid,$data[0]);"); - 232 - }#end while - 233 - }#endsub replaceepg - 234 - 251 - 235 - sub registdb{ - 252 - 236 - my $foltiastarttime = $_[0]; - … - … - 258 - 242 - 259 - 243 - #&writelog("xmltv2foltia DEBUG $foltiastarttime:$foltiaendtime"); - 260 - 261 - 262 - 244 - $foltiastarttime = substr($foltiastarttime,0,12); - 263 - 245 - $foltiaendtime = substr($foltiaendtime,0,12); - 264 - 246 - 265 - if($foltia - starttime > $todaytime){- 266 - 267 - $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'});- 268 - $sth->execute();- 269 - @currentepgid = $sth->fetchrow_array;- 270 - 271 - if ($currentepgid[0] < 1 ){- 272 - $newepgid = 1;- 273 - }else{- 274 - $newepgid = $currentepgid[0];- 275 - $newepgid++;- 276 - }- 247 - if($foltiaendtime > $todaytime){ - 248 - # epgidはAUTOINCREMENTに変更した #2010/8/10 - 249 - # $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); - 250 - # $sth->execute(); - 251 - # @currentepgid = $sth->fetchrow_array; - 252 - # - 253 - # if ($currentepgid[0] < 1 ){ - 254 - # $newepgid = 1; - 255 - # }else{ - 256 - # $newepgid = $currentepgid[0]; - 257 - # $newepgid++; - 258 - # } - 277 - 259 - #&writelog("xmltv2foltia DEBUG $currentepgid[0] / $newepgid"); - 278 - 260 - my $lengthmin = &calclength($foltiastarttime , $foltiaendtime); - 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"; - 291 - 261 - 262 - #print "xmltv2foltia DEBUG :INSERT INTO foltia_epg VALUES ($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category)\n"; - 263 - push (@foltiastarttime,$foltiastarttime); - 264 - push (@foltiaendtime,$foltiaendtime); - 265 - push (@lengthmin,$lengthmin); - 266 - push (@channel,$channel); - 267 - push (@title,$title); - 268 - push (@desc,$desc); - 269 - push (@category,$category); - 270 - # $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); - 271 - # $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; - 292 - 272 - # &writelog("xmltv2foltia DEBUG $DBQuery"); - 293 - 294 - 273 - }else{ - 295 - 274 - #&writelog("xmltv2foltia DEBUG SKIP $foltiastarttime:$foltiaendtime"); - 296 - 275 - }#未来じゃなければ挿入しない - 297 - 276 - 277 - }#end sub registdb - 278 - 279 - sub commitdb{ - 280 - $dbh->{AutoCommit} = 0; - 281 - $dbh->do('BEGIN'); - 282 - #print Dumper(\@dbarray); - 283 - my $loopcount = @foltiastarttime; - 284 - my $i = 0; - 285 - 286 - #削除 - 287 - foreach $delid (@deleteepgid){ - 288 - $sth = $dbh->prepare($stmt{'xmltv2foltia.commitdb.1'}); - 289 - $sth->execute( $delid ) || warn "$delid\n"; - 290 - # &writelog("xmltv2foltia DEBUG : DELETE FROM foltia_epg WHERE epgid = $delid"); - 298 - 291 - } - 299 - 300 - 301 - 302 - 303 - 304 - 305 - 292 - #追加 - 293 - for ($i=0;$i<$loopcount;$i++){ - 294 - $sth = $dbh->prepare($stmt{'xmltv2foltia.commitdb.2'}); - 295 - $sth->execute( $foltiastarttime[$i],$foltiaendtime[$i], $lengthmin[$i], $channel[$i], $title[$i], $desc[$i], $category[$i]) || warn "error: $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; - 296 - #&writelog("xmltv2foltia DEBUG : INSERT INTO foltia_epg VALUES ( NULL , $foltiastarttime[$i],$foltiaendtime[$i], $lengthmin[$i], $channel[$i], $title[$i], $desc[$i], $category[$i])"); - 297 - }# end for - 298 - $dbh->do('COMMIT'); - 299 - $dbh->{AutoCommit} = 1; - 300 - }#end sub commitdb - 306 - 301 - 307 - 302 - sub removetag(){ 


