#!/usr/bin/ruby #------------------------------------------ # # RADIO Server timer record manager # for ruby # # Ver1.00 Jun.27.2000 # # Programed by K.Kunikane(rero2) # #------------------------------------------- #--------------------------------------------------- # 設定事項 #--------------------------------------------------- $basedir = "/home/radio_server/system/" require $basedir+"radio_lib.rb" #----- 出力ファイル名 $list_in = $basedir+"rec_list.txt" #----- 出力ファイル名 $list_out = $basedir+"rec_today.txt" #--------------------------------------------------- # クラス設計 #--------------------------------------------------- class MakeList < RecordList #------------------------------------------- #----- 今日から特定日数分のリスト作成 def make_days_item(day, output_name) #--- 出力ファイルのオープン file = open(output_name, "w") #--- 開始まで day日未満の放送を探す near = (24*60*60*day) @item.each do |pitem| if near > pitem.onair # -- pitem がヒットしたアイテム file.print(pitem.radio_line) end end #--- 出力ファイルのクローズ file.close end end #--------------------------------------------------- # サブルーチン設計 #--------------------------------------------------- #--------------------------------------------------- # メインフロー #--------------------------------------------------- #------------------------------------- # 昨日分の削除 if File::exist?($list_out) #--- 定常録音リストの読み込み request_list = MakeList.new($list_out) #--- 昨日分の削除 request_list.make_days_item(6, $basedir+"schedule_tmp.txt") end #------------------------------------- # 本日分リストの生成 file = open($list_out, "w") file.print("#-- radio record list (today)\n") file.close #--- 定常録音リストの読み込み request_list = MakeList.new($list_in) #--- 本日分の抜き出し request_list.make_days_item(1, $basedir+"schedule_today.txt") #------------------------------------- # リストの結合 command = sprintf("cat %sschedule_today.txt %sschedule_tmp.txt >> %s", $basedir, $basedir, $list_out); system(command) command = sprintf("rm %sschedule_today.txt %sschedule_tmp.txt", $basedir, $basedir); system(command) #------------------------------------- # 時間補正のくりあ adj = open($basedir+"time_adjust.txt", "w") adj.print("0\n") adj.close