#!/usr/bin/ruby #------------------------------------------ # # RADIO Server timer record manager # for ruby # # Nov.28.2000 # Ver1.00 Dec.07.2000 # Ver1.02 Jun.27.2001 # # Programed by K.Kunikane(rero2) # #------------------------------------------- #--------------------------------------------------- # 設定事項 #--------------------------------------------------- $basedir = "/home/radio_server/system/" require $basedir+"radio_lib.rb" #----- キャプチャーコマンド $capcom = "/home/radio_server/system/capt2mp3" #----- チャプチャーディレクトリ $capdir = "/home/radio_server/tmp/" #----- ストックディレクトリ $strdir = "/home/radio_server/" #--------------------------------------------------- # サブルーチン設計 #--------------------------------------------------- #--------------------------------------------------- # クラス設計 #--------------------------------------------------- #---------------------------------- # 録音クラス # class RecordBody < RecordList #------------------------------------- #----- 実際に録音する作業 def capture(nitem) name = nitem.radio_title time = (nitem.radio_length * 60) - 30 command = sprintf("%s %s %d", $capcom, name, time) system(command) stock(name) end #------------------------------------- #----- データを整理する def stock(label) # -- ディレクトリがなかったら掘る outdir = sprintf("%s%s", $strdir, label) unless File.exist?(outdir) Dir::mkdir(outdir) system("chmod 777 "+outdir); end # -- 移動 command = sprintf("mv %s%s*.mp3 %s%s/", $capdir, label, $strdir, label) system(command) command = sprintf("chmod 666 %s%s/*", $strdir, label) system(command) end #------------------------------------- #----- 録音タイミングの判断 def do_capture work = 0 target = nearest if (target.onair < 900) sleep(5) while (target.onair > 15) sleep(1) while (target.onair > 4) capture(target) work = 1 end work end end #--------------------------------------------------- # メインフロー #--------------------------------------------------- #------------------------------- #- 通常録音 if ARGV[0] != nil #--- 録音リストの読み込み request_list = RecordBody.new(ARGV[0]) #--- 録音作業 request_list.do_capture else print "Require record list.\n" end