Mercurial > epgrec.yaz
comparison getepg.php @ 85:549d799d73ae
mod: ÊÂÎó¥Æ¥¹¥ÈÃæ
author | Sushi-k <epgrec@park.mda.or.jp> |
---|---|
date | Mon, 01 Mar 2010 16:00:20 +0900 |
parents | 3ec5ca5e56ca |
children | c29d41d0c945 |
comparison
equal
deleted
inserted
replaced
84:3ec5ca5e56ca | 85:549d799d73ae |
---|---|
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 // 後方互æ›æ€§ | |
10 if( ! defined( "BS_EPG_CHANNEL" ) ) define( "BS_EPG_CHANNEL", "211" ); | |
11 if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8" ); | |
12 if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" ); | |
13 | |
14 | |
15 function check_file( $file ) { | |
16 // ファイルãŒãªã„ãªã‚‰ç„¡å•é¡Œ | |
17 if( ! file_exists( $file ) ) return true; | |
18 | |
19 // 1時間以上å‰ã®ãƒ•ã‚¡ã‚¤ãƒ«ãªã‚‰å‰Šé™¤ã—ã¦ã‚„ã‚Šç›´ã™ | |
20 if( (time() - filemtime( $file )) > 3600 ) { | |
21 @unlink( $file ); | |
22 return true; | |
23 } | |
24 | |
25 return false; | |
26 } | |
27 | |
9 $settings = Settings::factory(); | 28 $settings = Settings::factory(); |
10 | 29 |
30 $temp_xml_bs = $settings->temp_xml."_bs"; | |
31 $temp_xml_cs1 = $settings->temp_xml."_cs1"; | |
32 $temp_xml_cs2 = $settings->temp_xml."_cs2"; | |
33 $temp_xml_gr = $settings->temp_xml."_gr"; | |
34 | |
11 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 35 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
12 | 36 |
13 // BSを処ç†ã™ã‚‹ | 37 // BSを処ç†ã™ã‚‹ |
14 if( $settings->bs_tuners != 0 ) { | 38 if( $settings->bs_tuners != 0 ) { |
15 // 録画é‡è¤‡ãƒã‚§ãƒƒã‚¯ | 39 // 録画é‡è¤‡ãƒã‚§ãƒƒã‚¯ |
16 $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')" ); |
17 if( ($num == 0) && !file_exists($settings->temp_xml."_bs") ) { | 41 if( ($num == 0) && check_file($temp_xml_bs) ) { |
18 $cmdline = "CHANNEL=211 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"; |
19 exec( $cmdline ); | 43 exec( $cmdline ); |
20 $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$settings->temp_xml."_bs"; | 44 $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs; |
21 exec( $cmdline ); | 45 exec( $cmdline ); |
22 $cmdline = INSTALL_PATH."/storeProgram.php BS ".$settings->temp_xml."_bs"; | 46 $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs; |
23 exec( $cmdline ); | 47 exec( $cmdline ); |
24 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 48 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
25 } | 49 } |
26 | 50 |
27 // CS | 51 // CS |
28 if ($settings->cs_rec_flg != 0) { | 52 if ($settings->cs_rec_flg != 0) { |
29 $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')" ); |
30 if( ($num == 0) && !file_exists($settings->temp_xml."_cs01") ) { | 54 if( ($num == 0) && check_file($temp_xml_cs1) ) { |
31 $cmdline = "CHANNEL=CS8 DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; | 55 $cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; |
32 exec( $cmdline ); | 56 exec( $cmdline ); |
33 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$settings->temp_xml."_cs01"; | 57 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1; |
34 exec( $cmdline ); | 58 exec( $cmdline ); |
35 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$settings->temp_xml."_cs01"; | 59 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1; |
36 exec( $cmdline ); | 60 exec( $cmdline ); |
37 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 61 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
38 } | 62 } |
39 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); | 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')" ); |
40 if( ($num == 0) && !file_exists($settings->temp_xml."_cs02") ) { | 64 if( ($num == 0) && check_file($temp_xml_cs2) ) { |
41 $cmdline = "CHANNEL=CS24 DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; | 65 $cmdline = "CHANNEL=".CS2_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; |
42 exec( $cmdline ); | 66 exec( $cmdline ); |
43 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$settings->temp_xml."_cs02"; | 67 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs2; |
44 exec( $cmdline ); | 68 exec( $cmdline ); |
45 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$settings->temp_xml."_cs02"; | 69 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs2; |
46 exec( $cmdline ); | 70 exec( $cmdline ); |
47 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 71 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
48 } | 72 } |
49 } | 73 } |
50 } | 74 } |
52 // 地上波を処ç†ã™ã‚‹ | 76 // 地上波を処ç†ã™ã‚‹ |
53 if( $settings->gr_tuners != 0 ) { | 77 if( $settings->gr_tuners != 0 ) { |
54 foreach( $GR_CHANNEL_MAP as $key=>$value ){ | 78 foreach( $GR_CHANNEL_MAP as $key=>$value ){ |
55 // 録画é‡è¤‡ãƒã‚§ãƒƒã‚¯ | 79 // 録画é‡è¤‡ãƒã‚§ãƒƒã‚¯ |
56 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" ); | 80 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" ); |
57 if( ($num == 0) && !file_exists($settings->temp_xml."_".$value."") ) { | 81 if( ($num == 0) && check_file($temp_xml_gr.$value."") ) { |
58 $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; | 82 $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; |
59 exec( $cmdline ); | 83 exec( $cmdline ); |
60 $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$settings->temp_xml."_".$value.""; | 84 $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value.""; |
61 exec( $cmdline ); | 85 exec( $cmdline ); |
62 $cmdline = INSTALL_PATH."/storeProgram.php GR ".$settings->temp_xml."_".$value.""; | 86 $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value.""; |
63 exec( $cmdline ); | 87 exec( $cmdline ); |
64 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); | 88 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
65 } | 89 } |
66 } | 90 } |
67 } | 91 } |