前回のph01_check(q) とPh02_HandBrakeCLI(q)を前回作ったFoltiaRecStatus.scptに追記して、M-loop_pubにもいくつか追記して見ましょう。
以前のやつに上書きして見てください。
これも同様です。 M-loop_pub.appは以前の物を使って大丈夫です。 そのままDropbox内の新しいM-loop_pub.scptを読み込んでくれます。
M-loop_pubは前回空白にしていたMainDrop(theFile)に以下を記入
on MainDrop(theFile) --Manually_HandBrakeCLI(q)
set L to load script file (((path to home folder from user domain) as string) & "Dropbox:Scripts:module:Log_forConsole_pub.scpt") as alias
set R to load script file (((path to home folder from user domain) as string) & "Dropbox:Scripts:module:FoltiaRecStatus.scpt") as alias
set q to {theFile:theFile}
set q to q & {oFolder:(path to movies folder from user domain) as string}
repeat with aFile in theFile
set aFile to (aFile's contents) as alias
tell application "Finder"
set name_t to do shell script "echo " & (name of aFile as string)'s quoted form & "|sed -e 's/\\.[0-9,a-z,A-Z]*$//'"
set ext to aFile's name extension
set iFolder to (aFile's container) as string
set aFileName to name of aFile as string
end tell
if ext is "ts" then
LogOnConsole({cmt:"ドラッグされました。HandbrakeCLIを手動起動", open_:false}) of L
Ph02_HandBrakeCLI({iFolder:iFolder, ListOfKeyContainFile:{name_t}, iFileTail:".ts"} & q) of R
else if ext is "mp4" then
--適切なフォルダへ移動させるといったハンドラを作って動作させても良いでしょうね。
end if
end repeat
LogOnConsole({cmt:"☆DropFileプロセスは正常終了", open_:false}) of L
end MainDrop
Main_loop(q)側は以下の様に記載を追加してます。
on MainLoop(q)
set q to {status:"good", erro:false, loopPerSec:50, pswd:"********"} & q & {foltia:"foltia", JPVolume:"JP-file-style"}
--pswdは各自自分の環境に合わせて記載してください。
set L to load script file (((path to home folder from user domain) as string) & "Dropbox:Scripts:module:Log_forConsole_pub.scpt") as alias
--set N to load script file (((path to home folder from user domain) as string) & "Dropbox:Scripts:module:HTML_pub.scpt") as alias
set R to load script file (((path to home folder from user domain) as string) & "Dropbox:Scripts:module:FoltiaRecStatus.scpt") as alias
if ((do shell script "ping -t 1 -c 1 " & q's foltia & ".local||true") is "") then return {erro:true, status:LogOnConsoleR({cmt:"サーバーにPingが通らず", open_:false}) of L} & q
FoltiaRecStatus(q) of R
set q to Ph01_Check(q) of R --キーワードに相当するファイルがあるかどうかを検索して、Handbrakeで操作が必要なファイル名を ListOfKeyContainFileで戻す
if (q's erro) or (q's ListOfKeyContainFile is {}) then return q --statusエラーがあったり、リストが戻ってこなければLoopに戻す
set q to Ph02_HandBrakeCLI(q) of R
return q
end MainLoop
拡張子tsが付いてるファイルをドラッグドロップすると、Ph02_HandBrakeCLIの中の記述に沿って、そのまま低圧縮のMPEG4ファイルに変換するか、高速閲覧用の720pの低クオリティーの録画に圧縮するか決めてくれます。
まあこのエンコードしている間はFoltiaのチェックをしてくれないので、時間などを指定してエンコードさせたりするのも良いかもしれませんね。 書き出し先を好きな場所に指定するには引数 qの oFolderを自分の目的の場所に設定しておけば、明示されたoFolderに書き出してくれます。
これだと、キーワードファイル KeyWordForHandbrakeCLI.txt に記載しておくと、録画完了と共にエンコードが開始されます。 MPEG2ファイルのCM編集を設定すると、この状況だとCM編集が始まる前にエンコードが始まり、終わって古いtsファイルが上書きされても、2回目のエンコードはしてくれませんので、MPEG2のCM編集は切りにしておくか、書き出し後のファイルの作成時間をコメント欄に記載したりして、CM切り出し前のファイル作成時間を記載しておいて、変更があれば再度エンコード実行したりしても良いのかもしれませんが、今回は複雑になるのでそういう設定はしてません。
こんな物でしょうか?
今度は録画予定の番組の重複チェックを定期的に行うオプションを紹介して見ます。