changeset 85:549d799d73ae

mod: ÊÂÎó¥Æ¥¹¥ÈÃæ
author Sushi-k <epgrec@park.mda.or.jp>
date Mon, 01 Mar 2010 16:00:20 +0900
parents 3ec5ca5e56ca
children c29d41d0c945
files config.php.sample getepg.php
diffstat 2 files changed, 60 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/config.php.sample	Mon Mar 01 12:16:32 2010 +0900
+++ b/config.php.sample	Mon Mar 01 16:00:20 2010 +0900
@@ -56,10 +56,18 @@
 	*/
 );
 
-// 以下ã€USE_KUROBON以外ã®å®šæ•°ã¯è¨­å®šä¸è¦ã«ãªã‚Šã¾ã—ãŸ
+
+// BSãƒãƒ¥ãƒ¼ãƒŠãƒ¼ã¨ã—ã¦é»’Friioを用ã„ã¦ã„ã‚‹ã®ãªã‚‰ä¸‹ã®falseã‚’trueã«å¤‰ãˆã¦ãã ã•ã„。
+
+define( "USE_KUROBON", false );
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+// 以é™ã®å¤‰æ•°ãƒ»å®šæ•°ã¯ã»ã¨ã‚“ã©ã®å ´åˆã€å¤‰æ›´ã™ã‚‹å¿…è¦ã¯ã‚ã‚Šã¾ã›ã‚“
+
 
 define( "INSTALL_PATH", dirname(__FILE__) );		// インストールパス
-define( "USE_KUROBON", false );						// BSãƒãƒ¥ãƒ¼ãƒŠãƒ¼ã¨ã—ã¦Friio BS/CSを使ã†ãªã‚‰true
 
 // 以é™ã¯å¿…è¦ã«å¿œã˜ã¦å¤‰æ›´ã™ã‚‹
 
@@ -68,6 +76,15 @@
 define( "COMPLETE_CMD", INSTALL_PATH . "/recomplete.php" );	// 録画終了コマンド
 define( "GEN_THUMBNAIL", INSTALL_PATH . "/gen-thumbnail.sh" );	// サムãƒãƒ¼ãƒ«ç”Ÿæˆã‚¹ã‚¯ãƒªãƒ—ト
 
+// BS/CSã§EPGã‚’å–å¾—ã™ã‚‹ãƒãƒ£ãƒ³ãƒãƒ«
+// 通常ã¯å¤‰ãˆã‚‹å¿…è¦ã¯ã‚ã‚Šã¾ã›ã‚“
+// BSã§epgdumpãŒé »ç¹ã«è½ã¡ã‚‹å ´åˆã¯ã€å—信状態ã®ã„ã„ãƒãƒ£ãƒ³ãƒãƒ«ã«å¤‰ãˆã‚‹ã“ã¨ã§
+// 改善ã™ã‚‹ã‹ã‚‚ã—ã‚Œã¾ã›ã‚“
+
+define( "BS_EPG_CHANNEL",  "211"  );	// BS
+define( "CS1_EPG_CHANNEL", "CS8"  );	// CS1
+define( "CS2_EPG_CHANNEL", "CS24" );	// CS2
+
 
 // 地上デジタルãƒãƒ£ãƒ³ãƒãƒ«ãƒ†ãƒ¼ãƒ–ルsettings/gr_channel.phpãŒå­˜åœ¨ã™ã‚‹ãªã‚‰ãれを
 // 優先ã™ã‚‹
@@ -278,4 +295,4 @@
 	"autorec_mode integer not null default '0',".						// 自動録画ã®ãƒ¢ãƒ¼ãƒ‰02/23/2010追加
 	"weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'"		// 曜日ã€åŒè¿½åŠ 
 );
-?>
\ No newline at end of file
+?>
--- a/getepg.php	Mon Mar 01 12:16:32 2010 +0900
+++ b/getepg.php	Mon Mar 01 16:00:20 2010 +0900
@@ -6,20 +6,44 @@
   include_once( INSTALL_PATH . '/Keyword.class.php' );
   include_once( INSTALL_PATH . '/Settings.class.php' );
   
+  // 後方互æ›æ€§
+  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;
+  }
+  
   $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) && !file_exists($settings->temp_xml."_bs") ) {
-	 	$cmdline = "CHANNEL=211 DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
+	if( ($num == 0) && 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." ".$settings->temp_xml."_bs";
+  		$cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs;
   		exec( $cmdline );
-		$cmdline = INSTALL_PATH."/storeProgram.php BS ".$settings->temp_xml."_bs";
+		$cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs;
 		exec( $cmdline );
   		if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
 	}
@@ -27,22 +51,22 @@
 	// 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) && !file_exists($settings->temp_xml."_cs01") ) {
-			$cmdline = "CHANNEL=CS8 DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
+		if( ($num == 0) && 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." ".$settings->temp_xml."_cs01";
+			$cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1;
 			exec( $cmdline );
-			$cmdline = INSTALL_PATH."/storeProgram.php CS ".$settings->temp_xml."_cs01";
+			$cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1;
 			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 == 0) && !file_exists($settings->temp_xml."_cs02") ) {
-			$cmdline = "CHANNEL=CS24 DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
+		if( ($num == 0) && 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." ".$settings->temp_xml."_cs02";
+			$cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs2;
 			exec( $cmdline );
-			$cmdline = INSTALL_PATH."/storeProgram.php CS ".$settings->temp_xml."_cs02";
+			$cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs2;
 			exec( $cmdline );
 			if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
 	  	}
@@ -54,12 +78,12 @@
 	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) && !file_exists($settings->temp_xml."_".$value."") ) {
+		if( ($num == 0) && 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." ".$settings->temp_xml."_".$value."";
+			$cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value."";
 			exec( $cmdline );
-			$cmdline = INSTALL_PATH."/storeProgram.php GR ".$settings->temp_xml."_".$value."";
+			$cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value."";
 			exec( $cmdline );
 			if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
   		}