require_once INSTALL_PATH . '/Settings.class.php'; $settings = Settings::factory(); if (file_exists($settings->temp_data)) { unlink($settings->temp_data); } // 地上波を処理する if ($settings->gr_tuners != 0) { foreach (ChannelMaster::$GR as $key => $channel_no) { // 録画重複チェック $db = DB::conn(); $row = $db->row("SELECT COUNT(*) FROM Recorder_reserveTbl LEFT JOIN Recorder_programTbl ON Recorder_reserveTbl.program_disc = Recorder_programTbl.program_disc WHERE complete = '0' AND type = 'GR' AND endtime > NOW() AND starttime < addtime( NOW(), '00:01:10')"); if (is_array($row) && current($row) == 0) { $temp_filename = str_replace('.ts', "_GR{$channel_no}.ts", $settings->temp_data); // 直近1時間のtsない時だけ作る if (!RecorderService::isDumped($temp_filename)) { $options = array('CHANNEL' => $channel_no, 'DURATION' => 30, 'TYPE' => 'GR', 'TUNER' => 0, 'MODE' => 0, 'OUTPUT' => $temp_filename); RecorderService::doRecord($options); } // dump $xml = str_replace('.xml', "_GR{$channel_no}.xml", $settings->temp_xml); $cmdline = "{$settings->epgdump} {$key} {$temp_filename} {$xml}"; exec($cmdline); // parse if (file_exists($xml)) { RecorderService::storeProgram('GR', $xml); RecorderService::cleanup(); // unlink($xml); } } } }
<?php /** * update_crontab.php * * 予約情報をcrontabにおとす * * simpleReservationが実行された時だけ実行すればよさそうに見えるが、 * crontabをapacheから書き換える事はできないので、cronから書き換える必要がある */ mb_language("ja"); require_once dirname(__FILE__) . '/config.php'; // keywordから予約対象を調べて予約する Keyword::reserveAll(); // 一旦TMPに出す。 file_put_contents('/tmp/crontab.txt', RecorderService::generateCrontab()); exec('crontab /tmp/crontab.txt');
public static function storeProgram($type, $xmlfile) { global $BS_CHANNEL_MAP; global $CS_CHANNEL_MAP; // チャンネルマップファイルの準備 $map = array(); if ($type === "BS") { $map = $BS_CHANNEL_MAP; } else { if ($type === "GR") { $map = ChannelMaster::$GR; } else { if ($type === "CS") { $map = $CS_CHANNEL_MAP; } } } // XML parse $xml = simplexml_load_file($xmlfile); if ($xml === false) { throw new RuntimeException('simplexml parse error'); } // channel抽出 RecorderService::updateChannel($type, $xml); // programme 取得 RecorderService::updateProgram($type, $xml); }