Mercurial > epgrec.yaz
comparison getepg.php @ 92:e2c37cc736db
merged with upstream
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 02 Mar 2010 23:20:06 +0900 |
parents | 057ca53de6ca |
children | b3ba2658a228 |
comparison
equal
deleted
inserted
replaced
91:f6b909678e51 | 92:e2c37cc736db |
---|---|
3 include_once('config.php'); | 3 include_once('config.php'); |
4 include_once( INSTALL_PATH . '/DBRecord.class.php' ); | 4 include_once( INSTALL_PATH . '/DBRecord.class.php' ); |
5 include_once( INSTALL_PATH . '/Reservation.class.php' ); | 5 include_once( INSTALL_PATH . '/Reservation.class.php' ); |
6 include_once( INSTALL_PATH . '/Keyword.class.php' ); | 6 include_once( INSTALL_PATH . '/Keyword.class.php' ); |
7 include_once( INSTALL_PATH . '/Settings.class.php' ); | 7 include_once( INSTALL_PATH . '/Settings.class.php' ); |
8 | 8 |
9 // 後方互換性 | 9 // 後方互換性 |
10 if( ! defined( "BS_EPG_CHANNEL" ) ) define( "BS_EPG_CHANNEL", "211" ); | 10 if( ! defined( "BS_EPG_CHANNEL" ) ) define( "BS_EPG_CHANNEL", "211" ); |
11 if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8" ); | 11 if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8" ); |
12 if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" ); | 12 if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" ); |
13 | 13 |
14 | 14 |
15 function check_file( $file ) { | 15 function check_file( $file ) { |
16 // ファイルがないなら無問題 | 16 // ファイルがないなら無問題 |
17 if( ! file_exists( $file ) ) return true; | 17 if( ! file_exists( $file ) ) return true; |
18 | 18 |
19 // 1時間以上前のファイルなら削除してやり直す | 19 // 1時間以上前のファイルなら削除してやり直す |
20 if( (time() - filemtime( $file )) > 3600 ) { | 20 if( (time() - filemtime( $file )) > 3600 ) { |
21 @unlink( $file ); | 21 @unlink( $file ); |
22 return true; | 22 return true; |
23 } | 23 } |
24 | 24 |
25 return false; | 25 return false; |
26 } | 26 } |
27 | 27 |
28 $settings = Settings::factory(); | 28 $settings = Settings::factory(); |
29 | 29 |
30 $temp_xml_bs = $settings->temp_xml."_bs"; | 30 $temp_xml_bs = $settings->temp_xml."_bs"; |
31 $temp_xml_cs1 = $settings->temp_xml."_cs1"; | 31 $temp_xml_cs1 = $settings->temp_xml."_cs1"; |
32 $temp_xml_cs2 = $settings->temp_xml."_cs2"; | 32 $temp_xml_cs2 = $settings->temp_xml."_cs2"; |
33 $temp_xml_gr = $settings->temp_xml."_gr"; | 33 $temp_xml_gr = $settings->temp_xml."_gr"; |
34 | 34 |
35 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 35 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
36 | 36 |
37 // BSを処理する | 37 // BSを処理する |
38 if( $settings->bs_tuners != 0 ) { | 38 if( $settings->bs_tuners != 0 ) { |
39 // 録画重複チェック | 39 // 録画重複チェック |
40 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); | 40 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); |
41 if( ($num == 0) && check_file($temp_xml_bs) ) { | 41 if($num < $settings->bs_tuners && 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"; | 42 $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 ); | 43 exec( $cmdline ); |
44 $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs; | 44 $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs; |
45 exec( $cmdline ); | 45 exec( $cmdline ); |
46 $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs." >/dev/null 2>&1 &"; | 46 $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs." >/dev/null 2>&1 &"; |
49 } | 49 } |
50 | 50 |
51 // CS | 51 // CS |
52 if ($settings->cs_rec_flg != 0) { | 52 if ($settings->cs_rec_flg != 0) { |
53 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); | 53 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); |
54 if( ($num == 0) && check_file($temp_xml_cs1) ) { | 54 if($num < $settings->bs_tuners && check_file($temp_xml_cs1)) { |
55 | |
55 $cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; | 56 $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 ); | 57 exec( $cmdline ); |
57 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1; | 58 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1; |
58 exec( $cmdline ); | 59 exec( $cmdline ); |
59 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1." >/dev/null 2>&1 &"; | 60 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1." >/dev/null 2>&1 &"; |
70 exec( $cmdline ); | 71 exec( $cmdline ); |
71 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 72 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
72 } | 73 } |
73 } | 74 } |
74 } | 75 } |
75 | 76 |
76 // 地上波を処理する | 77 // 地上波を処理する |
77 if( $settings->gr_tuners != 0 ) { | 78 if( $settings->gr_tuners != 0 ) { |
78 foreach( $GR_CHANNEL_MAP as $key=>$value ){ | 79 foreach( $GR_CHANNEL_MAP as $key=>$value ){ |
79 // 録画重複チェック | 80 // 録画重複チェック |
80 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" ); | 81 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" ); |
81 if( ($num == 0) && check_file($temp_xml_gr.$value."") ) { | 82 if($num < $settings->gr_tuners && 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"; | 83 $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; |
83 exec( $cmdline ); | 84 exec( $cmdline ); |
84 $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value.""; | 85 $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value.""; |
85 exec( $cmdline ); | 86 exec( $cmdline ); |
86 $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value." >/dev/null 2>&1 &"; | 87 $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value." >/dev/null 2>&1 &"; |
87 exec( $cmdline ); | 88 exec( $cmdline ); |
88 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 89 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
89 } | 90 } |
90 } | 91 } |
91 } | 92 } |
92 | 93 |
93 ?> | 94 ?> |