Index: trunk/install/perl/foltialib.pl =================================================================== --- trunk/install/perl/foltialib.pl (リビジョン 94) +++ trunk/install/perl/foltialib.pl (リビジョン 111) @@ -381,7 +381,20 @@ }#endsub makemp4dir - - - +sub pid2sid{ +#番組IDからStation IDを取得 +my $pid = $_[0]; +my $sth; + $sth = $dbh->prepare($stmt{'foltialib.pid2sid.1'}); + $sth->execute($pid); +my @statusinfo = $sth->fetchrow_array; +my $sid = $statusinfo[0]; + +if ($sid eq ""){ + return 0 ; +}else{ + return $sid; +} + +}#end sub pid2sid Index: trunk/install/perl/epgimport.pl =================================================================== --- trunk/install/perl/epgimport.pl (リビジョン 111) +++ trunk/install/perl/epgimport.pl (リビジョン 111) @@ -0,0 +1,242 @@ +#!/usr/bin/perl +# +# +# Anime recording system foltia +# http://www.dcc-jpl.com/soft/foltia/ +# +# epgimport.pl +# +# EPG番組表取得 +# tsを取得してepgdump経由でepgテーブルにインポートします。 +# 内部でxmltv2foltia.plを呼んで実際の追加処理を行います。 +# +# usage +# epgimport.pl [long] #longがつくと一週間分 +# epgimport.pl [stationid] #放送局ID指定でそのチャンネルだけ短時間で取得 +# +# DCC-JPL Japan/foltia project +# + +use DBI; +use DBD::Pg; +use DBD::SQLite; +#use Schedule::At; +#use Time::Local; +use Jcode; + +$path = $0; +$path =~ s/epgimport.pl$//i; +if ($path ne "./"){ +push( @INC, "$path"); +} + +require "foltialib.pl"; + +my $ontvcode = ""; +my $channel = ""; +my @date = (); +my $recpt1path = $toolpath . "/perl/tool/recpt1"; #ほかのキャプチャデバイス作ってる人はココを変更 +my $epgdumppath = $toolpath ."/perl/tool"; #epgdumpのあるディレクトリ +my $xmloutpath = "/tmp"; +my %stations; +my $uset = ""; +my $usebs = ""; +my $usecs = ""; +my $stationid = "" ; +my $rectime = ""; + +#引き数がアルか? +if ( $ARGV[0] eq "long" ){ + #長期番組表取得 + $rectime = 60; + $bsrectime = 120; +}elsif( $ARGV[0] > 0 ){ + $stationid = $ARGV[0]; + $rectime = 3; + $bsrectime = 36; +}else{ + #短期番組表取得 + $rectime = 3; + $bsrectime = 36; +} +#データ量比較 +#3秒 16350 Aug 10 16:21 __27-epg-short.xml +#12秒 56374 Aug 10 16:21 __27-epg-long.xml +#60秒 127735 Aug 10 16:23 __27-epg-velylong.xml + +#重複起動確認 +$processes = &processfind("epgimport.pl"); +if ($processes > 1 ){ +&writelog("epgimport processes exist. exit:"); +exit; +} + + +$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; + +#局指定があるなら、単一放送局指定モード +if ($stationid > 0){ + $sth = $dbh->prepare($stmt{'epgimport.1'}); + $sth->execute($stationid); + @data = $sth->fetchrow_array(); + unless($data[0] == 1){#局の数が1でなければ異常終了 + &writelog("epgimport ERROR Invalid station id ($stationid)."); + exit 1; + }else{ + $sth = $dbh->prepare($stmt{'epgimport.2'}); + $sth->execute($stationid); + @data = $sth->fetchrow_array(); + $channel = $data[0]; + $ontvcode = $data[1]; + &writelog("epgimport DEBUG Single station mode (ch:$channel / $ontvcode)."); + } +}#endif $stationid > 0 + +#地デジ---------------------------------------- +#受信局確認 +if ($channel >= 13 && $channel <= 62){#局指定があるなら + $stations{$channel} = $ontvcode; + $uset = 1; +}elsif($channel >= 100){ + $uset = 0; #地デジ範囲外の局 +}else{ + $sth = $dbh->prepare($stmt{'epgimport.3'}); + $sth->execute(); + + while (@data = $sth->fetchrow_array()) { + $stations{$data[0]} = $data[1]; + }#end while + $uset = 1; +}#end if + +if ($uset == 1){ +foreach $channel ( keys %stations ) { + $ontvcode = $stations{$channel}; + #print "$ontvcode $digitalch\n"; + &chkrecordingschedule; + #print "$recpt1path $channel $rectime $recfolderpath/__$channel.m2t\n"; + $oserr = `$recpt1path $channel $rectime $recfolderpath/__$channel.m2t`; + #print "$epgdumppath/epgdump $ontvcode $recfolderpath/__$channel.m2t $xmloutpath/__$channel-epg.xml\n"; + $oserr = `$epgdumppath/epgdump $ontvcode $recfolderpath/__$channel.m2t $xmloutpath/__$channel-epg.xml`; + #print "cat $xmloutpath/__$channel-epg.xml | $toolpath/perl/xmltv2foltia.pl\n"; + $oserr = `cat $xmloutpath/__$channel-epg.xml | $toolpath/perl/xmltv2foltia.pl`; + unlink "$recfolderpath/__$channel.m2t"; + unlink "$xmloutpath/__$channel-epg.xml"; +}#end foreach +}#endif + +#BS---------------------------------------- +#受信局確認 +if ($channel >= 100 && $channel <= 222 ){#局指定があるなら + $usebs = 1; +}elsif($channel >= 13 && $channel <= 62){ + $usebs = 0; #地デジ局指定の場合、スキップ。 +}elsif($channel >= 223){ + $usebs = 0; #CS局指定の場合もスキップ +}else{ + $sth = $dbh->prepare($stmt{'epgimport.4'}); + $sth->execute(); + @data = $sth->fetchrow_array(); + if ($data[0] > 0 ){ + $usebs = 1; + } +}#end if + +if ($usebs == 1){ + #$ontvcode = $stations{$channel}; + $channel = 211; + #print "$ontvcode $digitalch\n"; + &chkrecordingschedule; + #print "$recpt1path $channel $bsrectime $recfolderpath/__$channel.m2t\n"; + $oserr = `$recpt1path $channel $bsrectime $recfolderpath/__$channel.m2t`; + #print "$epgdumppath/epgdump /BS $recfolderpath/__$channel.m2t $xmloutpath/__$channel-epg.xml\n"; + $oserr = `$epgdumppath/epgdump /BS $recfolderpath/__$channel.m2t $xmloutpath/__$channel-epg.xml`; + #print "cat $xmloutpath/__$channel-epg.xml | $toolpath/perl/xmltv2foltia.pl\n"; + $oserr = `cat $xmloutpath/__$channel-epg.xml | $toolpath/perl/xmltv2foltia.pl`; + unlink "$recfolderpath/__$channel.m2t"; + unlink "$xmloutpath/__$channel-epg.xml"; +}else{ + &writelog("epgimport DEBUG Skip BS.$channel:$usebs"); +} + + + +#CS---------------------------------------- +#CSは取得に時間がかかるがどうしようか +#ひとまずlongモードのときだけ取得 +if ( $ARGV[0] eq "long" ){ +#受信局確認 +if ($channel >= 223 ){#局指定があるなら + $usecs = 1; +}else{ + $sth = $dbh->prepare($stmt{'epgimport.5'}); + $sth->execute(); + @data = $sth->fetchrow_array(); + if ($data[0] > 0 ){ + $usecs = 1; + } +}#end if + +if ($usecs == 1){ +#一気に録画して + $channela = "CS8"; + #print "$ontvcode $digitalch\n"; + &chkrecordingschedule; + #print "$recpt1path $channela $bsrectime $recfolderpath/__$channela.m2t\n"; + $oserr = `$recpt1path $channela $bsrectime $recfolderpath/__$channela.m2t`; + + $channelb = "CS24"; + &chkrecordingschedule; + #print "$recpt1path $channelb $bsrectime $recfolderpath/__$channelb.m2t\n"; + $oserr = `$recpt1path $channelb $bsrectime $recfolderpath/__$channelb.m2t`; + +#時間のかかるepgdumpまとめてあとまわし + #print "nice -n 19 $epgdumppath/epgdump /CS $recfolderpath/__$channela.m2t $xmloutpath/__$channela-epg.xml\n"; + $oserr = `nice -n 19 $epgdumppath/epgdump /CS $recfolderpath/__$channela.m2t $xmloutpath/__$channela-epg.xml`; + #print "cat $xmloutpath/__$channela-epg.xml | $toolpath/perl/xmltv2foltia.pl\n"; + $oserr = `cat $xmloutpath/__$channela-epg.xml | $toolpath/perl/xmltv2foltia.pl`; + unlink "$recfolderpath/__$channela.m2t"; + unlink "$xmloutpath/__$channela-epg.xml"; + + #print "nice -n 19 $epgdumppath/epgdump /CS $recfolderpath/__$channelb.m2t $xmloutpath/__$channelb-epg.xml\n"; + $oserr = `nice -n 19 $epgdumppath/epgdump /CS $recfolderpath/__$channelb.m2t $xmloutpath/__$channelb-epg.xml`; + #print "cat $xmloutpath/__$channelb-epg.xml | $toolpath/perl/xmltv2foltia.pl\n"; + $oserr = `cat $xmloutpath/__$channelb-epg.xml | $toolpath/perl/xmltv2foltia.pl`; + unlink "$recfolderpath/__$channelb.m2t"; + unlink "$xmloutpath/__$channelb-epg.xml"; +}else{ + &writelog("epgimport DEBUG Skip CS."); +}#endif use +}else{ + if ($channel >= 223 ){#局指定があるなら + &writelog("epgimport ERROR CS Station No. was ignored. CS EPG get long mode only."); + } +}#end if long + + +sub chkrecordingschedule{ +#放送予定まで近くなったら、チューナー使いつづけないようにEPG取得中断 +my $now = time() ; +my $fiveminitsafter = time() + 60 * 4; +my $rows = -2; +$now = &epoch2foldate($now); +$fiveminitsafter = &epoch2foldate($fiveminitsafter); + +#録画予定取得 +$sth = $dbh->prepare($stmt{'epgimport.6'}); +$sth->execute($now,$fiveminitsafter,$now,$fiveminitsafter); + +while (@data = $sth->fetchrow_array()) { +# +}#end while + +$rows = $sth->rows; + +if ($rows > 0 ){ + &writelog("epgimport ABORT The recording schedule had approached."); + exit ; +}else{ + &writelog("epgimport DEBUG Near rec program is $rows.:$now:$fiveminitsafter"); +}#end if +}#endsub chkrecordingschedule + Index: trunk/install/perl/folprep.pl =================================================================== --- trunk/install/perl/folprep.pl (リビジョン 94) +++ trunk/install/perl/folprep.pl (リビジョン 111) @@ -29,9 +29,9 @@ require "foltialib.pl"; -#XMLゲット & DB更新 -system("$toolpath/perl/getxml2db.pl"); + +#PID探し +my $pid = $ARGV[0]; #引き数がアルか? -$pid = $ARGV[0] ; if ($pid eq "" ){ #引き数なし出実行されたら、終了 @@ -40,9 +40,17 @@ } -#PID探し -$pid = $ARGV[0]; +my $stationid = ""; +if ($pid <= 0){ + #EPG更新 & DB更新 + $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; + $stationid = &pid2sid($pid); + system("$toolpath/perl/epgimport.pl $stationid"); +}else{ + #XMLゲット & DB更新 + system("$toolpath/perl/getxml2db.pl"); +} #キュー再投入 - &writelog("folprep $toolpath/perl/addpidatq.pl $pid"); +&writelog("folprep $toolpath/perl/addpidatq.pl $pid"); system("$toolpath/perl/addpidatq.pl $pid"); Index: trunk/install/perl/db/Pg.pl =================================================================== --- trunk/install/perl/db/Pg.pl (リビジョン 97) +++ trunk/install/perl/db/Pg.pl (リビジョン 111) @@ -27,4 +27,5 @@ 'foltialib.changefilestatus.1' => "UPDATE foltia_subtitle SET filestatus = ?, lastupdate = now() WHERE pid = ?", 'foltialib.getfilestatus.1' => "SELECT filestatus FROM foltia_subtitle WHERE pid = ?", +'foltialib.pid2sid.1' => "SELECT stationid FROM foltia_subtitle WHERE pid = ?", 'getxml2db.1' => "SELECT count(*) FROM foltia_program WHERE tid = ?", @@ -72,7 +73,37 @@ 'updatem2pfiletable.4' => "INSERT into foltia_mp4files values (?, ?)", -'xmltv2foltia.chkerase.1' => "DELETE FROM foltia_epg WHERE startdatetime > ? AND ontvchannel = ?", -'xmltv2foltia.registdb.1' => "SELECT max(epgid) FROM foltia_epg", -'xmltv2foltia.registdb.2' => "INSERT INTO foltia_epg VALUES (?, ?, ?, ?, ?, ?, ?, ?)", +'xmltv2foltia.replaceepg.1' => "SELECT * FROM foltia_epg WHERE enddatetime > ? AND startdatetime < ? AND ontvchannel = ?", +'xmltv2foltia.commitdb.1' => "DELETE FROM foltia_epg WHERE epgid = ?", +'xmltv2foltia.commitdb.2' => "INSERT INTO foltia_epg VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)" , + +'epgimport.1' => "SELECT count(*) FROM foltia_station WHERE stationid = ?" , +'epgimport.2' => "SELECT digitalch,ontvcode FROM foltia_station WHERE stationid = ?" , +'epgimport.3' => "SELECT digitalch,ontvcode FROM foltia_station WHERE ontvcode is not NULL AND digitalch >= 13 AND digitalch <= 62 ORDER BY digitalch ASC" , +'epgimport.4' => "SELECT count(*) FROM foltia_station WHERE ontvcode is not NULL AND digitalch >= 100 AND digitalch <= 222 ORDER BY digitalch ASC" , +'epgimport.5' => "SELECT count(*) FROM foltia_station WHERE ontvcode is not NULL AND digitalch >= 223 ORDER BY digitalch ASC" , +'epgimport.6' => "SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_subtitle.epgaddedby, +foltia_tvrecord.digital +FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord +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 +AND foltia_subtitle.enddatetime >= ? AND foltia_subtitle.startdatetime < ? +UNION +SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_subtitle.epgaddedby, +foltia_tvrecord.digital +FROM foltia_tvrecord +LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) +LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) +LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) +WHERE foltia_tvrecord.stationid = 0 AND + foltia_subtitle.enddatetime >= ? AND foltia_subtitle.startdatetime < ? " , ); Index: trunk/install/perl/channelscan.pl =================================================================== --- trunk/install/perl/channelscan.pl (リビジョン 111) +++ trunk/install/perl/channelscan.pl (リビジョン 111) @@ -0,0 +1,387 @@ +#!/usr/bin/perl +# +# +# Anime recording system foltia +# http://www.dcc-jpl.com/soft/foltia/ +# +# +# チャンネルスキャン +# 初期インストール時に受信可能局をスキャンします +# +# DCC-JPL Japan/foltia project +# + +#use DBI; +#use DBD::Pg; +#use DBD::SQLite; +#use Schedule::At; +#use Time::Local; +#use Jcode; + +#$path = $0; +#$path =~ s/channelscan.pl$//i; +#if ($path ne "./"){ +#push( @INC, "$path"); +#} + +#require "foltialib.pl"; + +my $recpt1path = "/home/foltia/perl/tool/recpt1"; #ほかのキャプチャデバイス作ってる人はココを変更 +my $epgdumppath = "/home/foltia/perl/tool"; #epgdumpのあるディレクトリ +my $recfolderpath = "/home/foltia/php/tv";#tsを出力するディレクトリ +my $xmloutpath = "/tmp"; +my $channel = 13 ; #地デジチャンネルは13-62 +my $oserr = ""; +my $line = ""; + +print "Initialize\n"; +print "Tool path are\n"; +print "REC:$recpt1path\n"; +print "EPGDUMP:$epgdumppath/epgdump\n"; +print "TS OUT:$recfolderpath/\n"; +print "XML OUT:$xmloutpath/\n"; + +#ツールがあるか確認 +unless (-e "$recpt1path"){ + print "Please install $recpt1path.\n"; + exit 1; +} +unless (-e "$epgdumppath/epgdump"){ + print "Please install $epgdumppath/epgdump.\n"; + exit 1; +} +unless (-e "$recfolderpath"){ + print "Please make directory $recfolderpath.\n"; + exit 1; +} +unless (-e "$xmloutpath"){ + print "Please make directory $xmloutpath.\n"; + exit 1; +} + + +#地デジスキャンループ +for ($channel = 13; $channel <= 62 ; $channel++){ + print "\nChannel: $channel\n"; + $oserr = `$recpt1path $channel 4 $recfolderpath/__$channel.m2t`; + $oserr = `$epgdumppath/epgdump $channel $recfolderpath/__$channel.m2t $xmloutpath/__$channel-epg.xml`; + + if (-s "$xmloutpath/__$channel-epg.xml" ){ + print "\t\t This channel can view : $channel \n"; + open(XML, "< $xmloutpath/__$channel-epg.xml"); + while ( $line = ) { + #Jcode::convert(\$line,'euc','utf8'); + if($line =~ ///g; + #Jcode::convert(\$line,'utf8','euc'); + print "\t\t $channel $line\n"; + }#end if + }#end while + close(XML); + }else{ + print "\t\t Not Available : $channel \n"; + }#end if +}#end for + + +#BSデジタル +$channel = 211; + print "\nBS Digital Scan\n"; + $oserr = `$recpt1path $channel 4 $recfolderpath/__$channel.m2t`; + $oserr = `$epgdumppath/epgdump /BS $recfolderpath/__$channel.m2t $xmloutpath/__$channel-epg.xml`; + + if (-s "$xmloutpath/__$channel-epg.xml" ){ + print "\t\t BS Digital can view : \n"; + open(XML, "< $xmloutpath/__$channel-epg.xml"); + while ( $line = ) { + #Jcode::convert(\$line,'euc','utf8'); + if($line =~ ///g; + #Jcode::convert(\$line,'utf8','euc'); + print "\t\t $line\n"; + }#end if + }#end while + close(XML); + }else{ + print "\t\t Not Available : BS Digital \n"; + }#end if + + +# +# NHK BS1 +# +# +# NHK BS2 +# +# +# NHK BSh +# +# +# BS日テレ +# +# +# BS朝日 +# +# +# BS-TBS +# +# +# BSジャパン +# +# +# BSフジ +# +# +# WOWOW +# +# +# WOWOW2 +# +# +# WOWOW3 +# +# +# スター・チャンネル +# +# +# BS11 +# +# +# TwellV +# +# + +#CSデジタル +$channel = "CS8"; + print "\nCS Digital Scan\n"; + $oserr = `$recpt1path $channel 4 $recfolderpath/__$channel.m2t`; + $oserr = `$epgdumppath/epgdump /CS $recfolderpath/__$channel.m2t $xmloutpath/__$channel-epg.xml`; + + if (-s "$xmloutpath/__$channel-epg.xml" ){ + print "\t\t CS Digital can view : \n"; + open(XML, "< $xmloutpath/__$channel-epg.xml"); + while ( $line = ) { + #Jcode::convert(\$line,'euc','utf8'); + if($line =~ ///g; + #Jcode::convert(\$line,'utf8','euc'); + print "\t\t $line\n"; + }#end if + }#end while + close(XML); + }else{ + print "\t\t Not Available : CS Digital \n"; + }#end if + +# +# スターchプラス +# +# +# 日本映画専門chHD +# +# +# フジテレビCSHD +# +# +# ショップチャンネル +# +# +# ザ・シネマ +# +# +# スカチャンHD800 +# +# +# スカチャン801 +# +# +# スカチャン802 +# +# +# e2プロモ +# +# +# インターローカルTV +# +# +# Jスポーツ ESPN +# +# +# FOX +# +# +# スペースシャワーTV +# +# +# カートゥーン ネット +# +# +# トゥーン・ディズニー +# +# +# 東映チャンネル +# +# +# 衛星劇場 +# +# +# チャンネルNECO +# +# +# 洋画★シネフィル +# +# +# スター・クラシック +# +# +# 時代劇専門チャンネル +# +# +# スーパードラマ +# +# +# AXN +# +# +# ナショジオチャンネル +# +# +# ワンテンポータル +# +# +# ゴルフチャンネル +# +# +# テレ朝チャンネル +# +# +# MTV +# +# +# ミュージック・エア +# +# +# 朝日ニュースター +# +# +# BBCワールド +# +# +# CNNj +# +# +# ジャスト・アイ +# +# +# Jスポーツ 1 +# +# +# Jスポーツ 2 +# +# +# JスポーツPlusH +# +# +# GAORA +# +# +# sky・Aスポーツ+ +# +# +# 宝塚プロモチャンネル +# +# +# SKY・STAGE +# +# +# チャンネル銀河 +# +# +# AT-X +# +# +# ヒストリーチャンネル +# +# +# スカチャン803 +# +# +# スカチャン804 +# +# +# ムービープラスHD +# +# +# ゴルフネットワーク +# +# +# LaLa HD +# +# +# フジテレビ739 +# +# +# フジテレビ721 +# +# +# アニマックス +# +# +# ディスカバリー +# +# +# アニマルプラネット +# +# +# C-TBSウエルカム +# +# +# QVC +# +# +# プライム365.TV +# +# +# ファミリー劇場 +# +# +# TBSチャンネル +# +# +# ディズニーチャンネル +# +# +# MUSIC ON! TV +# +# +# キッズステーション +# +# +# TBSニュースバード +# +# +# CS日本番組ガイド +# +# +# 日テレG+ +# +# +# fashion TV +# +# +# 日テレプラス +# +# +# エコミュージックTV +# +# +# Music Japan TV +# +# +# 日テレNEWS24 +# + + +#CATV +# /home/foltia/perl/tool/recpt1 --b25 C13 10 /home/foltia/php/tv/__C13.m2t +# /home/foltia/perl/tool/epgdump /CS /home/foltia/php/tv/__C13.m2t /tmp/__C13-epg.xml Index: trunk/install/perl/digitaltvrecording.pl =================================================================== --- trunk/install/perl/digitaltvrecording.pl (リビジョン 99) +++ trunk/install/perl/digitaltvrecording.pl (リビジョン 111) @@ -32,5 +32,5 @@ $extendrecendsec = 10; #recording end second. #$startupsleeptime = 52; #process wait(MAX60sec) -$startupsleeptime = 27; #process wait(MAX60sec) +$startupsleeptime = 32; #process wait(MAX60sec) #------------------------------- @@ -373,6 +373,8 @@ if ($recch == 333) { $recch = "CS16";#333ch:アニメシアターX(AT-X) - }elsif($recch == 330){ - $recch = "CS22";#330ch:キッズステーション + #}elsif($recch == 330){ + # $recch = "CS22";#330ch:キッズステーション #HD化により2010/4変更 + }elsif($recch == 335){ + $recch = "CS8";#335ch:キッズステーション HD }elsif($recch == 332){ $recch = "CS20";#332ch:アニマックス Index: trunk/install/perl/schedulecheck.pl =================================================================== --- trunk/install/perl/schedulecheck.pl (リビジョン 94) +++ trunk/install/perl/schedulecheck.pl (リビジョン 111) @@ -53,4 +53,5 @@ }#while - +#EPG更新 +system("$toolpath/perl/epgimport.pl"); } Index: trunk/install/perl/xmltv2foltia.pl =================================================================== --- trunk/install/perl/xmltv2foltia.pl (リビジョン 94) +++ trunk/install/perl/xmltv2foltia.pl (リビジョン 111) @@ -4,16 +4,11 @@ # http://www.dcc-jpl.com/soft/foltia/ # -#xmltv2foltia.pl -#XMLTV日本語版の出力するXMLを受け取り、EPGデータベースに挿入します。 -# -#↓本家に取り込まれたっぽい(未確認) -# -#XMLTVは -# http://www.systemcreate-inc.com/gsxr/pc/mythtv.html#patches -#のパッチをあてたものを想定しています。オリジナルと比較して、サブタイトルや内容など -#より詳細な内容を取得できます。 -# -# usage;perl /usr/bin/tv_grab_jp | ./xmltv2foltia.pl -# +# xmltv2foltia.pl +# +# XMLTV日本語版形式のXMLを受け取り、EPGデータベースに挿入します。 +# アナログ時代はXMLTVを利用していましたが、現在はepgimport.plを使用します。 +# +# usage +# cat /tmp/__27-epg.xml | /home/foltia/perl/xmltv2foltia.pl # # DCC-JPL Japan/foltia project @@ -26,5 +21,5 @@ # http://www.lr.pi.titech.ac.jp/~abekawa/perl/perl_unicode.html use Jcode; -# use Data::Dumper; +use Data::Dumper; use Time::Local; use DBI; @@ -43,11 +38,15 @@ $today = strftime("%Y%m%d", localtime); $todaytime = strftime("%Y%m%d%H%M", localtime); +@deleteepgid = (); # DB Connect $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; -$dbh->{AutoCommit} = 0; while(<>){ #print $_; +s/\xef\xbd\x9e/\xe3\x80\x9c/g; #wavedash +s/\xef\xbc\x8d/\xe2\x88\x92/g; #hyphenminus +s/&#([0-9A-Fa-f]{2,6});/(chr($1))/eg; #'遊戯王5D's'とかの数値参照対応を + Jcode::convert(\$_,'euc','utf8'); # from_to($_, "utf8","euc-jp"); @@ -69,12 +68,4 @@ eval("$_"); #print Dumper($_) ; - -}elsif(/commit; +&commitdb; + #end ################ -sub chkerase{ -# xmltvからきた日付とチャンネルをfoltia epgと比較 +sub replaceepg{ +#消すEPGのIDを配列に追加します my $foltiastarttime = $_[0]; # 14桁 my $ontvepgchannel = $_[1]; -my $epgstartdate = substr($foltiastarttime,0,8); # 8桁 20050807 -my @epgcounts = ""; -my $DBQuery = ""; - -#if ($currentworkdate eq "" ){#初回起動なら -if ( $currentworkch ne $ontvepgchannel){ - - -if ($epgstartdate >= $today){# xmltvtvから今日以降のデータが来ていれば -my $epgstartdatetime = $today * 10000 ; # 200508070000 12桁 -# 新規に入る予定の未来の番組表、全部いったん消す -# $DBQuery = "DELETE from foltia_epg where startdatetime > $epgstartdatetime AND ontvchannel = '$ontvepgchannel' "; - $sth = $dbh->prepare($stmt{'xmltv2foltia.chkerase.1'}); - $sth->execute($todaytime, $ontvepgchannel); - &writelog("xmltv2foltia DELETE EPG $epgstartdatetime:$stmt{'xmltv2foltia.chkerase.1'}"); -#$currentworkdate = "$today"; -$currentworkch = $ontvepgchannel ; -}else{ - &writelog("xmltv2foltia ERROR EPG INVALID:$epgstartdate:$today"); - #exit(); -}# endif xmltvtvから今日のデータが来ていれば -}#end if 初回起動なら - -} +my $foltiaendtime = $_[2]; # 14桁 +my @data = (); + +$foltiastarttime = substr($foltiastarttime,0,12); # 12桁 200508072254 +$foltiaendtime = substr($foltiaendtime,0,12); # 12桁 200508072355 + +$sth = $dbh->prepare($stmt{'xmltv2foltia.replaceepg.1'}); +$sth->execute($foltiastarttime , $foltiaendtime , $ontvepgchannel); + +while (@data = $sth->fetchrow_array()) { + push(@deleteepgid,$data[0]); + #&writelog("xmltv2foltia DEBUG push(\@deleteepgid,$data[0]);"); +}#end while +}#endsub replaceepg + sub registdb{ my $foltiastarttime = $_[0]; @@ -258,50 +242,61 @@ #&writelog("xmltv2foltia DEBUG $foltiastarttime:$foltiaendtime"); - - $foltiastarttime = substr($foltiastarttime,0,12); $foltiaendtime = substr($foltiaendtime,0,12); -if($foltiastarttime > $todaytime){ - - $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); - $sth->execute(); - @currentepgid = $sth->fetchrow_array; - - if ($currentepgid[0] < 1 ){ - $newepgid = 1; - }else{ - $newepgid = $currentepgid[0]; - $newepgid++; - } +if($foltiaendtime > $todaytime){ +# epgidはAUTOINCREMENTに変更した #2010/8/10 +# $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); +# $sth->execute(); +# @currentepgid = $sth->fetchrow_array; +# +# if ($currentepgid[0] < 1 ){ +# $newepgid = 1; +# }else{ +# $newepgid = $currentepgid[0]; +# $newepgid++; +# } #&writelog("xmltv2foltia DEBUG $currentepgid[0] / $newepgid"); my $lengthmin = &calclength($foltiastarttime , $foltiaendtime); -# $newepgid = $dbh->quote($newepgid ); -# $foltiastarttime = $dbh->quote($foltiastarttime); -# $foltiaendtime = $dbh->quote($foltiaendtime ); -# $lengthmin = $dbh->quote($lengthmin ); -# $channel = $dbh->quote($channel ); -# $title = $dbh->quote($title); -# $desc = $dbh->quote($desc); -# $category = $dbh->quote($category); - - $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); - $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || - warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; - + +#print "xmltv2foltia DEBUG :INSERT INTO foltia_epg VALUES ($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category)\n"; +push (@foltiastarttime,$foltiastarttime); +push (@foltiaendtime,$foltiaendtime); +push (@lengthmin,$lengthmin); +push (@channel,$channel); +push (@title,$title); +push (@desc,$desc); +push (@category,$category); +# $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); +# $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; # &writelog("xmltv2foltia DEBUG $DBQuery"); - }else{ #&writelog("xmltv2foltia DEBUG SKIP $foltiastarttime:$foltiaendtime"); }#未来じゃなければ挿入しない +}#end sub registdb + +sub commitdb{ +$dbh->{AutoCommit} = 0; +$dbh->do('BEGIN'); +#print Dumper(\@dbarray); +my $loopcount = @foltiastarttime; +my $i = 0; + +#削除 +foreach $delid (@deleteepgid){ + $sth = $dbh->prepare($stmt{'xmltv2foltia.commitdb.1'}); + $sth->execute( $delid ) || warn "$delid\n"; +# &writelog("xmltv2foltia DEBUG : DELETE FROM foltia_epg WHERE epgid = $delid"); } - - - - - - - +#追加 +for ($i=0;$i<$loopcount;$i++){ + $sth = $dbh->prepare($stmt{'xmltv2foltia.commitdb.2'}); + $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"; +#&writelog("xmltv2foltia DEBUG : INSERT INTO foltia_epg VALUES ( NULL , $foltiastarttime[$i],$foltiaendtime[$i], $lengthmin[$i], $channel[$i], $title[$i], $desc[$i], $category[$i])"); +}# end for +$dbh->do('COMMIT'); +$dbh->{AutoCommit} = 1; +}#end sub commitdb sub removetag(){ Index: trunk/install/perl/ipodtranscode.pl =================================================================== --- trunk/install/perl/ipodtranscode.pl (リビジョン 97) +++ trunk/install/perl/ipodtranscode.pl (リビジョン 111) @@ -306,4 +306,9 @@ # 中間ファイル消す &changefilestatus($pid,$FILESTATUSTRANSCODECOMPLETE); + &updatemp4file(); + }else{ + &writelog("ipodtranscode ERR ; Fail.Giving up! MAQ${mp4filenamestring}.MP4"); + &changefilestatus($pid,999); + } unlink("${filenamebody}_HD.m2t"); unlink("${filenamebody}_tss.m2t"); @@ -311,9 +316,5 @@ unlink("$filenamebody.wav"); unlink("$filenamebody.base.mp4"); - - &updatemp4file(); - }else{ - &writelog("ipodtranscode ERR ; Fail MAQ${mp4filenamestring}.MP4"); - } + } Index: trunk/install/perl/cron_foltia_dayly.sh =================================================================== --- trunk/install/perl/cron_foltia_dayly.sh (リビジョン 66) +++ trunk/install/perl/cron_foltia_dayly.sh (リビジョン 111) @@ -10,7 +10,10 @@ # -# XMLTVをつかってEPG番組表インポート +#デジタル放送から一週間分のEPGを取得 +/home/foltia/perl/epgimport.pl long + +# XMLTVをつかってEPG番組表インポート(アナログ専用旧仕様) # -/usr/bin/perl /usr/bin/tv_grab_jp | /home/foltia/perl/xmltv2foltia.pl +#/usr/bin/perl /usr/bin/tv_grab_jp | /home/foltia/perl/xmltv2foltia.pl # 2つの局設定使うような場合 #/usr/bin/perl /usr/bin/tv_grab_jp --config-file ~/.xmltv/tv_grab_jp.conf.jcom | /home/foltia/perl/xmltv2foltia.pl Index: trunk/install/php/folcast.php =================================================================== --- trunk/install/php/folcast.php (リビジョン 102) +++ trunk/install/php/folcast.php (リビジョン 111) @@ -52,7 +52,7 @@ SELECT foltia_program.tid,foltia_program.title, foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime FROM foltia_subtitle , foltia_program WHERE \"pspfilename\" LIKE 'M%%' AND foltia_program.tid = foltia_subtitle.tid AND foltia_program.tid = $tid -ORDER BY \"enddatetime\" DESC -limit $max offset 0 - "; +ORDER BY enddatetime DESC + limit ? offset 0 +"; $titlequery = " @@ -63,4 +63,5 @@ // $titlers = m_query($con, $query, "DBクエリに失敗しました"); $titlers = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); +// $titlers = sql_query($con, $titlequery, "DBクエリに失敗しました",array($tid)); $rowdata = $titlers->fetch(); $rsstitle = $rowdata[1]; @@ -69,7 +70,10 @@ $query = " SELECT foltia_program.tid,foltia_program.title, -foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime FROM foltia_subtitle , foltia_program WHERE \"pspfilename\" LIKE 'M%%' AND foltia_program.tid = foltia_subtitle.tid ORDER BY \"enddatetime\" DESC -offset 0 limit ? +foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime FROM foltia_subtitle , foltia_program WHERE \"pspfilename\" LIKE 'M%%' AND foltia_program.tid = foltia_subtitle.tid ORDER BY enddatetime DESC +limit ? offset 0 "; + + + $rsstitle = "新規録画"; }//if Index: trunk/install/php/viewepg.php =================================================================== --- trunk/install/php/viewepg.php (リビジョン 94) +++ trunk/install/php/viewepg.php (リビジョン 111) @@ -67,21 +67,25 @@ $yesterday = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday -1 , $startyear)); +$dayyesterday = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday -1 , $startyear)); $today0400 = date ("YmdHi",mktime(4 , 0 , 0, $startmonth , $startday , $startyear)); +$today0800 = date ("YmdHi",mktime(8 , 0 , 0, $startmonth , $startday , $startyear)); $today1200 = date ("YmdHi",mktime(12 , 0 , 0, $startmonth , $startday , $startyear)); +$today1600 = date ("YmdHi",mktime(16 , 0 , 0, $startmonth , $startday , $startyear)); $today2000 = date ("YmdHi",mktime(20 , 0 , 0, $startmonth , $startday , $startyear)); +$today2359 = date ("YmdHi",mktime(23 , 59 , 0, $startmonth , $startday , $startyear)); $day1after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear)); -$day1 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear)); +$day1 = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear)); $day2after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear)); -$day2 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear)); +$day2 = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear)); $day3after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear)); -$day3 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear)); +$day3 = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear)); $day4after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear)); -$day4 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear)); +$day4 = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear)); $day5after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear)); -$day5 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear)); +$day5 = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear)); $day6after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear)); -$day6 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear)); +$day6 = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear)); $day7after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear)); -$day7 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear)); +$day7 = date ("m/d(D)",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear)); @@ -115,5 +119,5 @@ -print "←前の日 現在 当日(4:00 12:00 20:00) 次の日 $day2 $day3 $day4 $day5 $day6 $day7
\n"; +print "←$dayyesterday(前日) 現在 当日(4:00 8:00 12:00 16:00 20:00 24:00) $day1(翌日) $day2 $day3 $day4 $day5 $day6 $day7
\n"; @@ -127,8 +131,12 @@ print " $page / $pages (放送局) "; +for ($i=1;$i<=$pages;$i++){ + print "$i・"; +} + if ($page < $pages){ $nextpage = $page + 1; - print ""; + print ""; } } @@ -158,5 +166,5 @@ SELECT ontvcode FROM foltia_station - WHERE \"ontvcode\" LIKE '%ontvjapan%' + WHERE \"ontvcode\" LIKE '%ontvjapan%' ORDER BY stationid ASC , stationrecch LIMIT ? OFFSET ? Index: trunk/install/mktable.sqlite.txt =================================================================== --- trunk/install/mktable.sqlite.txt (リビジョン 95) +++ trunk/install/mktable.sqlite.txt (リビジョン 111) @@ -62,5 +62,5 @@ drop table foltia_epg; create table foltia_epg ( -epgid integer PRIMARY KEY, +epgid integer PRIMARY KEY AUTOINCREMENT, startdatetime integer, enddatetime integer, @@ -173,5 +173,5 @@ INSERT INTO foltia_station VALUES (397, 'カートゥーンネットワーク', 0, '', '', '', '780', '', '1046.ontvjapan.com',NULL,NULL); INSERT INTO foltia_station VALUES (263, 'アニマックス', 0, '', '', '', '782', '', '1047.ontvjapan.com',NULL,NULL); -INSERT INTO foltia_station VALUES (261, 'キッズステーション', 0, '', '', 'c', '781', '', '1045.ontvjapan.com',NULL,NULL); +INSERT INTO foltia_station VALUES (261, 'キッズステーション', 0, '', '', 'c', '335', '', '1045.ontvjapan.com',NULL,NULL); INSERT INTO foltia_station VALUES (449, 'ディスカバリーチャンネル', 0, '', '', '', '796', '', '1062.ontvjapan.com',NULL,NULL); INSERT INTO foltia_station VALUES (448, 'MONDO21', 0, '', '', '', '722', '', '1049.ontvjapan.com',NULL,NULL); Index: trunk/install/mktable.txt =================================================================== --- trunk/install/mktable.txt (リビジョン 95) +++ trunk/install/mktable.txt (リビジョン 111) @@ -62,5 +62,5 @@ drop table foltia_epg; create table foltia_epg ( -epgid int8 PRIMARY KEY, +epgid int8 PRIMARY KEY SERIAL, startdatetime int8, enddatetime int8, @@ -172,5 +172,5 @@ INSERT INTO foltia_station VALUES (397, 'カートゥーンネットワーク', 0, '', '', '', '780', '', '1046.ontvjapan.com',NULL,NULL); INSERT INTO foltia_station VALUES (263, 'アニマックス', 0, '', '', '', '782', '', '1047.ontvjapan.com',NULL,NULL); -INSERT INTO foltia_station VALUES (261, 'キッズステーション', 0, '', '', 'c', '781', '', '1045.ontvjapan.com',NULL,NULL); +INSERT INTO foltia_station VALUES (261, 'キッズステーション', 0, '', '', 'c', '335', '', '1045.ontvjapan.com',NULL,NULL); INSERT INTO foltia_station VALUES (449, 'ディスカバリーチャンネル', 0, '', '', '', '796', '', '1062.ontvjapan.com',NULL,NULL); INSERT INTO foltia_station VALUES (448, 'MONDO21', 0, '', '', '', '722', '', '1049.ontvjapan.com',NULL,NULL);