OSDN Git Service

fix: スターチャンネル追加
[epgrec/epgrec.git] / recomplete.php
1 #!/usr/bin/php
2 <?php
3 $script_path = dirname( __FILE__ );
4 chdir( $script_path );
5 include_once( $script_path . '/config.php');
6 include_once( INSTALL_PATH . "/DBRecord.class.php" );
7 include_once( INSTALL_PATH . "/Settings.class.php" );
8 include_once( INSTALL_PATH . "/recLog.inc.php" );
9
10 $settings = Settings::factory();
11
12 $reserve_id = $argv[1];
13
14 try{
15         $rrec = new DBRecord( RESERVE_TBL, "id" , $reserve_id );
16         $rrec->complete = '1';
17         
18         if( file_exists( INSTALL_PATH .$settings->spool . "/". $rrec->path ) ) {
19                 // 予約完了
20                 reclog( "recomplete:: 予約ID". $rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画が完了" );
21                 
22                 if( $settings->mediatomb_update == 1 ) {
23                         // ちょっと待った方が確実っぽい
24                         @exec("sync");
25                         sleep(15);
26                         $dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
27                         if( $dbh !== false ) {
28                                 $sqlstr = "use ".$settings->db_name;
29                                 @mysql_query( $sqlstr );
30                                 // 別にやらなくてもいいが
31                                 $sqlstr = "set NAME utf8";
32                                 @mysql_query( $sqlstr );
33                                 $sqlstr = "update mt_cds_object set metadata='dc:description=".mysql_real_escape_string($rrec->description)."&epgrec:id=".$reserve_id."' where dc_title='".$rrec->path."'";
34                                 @mysql_query( $sqlstr );
35                                 $sqlstr = "update mt_cds_object set dc_title='".mysql_real_escape_string($rrec->title)."(".date("Y/m/d").")' where dc_title='".$rrec->path."'";
36                                 @mysql_query( $sqlstr );
37                         }
38                 }
39         }
40         else {
41                 // 予約失敗
42                 reclog( "recomplete:: 予約ID". $rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画に失敗した模様", E_ERROR );
43                 $rrec->delete();
44         }
45 }
46 catch( exception $e ) {
47         reclog( "recomplete:: 予約テーブルのアクセスに失敗した模様", E_ERROR );
48         reclog( "recomplete:: ".$e->getMessage()."" , E_ERROR );
49         exit( $e->getMessage() );
50 }
51
52 ?>