view getepg.php @ 84:3ec5ca5e56ca

add: EPG取得並列化版を暫定的に標準に
author yoneda <yoneda@recorder.localnet.mda.or.jp>
date Mon, 01 Mar 2010 12:16:32 +0900
parents 330c83ae8c95
children 549d799d73ae
line wrap: on
line source

#!/usr/bin/php
<?php
  include_once('config.php');
  include_once( INSTALL_PATH . '/DBRecord.class.php' );
  include_once( INSTALL_PATH . '/Reservation.class.php' );
  include_once( INSTALL_PATH . '/Keyword.class.php' );
  include_once( INSTALL_PATH . '/Settings.class.php' );
  
  $settings = Settings::factory();

  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";
  		exec( $cmdline );
  		$cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$settings->temp_xml."_bs";
  		exec( $cmdline );
		$cmdline = INSTALL_PATH."/storeProgram.php BS ".$settings->temp_xml."_bs";
		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 == 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";
			exec( $cmdline );
			$cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$settings->temp_xml."_cs01";
			exec( $cmdline );
			$cmdline = INSTALL_PATH."/storeProgram.php CS ".$settings->temp_xml."_cs01";
			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";
			exec( $cmdline );
			$cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$settings->temp_xml."_cs02";
			exec( $cmdline );
			$cmdline = INSTALL_PATH."/storeProgram.php CS ".$settings->temp_xml."_cs02";
			exec( $cmdline );
			if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
	  	}
  	}
  }
  
  // 遺羈≪
  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) && !file_exists($settings->temp_xml."_".$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."";
			exec( $cmdline );
			$cmdline = INSTALL_PATH."/storeProgram.php GR ".$settings->temp_xml."_".$value."";
			exec( $cmdline );
			if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
  		}
  	}
  }
  
?>