diff getepg.php @ 152:784e3c82926e

mod: yazucchiさんのパッチ取り込み
author epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
date Sun, 28 Mar 2010 22:13:52 +0900
parents 481e789605e3
children 190a3c46611d
line wrap: on
line diff
--- a/getepg.php	Sat Mar 27 16:04:54 2010 +0900
+++ b/getepg.php	Sun Mar 28 22:13:52 2010 +0900
@@ -14,20 +14,20 @@
   if( ! defined( "BS_EPG_CHANNEL" )  ) define( "BS_EPG_CHANNEL",  "211"  );
   if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8"  );
   if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" );
-  
+
   function check_file( $file ) {
 	// <ゃ≦馹
 	if( ! file_exists( $file ) ) return true;
-	
+
 	// 1篁ヤ<ゃゃ眼
 	if( (time() - filemtime( $file )) > 3600 ) {
 		@unlink( $file );
 		return true;
 	}
-	
+
 	return false;
   }
-  
+
   // 筝純桁慎羞宴顄帥鴻
   $use_para = false;
   $use_para = (function_exists( "pcntl_fork" ) && function_exists( "posix_setsid" ) && function_exists( "pcntl_signal" ) && function_exists("pcntl_setpriority"));
@@ -39,19 +39,19 @@
   }
   
   $settings = Settings::factory();
-  
+
   $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";
-  
+
   if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
-  
+
   // BS
   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 == 0) && check_file($temp_xml_bs) ) {
+	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;
@@ -70,7 +70,8 @@
 	// 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 == 0) && check_file($temp_xml_cs1) ) {
+		if($num < $settings->bs_tuners && check_file($temp_xml_cs1)) {
+
 			$cmdline = "CHANNEL=".CS1_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_cs1;
@@ -86,7 +87,7 @@
 			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 == 0) && check_file($temp_xml_cs2) ) {
+		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;
@@ -103,13 +104,13 @@
 	  	}
   	}
   }
-  
+
   // 遺羈≪
   if( $settings->gr_tuners != 0 ) {
 	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 == 0) && check_file($temp_xml_gr.$value."") ) {
+		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";
 			exec( $cmdline );
 			$cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value."";
@@ -128,8 +129,8 @@
   }
   // 筝х
   if( $use_para ) exit();
-  
+
   garbageClean();			//  筝荀違
   doKeywordReservation();	// 若若篋膣
   exit();
-?>
\ No newline at end of file
+?>