From 235d2edceae8a765f4514a9d4bd77da5cf4048cc Mon Sep 17 00:00:00 2001 From: "epgrec@park.mda.or.jp" Date: Sun, 3 Jun 2012 18:46:36 +0900 Subject: [PATCH 1/1] =?utf8?q?modified:=20=20=20epgwakealarm.php=20?= =?utf8?q?=E7=9C=81=E9=9B=BB=E5=8A=9B=E5=B0=91=E3=81=97=E4=BF=AE=E6=AD=A3?= =?utf8?q?=20modified:=20=20=20getepg.php=20=E7=9C=81=E9=9B=BB=E5=8A=9B?= =?utf8?q?=E5=B0=91=E3=81=97=E4=BF=AE=E6=AD=A3|epgdump=E4=B8=A6=E5=88=97?= =?utf8?q?=E5=8C=96=20modified:=20=20=20storeProgram.php=20epgdump?= =?utf8?q?=E4=B8=A6=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- epgwakealarm.php | 1 - getepg.php | 61 ++++++++++++++++++++++---------------------------------- storeProgram.php | 45 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 64 insertions(+), 43 deletions(-) diff --git a/epgwakealarm.php b/epgwakealarm.php index f37ae3e..0a30c18 100755 --- a/epgwakealarm.php +++ b/epgwakealarm.php @@ -32,7 +32,6 @@ else if( (intval($wakeupvars->getepg_time) + intval($settings->getepg_timer) * 3600 ) <= time() ) { $wakeupvars->reason = "getepg"; exec( INSTALL_PATH."/getepg.php >/dev/null 2>&1" ); - $wakeupvars->getepg_time = time(); } else { $wakeupvars->reason = "other"; diff --git a/getepg.php b/getepg.php index a4fc916..63e1bde 100755 --- a/getepg.php +++ b/getepg.php @@ -24,11 +24,6 @@ if( pcntl_fork() != 0 ) exit; pcntl_signal(SIGTERM, "handler"); - pcntl_signal(SIGKILL, "handler"); - pcntl_signal(SIGSTOP, "handler"); - pcntl_signal(SIGINT , "handler"); - pcntl_signal(SIGALRM, "handler"); - fclose(STDIN); fclose(STDOUT); @@ -86,10 +81,10 @@ $cs2_proc = false; - $temp_xml_bs = $settings->temp_xml."_bs"; - $temp_xml_cs1 = $settings->temp_xml."_cs1"; - $temp_xml_cs2 = $settings->temp_xml."_cs2"; - $temp_xml_gr = $settings->temp_xml."_gr"; + $temp_data_bs = $settings->temp_data.".bs"; + $temp_data_cs1 = $settings->temp_data.".cs1"; + $temp_data_cs2 = $settings->temp_data.".cs2"; + $temp_data_gr = $settings->temp_data.".gr"; if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); @@ -97,40 +92,31 @@ if( $settings->bs_tuners != 0 ) { // 録画重複チェック $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); - if($num < $settings->bs_tuners && check_file($temp_xml_bs)) { - $cmdline = "CHANNEL=".BS_EPG_CHANNEL." DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; - exec( $cmdline ); - $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs; + if($num < $settings->bs_tuners && check_file($temp_data_bs)) { + $cmdline = "CHANNEL=".BS_EPG_CHANNEL." DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$temp_data_bs." ".DO_RECORD . " >/dev/null 2>&1"; exec( $cmdline ); - $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs; + $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_data_bs; $bs_proc = epgrec_exec( $cmdline ); - if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); } // CS if ($settings->cs_rec_flg != 0) { $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); - if($num < $settings->bs_tuners && check_file($temp_xml_cs1)) { + if($num < $settings->bs_tuners && check_file($temp_data_cs1)) { - $cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; + $cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$temp_data_cs1." ".DO_RECORD . " >/dev/null 2>&1"; exec( $cmdline ); - $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1; - exec( $cmdline ); - $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1; + $cmdline = INSTALL_PATH."/storeProgram.php CS1 ".$temp_data_cs1; $cs1_proc = epgrec_exec($cmdline); - if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); } $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); - if( ($num < $settings->bs_tuners) && check_file($temp_xml_cs2) ) { - $cmdline = "CHANNEL=".CS2_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; - exec( $cmdline ); - $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs2; + if( ($num < $settings->bs_tuners) && check_file($temp_data_cs2) ) { + $cmdline = "CHANNEL=".CS2_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$temp_data_cs2." ".DO_RECORD . " >/dev/null 2>&1"; exec( $cmdline ); - $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs2; + $cmdline = INSTALL_PATH."/storeProgram.php CS2 ".$temp_data_cs2; $cs2_proc = epgrec_exec( $cmdline ); - if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); } } } @@ -140,14 +126,11 @@ foreach( $GR_CHANNEL_MAP as $key=>$value ){ // 録画重複チェック $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" ); - if($num < $settings->gr_tuners && check_file($temp_xml_gr.$value."")) { - $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; + if($num < $settings->gr_tuners && check_file($temp_data_gr.$value."")) { + $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$temp_data_gr.$value." ".DO_RECORD . " >/dev/null 2>&1"; exec( $cmdline ); - $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value.""; - exec( $cmdline ); - $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value; + $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_data_gr.$value." ".$key; $gr_procs[] = epgrec_exec( $cmdline ); - if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); } } } @@ -188,20 +171,24 @@ doKeywordReservation(); // キーワード予約 if( intval($settings->use_power_reduce) != 0 ) { - // 起動した理由を調べる if( file_exists(INSTALL_PATH. "/settings/wakeupvars.xml") ) { $wakeupvars_text = file_get_contents( INSTALL_PATH. "/settings/wakeupvars.xml" ); $wakeupvars = new SimpleXMLElement($wakeupvars_text); + + // getepg終了時を書込み + $wakeupvars->getepg_time = time(); + // 起動理由を調べる if( strcasecmp( "getepg", $wakeupvars->reason ) == 0 ) { // 1時間以内に録画はないか? $count = DBRecord::countRecords( RESERVE_TBL, " WHERE complete <> '1' AND starttime < addtime( now(), '01:00:00') AND endtime > now()" ); if( $count != 0 ) { // 録画があるなら録画起動にして終了 $wakeupvars->reason = "reserve"; - $wakeupvars->asXML(INSTALL_PATH. "/settings/wakeupvars.xml"); - exit(); } - exec( $settings->shutdown . " -h +".$settings->wakeup_before ); + else { + exec( $settings->shutdown . " -h +".$settings->wakeup_before ); + } } + $wakeupvars->asXML(INSTALL_PATH. "/settings/wakeupvars.xml"); } } exit(); diff --git a/storeProgram.php b/storeProgram.php index a6f1194..9a84f50 100755 --- a/storeProgram.php +++ b/storeProgram.php @@ -4,8 +4,9 @@ chdir( $script_path ); include_once( $script_path . '/config.php'); - $type = $argv[1]; // BS CS GR - $file = $argv[2]; // XMLファイル + $type = $argv[1]; // BS CS1 CS2 GR + $file = $argv[2]; // TSファイル + $key = ""; // プライオリティ低に pcntl_setpriority(20); @@ -15,13 +16,47 @@ include_once( INSTALL_PATH . '/Keyword.class.php' ); include_once( INSTALL_PATH . '/Settings.class.php' ); include_once( INSTALL_PATH . '/storeProgram.inc.php' ); + include_once( INSTALL_PATH . "/reclib.php" ); + $settings = Settings::factory(); - if( file_exists( $file ) ) { - storeProgram( $type, $file ); - @unlink( $file ); + $xmlfile = ""; + $cmdline = $settings->epgdump." "; + + if( $type === "GR" ) { + $key = $argv[3]; // key + $xmlfile = $settings->temp_xml.$key.""; + $cmdline .= $key." ".$file." ".$xmlfile; + } + else if( $type === "CS1" ) { + $type = "CS"; + $xmlfile = $settings->temp_xml."_cs1"; + $cmdline .= "/CS ".$file." ".$xmlfile; } + else if( $type === "CS2" ) { + $type = "CS"; + $xmlfile = $settings->temp_xml."_cs2"; + $cmdline .= "/CS ".$file." ".$xmlfile; + } + else if( $type === "BS" ) { + $xmlfile = $settings->temp_xml."_bs"; + $cmdline .= "/BS ".$file." ".$xmlfile; + } + else exit(); + + exec( $cmdline ); + if( file_exists( $xmlfile ) ) { + storeProgram( $type, $xmlfile ); + @unlink( $xmlfile ); + } + else { + reclog( "storeProgram:: 正常な".$xmlfile."が作成されなかった模様(放送間帯でないなら問題ありません)", EPGREC_WARN ); + } + + if( file_exists( $file ) ) @unlink( $file ); + + /* garbageClean(); // 不要プログラム削除 doKeywordReservation(); // キーワード予約 -- 2.11.0