さて今回はマックのMovieフォルダ内の KeyWordForHandbrakeCLI.txt と言うファイルに例えば
_シネマ「
_映画「
金曜ロードショー
土曜洋画劇場
#土曜映画デラックス
サタ☆シネ
葬送のフリーレン
といった感じにキーワードを登録しておきます。 まあ自分で好きなファイル名に変更してアップルスクリプト内の記載を変更してもらっても良いと思います。
また今回はフォルティアサーバーの共有ボリューム "JP-file-style"をあらかじめマウントした上で現時点から1時間前の録画記録をJP-file-style:01-全録画:2024:03:MPEG2: フォルダ内を検索して、そのデーターがHandBrakeCLIでの書き出しフォルダoFolder内に格納されていなければ、q's ListOfKeyContainFile に登録して、Ph02_HandBrakeCLI(q)を稼働させる事にするわけですね。
on Ph01_Check(q)
--このパートは, JP-file-styleをマウントし、q's iFolder内にKeywordファイルがあるかどうかを確認し、あればq's ListOfKeyContainFileにリスト形式で返却する。
set q to q & {foltia:"foltia", JPVolume:"JP-file-style", KeyFile:( (path to movies folder from user domain) as string) & "KeyWordForHandbrakeCLI.txt", iFolder:"JP-file-style:01-全録画:" & (do shell script "date -v-1H +%Y:%m:MPEG2:"), oFolder:(path to movies folder from user domain) as string, ListOfKeyContainFile:{}}
set L to load script file (((path to home folder from user domain) as string) & "Dropbox:Scripts:module:Logs_forConsole_pub.scpt") as alias
--JPVolumeフォルダをマウントする、Macの場合は一回はあらかじめマウントしてキーワードなどはキーチェーンに登録しておく必要があり
tell application "Finder" to set Diskls to (every disk whose displayed name is q's JPVolume)
try
tell application "Finder"
if Diskls is {} then
if ((do shell script "ping -t 1 -c 1 " & q's foltia & ".local||true") is "") then return {erro:true} & q
mount volume "smb://" & q's foltia & ".local/" & q's JPVolume
LogOnConsole({cmt:"JP-file-styleを再マウントしました", open_:true}) of L
end if
end tell
on error
LogOnConsole({cmt:"JP-file-styleがマウントできない", open_:false}) of L
return {erro:true} & q
end try
--マウントされなければq's erro trueを返す
--KeyWordForHandbrakeCLI.txt を探し改行で区切られたテキストキーワードをList変数 _lsに格納する
set f to (q's KeyFile as alias)'s POSIX path
set ls to do shell script "cat " & quoted form of f & "| grep -v '^#'|grep -v '^//'||true"
set _ls to every paragraph of (do shell script "echo " & quoted form of ls)
set ListOfKeyContainFile_i to {}
repeat with key_ in _ls
set key_ to (key_'s contents)
set ListOfKeyContainFile_i to ListOfKeyContainFile_i & every paragraph of (do shell script "ls " & quoted form of (POSIX path of (q's iFolder) ) & "|grep " & quoted form of key_ & "||true")
end repeat
--return ListOfKeyContainFile_i
--キーワード録画はエンコード方法を変える方向で行く
--書き出しファイルからキーワード録画の名前が消えるので、エンコード後のファイルがあるかどうかの判断を行う
set ListOfKeyContainFile to {}
repeat with key_ in ListOfKeyContainFile_i
set key_ to key_'s contents
set key_cut to do shell script "echo " & key_'s quoted form & "| sed -e 's/\\.[a-z]*$//'| iconv -f UTF-8-MAC -t UTF-8|sed -e 's/_キーワード録画_[0-9]*_/_/g'"
set key_ to do shell script "echo " & key_'s quoted form & "| sed -e 's/\\.[a-z]*$//'"
try
set key_cut to text 1 thru 20 of key_cut --長すぎる名前はカットする
end try
set oFile to do shell script "ls " & quoted form of (POSIX path of (q's oFolder as alias) ) & "| iconv -f UTF-8-MAC -t UTF-8|grep " & quoted form of key_cut & "||true"
if oFile is "" then set oFile to do shell script "ls " & quoted form of (POSIX path of (q's oFolder as alias) ) & "|grep " & quoted form of key_cut & "||true"
--該当するファイルがoFolder内に無ければoFileは""となっている。
if (oFile is "") then set ListOfKeyContainFile to ListOfKeyContainFile & {key_} --カットする前のListOfKeyContainFile_i内のデータを保管する
end repeat
return {ListOfKeyContainFile:ListOfKeyContainFile} & q
end Ph01_Check
こんな形でしょうかね、次回はこれをM-loop_pubに搭載して見ましょう。