comparison getepg.php @ 111:3bed74eca373

change: EPG取得並列化が可能かどうかを判定するように変更
author epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
date Sat, 13 Mar 2010 16:45:29 +0900
parents c29d41d0c945
children b3ba2658a228 481e789605e3
comparison
equal deleted inserted replaced
108:4bd07b03c694 111:3bed74eca373
1 #!/usr/bin/php 1 #!/usr/bin/php
2 <?php 2 <?php
3 include_once('config.php'); 3 $script_path = dirname( __FILE__ );
4 chdir( $script_path );
5 include_once( $script_path . '/config.php');
4 include_once( INSTALL_PATH . '/DBRecord.class.php' ); 6 include_once( INSTALL_PATH . '/DBRecord.class.php' );
5 include_once( INSTALL_PATH . '/Reservation.class.php' ); 7 include_once( INSTALL_PATH . '/Reservation.class.php' );
6 include_once( INSTALL_PATH . '/Keyword.class.php' ); 8 include_once( INSTALL_PATH . '/Keyword.class.php' );
7 include_once( INSTALL_PATH . '/Settings.class.php' ); 9 include_once( INSTALL_PATH . '/Settings.class.php' );
10 include_once( INSTALL_PATH . '/storeProgram.inc.php' );
8 11
9 // 緇剛 12 // 緇剛
10 if( ! defined( "BS_EPG_CHANNEL" ) ) define( "BS_EPG_CHANNEL", "211" ); 13 if( ! defined( "BS_EPG_CHANNEL" ) ) define( "BS_EPG_CHANNEL", "211" );
11 if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8" ); 14 if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8" );
12 if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" ); 15 if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" );
13
14 16
15 function check_file( $file ) { 17 function check_file( $file ) {
16 // <ゃ≦馹 18 // <ゃ≦馹
17 if( ! file_exists( $file ) ) return true; 19 if( ! file_exists( $file ) ) return true;
18 20
22 return true; 24 return true;
23 } 25 }
24 26
25 return false; 27 return false;
26 } 28 }
29
30 // 筝純桁慎羞宴顄帥鴻
31 $use_para = false;
32 $use_para = (function_exists( "pcntl_fork" ) && function_exists( "posix_setsid" ) && function_exists( "pcntl_signal" ) && function_exists("pcntl_setpriority"));
33
27 34
28 $settings = Settings::factory(); 35 $settings = Settings::factory();
29 36
30 $temp_xml_bs = $settings->temp_xml."_bs"; 37 $temp_xml_bs = $settings->temp_xml."_bs";
31 $temp_xml_cs1 = $settings->temp_xml."_cs1"; 38 $temp_xml_cs1 = $settings->temp_xml."_cs1";
41 if( ($num == 0) && check_file($temp_xml_bs) ) { 48 if( ($num == 0) && check_file($temp_xml_bs) ) {
42 $cmdline = "CHANNEL=".BS_EPG_CHANNEL." DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; 49 $cmdline = "CHANNEL=".BS_EPG_CHANNEL." DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
43 exec( $cmdline ); 50 exec( $cmdline );
44 $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs; 51 $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs;
45 exec( $cmdline ); 52 exec( $cmdline );
46 $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs." >/dev/null 2>&1 &"; 53 if( $use_para ) {
47 exec( $cmdline ); 54 $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs." >/dev/null 2>&1 &";
55 exec( $cmdline );
56 }
57 else {
58 storeProgram( "BS", $temp_xml_bs );
59 if( file_exists( $temp_xml_bs ) ) @unlink( $temp_xml_bs );
60 }
48 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); 61 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
49 } 62 }
50 63
51 // CS 64 // CS
52 if ($settings->cs_rec_flg != 0) { 65 if ($settings->cs_rec_flg != 0) {
54 if( ($num == 0) && check_file($temp_xml_cs1) ) { 67 if( ($num == 0) && check_file($temp_xml_cs1) ) {
55 $cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; 68 $cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
56 exec( $cmdline ); 69 exec( $cmdline );
57 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1; 70 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1;
58 exec( $cmdline ); 71 exec( $cmdline );
59 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1." >/dev/null 2>&1 &"; 72 if( $use_para ) {
60 exec( $cmdline ); 73 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1." >/dev/null 2>&1 &";
74 exec( $cmdline );
75 }
76 else {
77 storeProgram( "CS", $temp_xml_cs1 );
78 if( file_exists( $temp_xml_cs1 ) ) @unlink( $temp_xml_cs1 );
79 }
61 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); 80 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
62 } 81 }
63 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); 82 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" );
64 if( ($num == 0) && check_file($temp_xml_cs2) ) { 83 if( ($num == 0) && check_file($temp_xml_cs2) ) {
65 $cmdline = "CHANNEL=".CS2_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; 84 $cmdline = "CHANNEL=".CS2_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
66 exec( $cmdline ); 85 exec( $cmdline );
67 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs2; 86 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs2;
68 exec( $cmdline ); 87 exec( $cmdline );
69 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs2." >/dev/null 2>&1 &"; 88 if( $use_para ) {
70 exec( $cmdline ); 89 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs2." >/dev/null 2>&1 &";
90 exec( $cmdline );
91 }
92 else {
93 storeProgram( "CS", $temp_xml_cs2 );
94 if( file_exists( $temp_xml_cs2 ) ) @unlink( $temp_xml_cs2 );
95 }
71 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); 96 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
72 } 97 }
73 } 98 }
74 } 99 }
75 100
81 if( ($num == 0) && check_file($temp_xml_gr.$value."") ) { 106 if( ($num == 0) && check_file($temp_xml_gr.$value."") ) {
82 $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; 107 $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1";
83 exec( $cmdline ); 108 exec( $cmdline );
84 $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value.""; 109 $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value."";
85 exec( $cmdline ); 110 exec( $cmdline );
86 $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value." >/dev/null 2>&1 &"; 111 if( $use_para ) {
87 exec( $cmdline ); 112 $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value." >/dev/null 2>&1 &";
113 exec( $cmdline );
114 }
115 else {
116 storeProgram( "GR", $temp_xml_gr.$value );
117 if( file_exists( $temp_xml_gr.$value ) ) @unlink( $temp_xml_gr.$value );
118 }
88 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); 119 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data );
89 } 120 }
90 } 121 }
91 } 122 }
123 // 筝х
124 if( $use_para ) exit();
92 125
126 garbageClean(); // 筝荀違
127 doKeywordReservation(); // 若若篋膣
128 exit();
93 ?> 129 ?>