20260322

【ffmpeg】インストールヘルパ(ffmpeg.martin-riedl.de用)


【ffmpeg】インストールヘルパ(ffmpeg.martin-riedl.de用)


【スクリプトエディタで開く】 |

FFMPEGインストールV8.1.scpt
ソース
001#!/usr/bin/env osascript
002#coding: utf-8
003----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
004(*
005管理者権限不要の
006ユーザーインストール
007/Users/ユーザーID/Library/Application Support/bin/ffmpeg 
008
009インストールします
010
011ffmpegの公式リンクのバイナリーがインテル用なので
012https://evermeet.cx/ffmpeg/
013ARM用にMAKEされている
014ダウンロードサイトはドイツの『野良サイト』を利用しています
015https://ffmpeg.martin-riedl.de/
016
017品質について私は保証しません(でも、まぁ大丈夫じゃないか?な?)
018
019現在あるバイナリーはゴミ箱に入れてからダウンロードしますので
020置き換え・アップデートになります
021
022v1 初回作成
023v2 ffmepgのバージョンが上がったのでURLを更新した
024v2.1 ffmepgのバージョンが上がったのでURLを更新した v8版
02520250830 ffmpegのv8版 このffmpegはwhisper文字起こし機能を含んでいません
026v2.1.1 ffmepgのバージョンが上がったのでURLを更新した v8.0.1版
027v2.2 リンボリックリンクによってバージョン管理できるようにした
028v2.2.1 アトリビュートを削除しておくように変更
029
030com.cocolog-nifty.quicktimer.icefloe *)
031----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
032use AppleScript version "2.8"
033use framework "Foundation"
034use framework "AppKit"
035use scripting additions
036property refMe : a reference to current application
037set appFileManager to refMe's NSFileManager's defaultManager()
038
039##############################
040#【設定項目】
041#Version
042set strVerSion to ("8.1") as text
043#スナップショット=TRUE リリースビルド=FALSE
044set boolSnap to true as boolean
045
046##############################
047#メタ文字
048set strLF to ("" & linefeed & "") as text
049set strCR to ("" & return & "") as text
050set strCRLF to ("" & return & linefeed & "") as text
051set strSpace to ("" & space & "") as text
052set strTab to ("" & tab & "") as text
053##############################
054#インストールチェック
055set refResponse to doChkInstall("ffmpeg")
056if refResponse is false then
057   log "未インストール" & strCR & "インストールします"
058else
059   if refResponse contains "Support/bin/ffmpeg" then
060      log "インストール済みです" & strCR & "アップデートします"
061   else
062      log "ローカルインストール済みです" & strCR & "処理を中止します"
063      return false
064   end if
065end if
066
067##############################
068#ダウンロードサイト
069set strURL to ("https://ffmpeg.martin-riedl.de") as text
070set ocidURLString to refMe's NSString's stringWithString:(strURL)
071set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLString)
072#NSDATA
073set ocidOption to (refMe's NSDataReadingMappedIfSafe)
074set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference)
075if (last item of listResponse) = (missing value) then
076   log "initWithContentsOfURL 正常処理"
077   set ocidReadData to (first item of listResponse)
078else if (item 2 of listResponse) ≠ (missing value) then
079   set strErrorNO to (last item of listResponse)'s code() as text
080   set strErrorMes to (last item of listResponse)'s localizedDescription() as text
081   refMe's NSLog("■:" & strErrorNO & strErrorMes)
082   return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes
083end if
084#XML
085set ocidOption to (refMe's NSXMLNodePreserveAll) + (refMe's NSXMLDocumentTidyHTML)
086set listResponse to refMe's NSXMLDocument's alloc()'s initWithData:(ocidReadData) options:(ocidOption) |error|:(reference)
087set ocidReadXML to (first item of listResponse)
088
089set ocidRoorElement to ocidReadXML's rootElement()
090########################################
091#インストールURL (Apple Silicon/arm64)
092########################################
093set listResponse to (ocidRoorElement's nodesForXPath:("//a[contains(@href, 'macos/arm64') and contains(text(), 'FFmpeg (ZIP)')]") |error|:(reference))
094if boolSnap is true then
095   set ocidAelement to (first item of listResponse)'s firstObject()
096else
097   set ocidAelement to (first item of listResponse)'s lastObject()
098end if
099if ocidAelement = (missing value) then
100   set strZip1 to ("https://ffmpeg.martin-riedl.de/download/macos/arm64/1774549676_8.1/ffmpeg.zip") as text
101else
102   set ocidAttar to ocidAelement's attributeForName:("href")
103   set ocidZip1 to ocidAttar's stringValue()
104   set ocidZip1URL to ocidURLString's stringByAppendingString:(ocidZip1)
105   set strZip1 to ocidZip1URL as text
106end if
107log strZip1 as text
108###################################
109set listResponse to (ocidRoorElement's nodesForXPath:("//a[contains(@href, 'macos/arm64') and contains(text(), 'FFprobe (ZIP)')]") |error|:(reference))
110if boolSnap is true then
111   set ocidAelement to (first item of listResponse)'s firstObject()
112else
113   set ocidAelement to (first item of listResponse)'s lastObject()
114end if
115if ocidAelement = (missing value) then
116   set strZip2 to ("https://ffmpeg.martin-riedl.de/download/macos/arm64/1774549676_8.1/ffprobe.zip") as text
117else
118   set ocidAttar to ocidAelement's attributeForName:("href")
119   set ocidZip2 to ocidAttar's stringValue()
120   set ocidZip2URL to ocidURLString's stringByAppendingString:(ocidZip2)
121   set strZip2 to ocidZip2URL as text
122end if
123log strZip2 as text
124###################################
125set listResponse to (ocidRoorElement's nodesForXPath:("//a[contains(@href, 'macos/arm64') and contains(text(), 'FFplay (ZIP)')]") |error|:(reference))
126if boolSnap is true then
127   set ocidAelement to (first item of listResponse)'s firstObject()
128else
129   set ocidAelement to (first item of listResponse)'s lastObject()
130end if
131if ocidAelement = (missing value) then
132   set strZip3 to ("https://ffmpeg.martin-riedl.de/download/macos/arm64/1774549676_8.1/ffplay.zip") as text
133else
134   set ocidAttar to ocidAelement's attributeForName:("href")
135   set ocidZip3 to ocidAttar's stringValue()
136   set ocidZip3URL to ocidURLString's stringByAppendingString:(ocidZip3)
137   set strZip3 to ocidZip3URL as text
138end if
139log strZip3 as text
140
141
142###################################
143#リストに
144set listURL to {strZip1, strZip2, strZip3} as list
145
146#保存先
147set ocidHomeDirURL to appFileManager's homeDirectoryForCurrentUser()
148set strSetSubePath to ("Library/Application Support/bin/ffmpeg/" & strVerSion & "") as text
149set ocidDistDirPathURL to ocidHomeDirURL's URLByAppendingPathComponent:(strSetSubePath) isDirectory:(true)
150set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init()
151ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
152set ocidDistDirPath to ocidDistDirPathURL's |path|()
153set boolDirExists to appFileManager's fileExistsAtPath:(ocidDistDirPath) isDirectory:(true)
154if boolDirExists is false then
155   set listDone to appFileManager's createDirectoryAtURL:(ocidDistDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)
156   if (item 1 of listDone) is false then
157      set strErrorNO to (item 2 of listDone)'s code() as text
158      set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
159      refMe's NSLog("■:" & strErrorNO & strErrorMes)
160      log "createDirectoryAtURL エラーしました" & strErrorNO & strErrorMes
161      return false
162   end if
163end if
164#解凍するためのレンポラリー(再起動時に自動で削除されます)
165set ocidTempDirURL to appFileManager's temporaryDirectory()
166set ocidUUID to refMe's NSUUID's alloc()'s init()
167set ocidUUIDString to ocidUUID's UUIDString
168set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true)
169set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init()
170ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
171set ocidMakeDirPath to ocidSaveDirPathURL's |path|()
172set boolDirExists to appFileManager's fileExistsAtPath:(ocidMakeDirPath) isDirectory:(true)
173if boolDirExists is false then
174   set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)
175   if (item 1 of listDone) is false then
176      set strErrorNO to (item 2 of listDone)'s code() as text
177      set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
178      refMe's NSLog("■:" & strErrorNO & strErrorMes)
179      log "createDirectoryAtURL エラーしました" & strErrorNO & strErrorMes
180      return false
181   end if
182end if
183
184#順番に処理
185repeat with itemURL in listURL
186   #
187   set ocidSourceFilePath to (refMe's NSString's stringWithString:(itemURL))
188   set ocidSourceFilePathURL to (refMe's NSURL's alloc()'s initWithString:(ocidSourceFilePath))
189   set ocidFileName to ocidSourceFilePathURL's lastPathComponent()
190   #
191   set ocidZipFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidFileName) isDirectory:(false))
192   set ocidZipFilePath to ocidZipFilePathURL's |path|()
193   ##NSDATAダウンロード
194   set ocidOption to (refMe's NSDataReadingMappedIfSafe)
195   set listResponse to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidSourceFilePathURL) options:(ocidOption) |error|:(reference))
196   if (item 2 of listResponse) = (missing value) then
197      log "initWithContentsOfURL 正常処理"
198      set ocidSaveData to (item 1 of listResponse)
199   else if (item 2 of listResponse) ≠ (missing value) then
200      set strErrorNO to (item 2 of listResponse)'s code() as text
201      set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
202      refMe's NSLog("■:" & strErrorNO & strErrorMes)
203      log ocidSource1FilePathURL's |path|() as text
204      return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes
205   end if
206   
207   ##NSDATAテンポラリーへ保存
208   set ocidOption to (refMe's NSDataWritingAtomic)
209   set listDone to (ocidSaveData's writeToURL:(ocidZipFilePathURL) options:(ocidOption) |error|:(reference))
210   if (item 1 of listDone) is true then
211      log "writeToURL 正常処理"
212   else if (item 2 of listDone) ≠ (missing value) then
213      set strErrorNO to (item 2 of listDone)'s code() as text
214      set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
215      refMe's NSLog("■:" & strErrorNO & strErrorMes)
216      log ocidZip1FilePathURL's |path|() as text
217      return "writeToURL エラーしました" & strErrorNO & strErrorMes
218   end if
219   #古いバイナリーはゴミ箱に
220   set ocidFileName to ocidFileName's stringByDeletingPathExtension()
221   set ocidDistFilePathURL to (ocidDistDirPathURL's URLByAppendingPathComponent:(ocidFileName) isDirectory:(false))
222   set listDone to (appFileManager's trashItemAtURL:(ocidDistFilePathURL) resultingItemURL:(missing value) |error|:(reference))
223   ########################
224   #解凍
225   set strCmd to ("/usr/bin/unzip  \"" & ocidZipFilePath & "\" -d \"" & ocidDistDirPath & "\"") as text
226   set strResponse to doZshShellScript(strCmd)
227   if strResponse is false then
228      return "解凍に失敗しました"
229   end if
230end repeat
231
232########################
233##シンボリックリンク処理
234set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
235set ocidAppSupportDirPathURL to ocidURLsArray's firstObject()
236set ocidExecDirPathURL to ocidAppSupportDirPathURL's URLByAppendingPathComponent:("bin/ffmpeg") isDirectory:(true)
237
238set listBinName to {"ffmpeg", "ffplay", "ffprobe"} as list
239
240repeat with itemBinName in listBinName
241   #シンボリックリンクを
242   set ocidLinkFilePathURL to (ocidExecDirPathURL's URLByAppendingPathComponent:(itemBinName) isDirectory:(false))
243   #ゴミ箱に入れて
244   set listDone to (appFileManager's trashItemAtURL:(ocidLinkFilePathURL) resultingItemURL:(ocidLinkFilePathURL) |error|:(reference))
245   #バイナリー
246   set strSubePath to ("" & strVerSion & "/" & itemBinName & "") as text
247   set ocidBinFilePathURL to (ocidExecDirPathURL's URLByAppendingPathComponent:(strSubePath) isDirectory:(false))
248   set listDone to (appFileManager's createSymbolicLinkAtURL:(ocidLinkFilePathURL) withDestinationURL:(ocidBinFilePathURL) |error|:(reference))
249   set strBinFilePath to ocidBinFilePathURL's |path|() as text
250   do shell script ("/usr/bin/xattr -c '" & strBinFilePath & "'")
251end repeat
252
253########################
254#解凍前のファイルをゴミ箱へ
255set listDone to (appFileManager's trashItemAtURL:(ocidSaveDirPathURL) resultingItemURL:(ocidSaveDirPathURL) |error|:(reference))
256
257
258########################
259#保存先を開く
260set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
261set boolDone to appSharedWorkspace's openURL:(ocidDistDirPathURL)
262log "処理終了"
263return boolDone
264
265
266
267##########################
268# 【N】ZSH 実行
269to doZshShellScript(argCommandText)
270   set strCommandText to argCommandText as text
271   log "コマンド開始" & return & strCommandText & return
272   set strExec to ("/bin/zsh -c '" & strCommandText & "'") as text
273   ##########
274   #コマンド実行
275   try
276      set strResnponse to (do shell script strExec) as text
277      log "コマンド終了"
278   on error
279      return false
280   end try
281   return strResnponse
282end doZshShellScript
283
284
285##############################
286#すでにインストール済みで
287#ユーザーがRC設定している場合は
288#パスが通るのでこれがエラーにならない
289to doChkInstall(argBinName)
290   try
291      #ランチD
292      set strCmd to ("/bin/zsh -c '/usr/bin/which " & argBinName & "'")
293      set strResponse to (do shell script strCmd) as text
294      return strResponse
295   on error strErrMsg number numErrNo
296      set strCmd to ("/bin/zsh -c \"[[ -f '/usr/local/bin/" & argBinName & "' ]] && echo \\\"TRUE\\\" || echo \\\"FALSE\\\"\"")
297      set strResponse to (do shell script strCmd) as text
298      if strResponse is "FALSE" then
299         return false
300      else if strResponse is "TRUE" then
301         set strResponse to ("/usr/local/bin/" & argBinName & "")
302      end if
303   end try
304end doChkInstall
AppleScriptで生成しました


【スクリプトエディタで開く】 |

FFMPEGインストールV8.1.scpt
ソース
001#!/usr/bin/env osascript
002#coding: utf-8
003----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
004(*
005管理者権限不要の
006ユーザーインストール
007/Users/ユーザーID/Library/Application Support/bin/ffmpeg 
008
009インストールします
010
011ffmpegの公式リンクのバイナリーがインテル用なので
012https://evermeet.cx/ffmpeg/
013ARM用にMAKEされている
014ダウンロードサイトはドイツの『野良サイト』を利用しています
015https://ffmpeg.martin-riedl.de/
016
017品質について私は保証しません(でも、まぁ大丈夫じゃないか?な?)
018
019現在あるバイナリーはゴミ箱に入れてからダウンロードしますので
020置き換え・アップデートになります
021
022v1 初回作成
023v2 ffmepgのバージョンが上がったのでURLを更新した
024v2.1 ffmepgのバージョンが上がったのでURLを更新した v8版
02520250830 ffmpegのv8版 このffmpegはwhisper文字起こし機能を含んでいません
026v2.1.1 ffmepgのバージョンが上がったのでURLを更新した v8.0.1版
027v2.2 リンボリックリンクによってバージョン管理できるようにした
028v2.2.1 アトリビュートを削除しておくように変更
029
030com.cocolog-nifty.quicktimer.icefloe *)
031----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
032use AppleScript version "2.8"
033use framework "Foundation"
034use framework "AppKit"
035use scripting additions
036property refMe : a reference to current application
037set appFileManager to refMe's NSFileManager's defaultManager()
038
039##############################
040#【設定項目】
041#Version
042set strVerSion to ("8.1") as text
043#スナップショット=TRUE リリースビルド=FALSE
044set boolSnap to true as boolean
045
046##############################
047#メタ文字
048set strLF to ("" & linefeed & "") as text
049set strCR to ("" & return & "") as text
050set strCRLF to ("" & return & linefeed & "") as text
051set strSpace to ("" & space & "") as text
052set strTab to ("" & tab & "") as text
053##############################
054#インストールチェック
055set refResponse to doChkInstall("ffmpeg")
056if refResponse is false then
057   log "未インストール" & strCR & "インストールします"
058else
059   if refResponse contains "Support/bin/ffmpeg" then
060      log "インストール済みです" & strCR & "アップデートします"
061   else
062      log "ローカルインストール済みです" & strCR & "処理を中止します"
063      return false
064   end if
065end if
066
067##############################
068#ダウンロードサイト
069set strURL to ("https://ffmpeg.martin-riedl.de") as text
070set ocidURLString to refMe's NSString's stringWithString:(strURL)
071set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLString)
072#NSDATA
073set ocidOption to (refMe's NSDataReadingMappedIfSafe)
074set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference)
075if (last item of listResponse) = (missing value) then
076   log "initWithContentsOfURL 正常処理"
077   set ocidReadData to (first item of listResponse)
078else if (item 2 of listResponse) ≠ (missing value) then
079   set strErrorNO to (last item of listResponse)'s code() as text
080   set strErrorMes to (last item of listResponse)'s localizedDescription() as text
081   refMe's NSLog("■:" & strErrorNO & strErrorMes)
082   return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes
083end if
084#XML
085set ocidOption to (refMe's NSXMLNodePreserveAll) + (refMe's NSXMLDocumentTidyHTML)
086set listResponse to refMe's NSXMLDocument's alloc()'s initWithData:(ocidReadData) options:(ocidOption) |error|:(reference)
087set ocidReadXML to (first item of listResponse)
088
089set ocidRoorElement to ocidReadXML's rootElement()
090########################################
091#インストールURL (Apple Silicon/arm64)
092########################################
093set listResponse to (ocidRoorElement's nodesForXPath:("//a[contains(@href, 'macos/arm64') and contains(text(), 'FFmpeg (ZIP)')]") |error|:(reference))
094if boolSnap is true then
095   set ocidAelement to (first item of listResponse)'s firstObject()
096else
097   set ocidAelement to (first item of listResponse)'s lastObject()
098end if
099if ocidAelement = (missing value) then
100   set strZip1 to ("https://ffmpeg.martin-riedl.de/download/macos/arm64/1766430132_8.0.1/ffmpeg.zip") as text
101else
102   set ocidAttar to ocidAelement's attributeForName:("href")
103   set ocidZip1 to ocidAttar's stringValue()
104   set ocidZip1URL to ocidURLString's stringByAppendingString:(ocidZip1)
105   set strZip1 to ocidZip1URL as text
106end if
107log strZip1 as text
108###################################
109set listResponse to (ocidRoorElement's nodesForXPath:("//a[contains(@href, 'macos/arm64') and contains(text(), 'FFprobe (ZIP)')]") |error|:(reference))
110if boolSnap is true then
111   set ocidAelement to (first item of listResponse)'s firstObject()
112else
113   set ocidAelement to (first item of listResponse)'s lastObject()
114end if
115if ocidAelement = (missing value) then
116   set strZip2 to ("https://ffmpeg.martin-riedl.de/download/macos/arm64/1766430132_8.0.1/ffprobe.zip") as text
117else
118   set ocidAttar to ocidAelement's attributeForName:("href")
119   set ocidZip2 to ocidAttar's stringValue()
120   set ocidZip2URL to ocidURLString's stringByAppendingString:(ocidZip2)
121   set strZip2 to ocidZip2URL as text
122end if
123log strZip2 as text
124###################################
125set listResponse to (ocidRoorElement's nodesForXPath:("//a[contains(@href, 'macos/arm64') and contains(text(), 'FFplay (ZIP)')]") |error|:(reference))
126if boolSnap is true then
127   set ocidAelement to (first item of listResponse)'s firstObject()
128else
129   set ocidAelement to (first item of listResponse)'s lastObject()
130end if
131if ocidAelement = (missing value) then
132   set strZip3 to ("https://ffmpeg.martin-riedl.de/download/macos/arm64/1766430132_8.0.1/ffplay.zip") as text
133else
134   set ocidAttar to ocidAelement's attributeForName:("href")
135   set ocidZip3 to ocidAttar's stringValue()
136   set ocidZip3URL to ocidURLString's stringByAppendingString:(ocidZip3)
137   set strZip3 to ocidZip3URL as text
138end if
139log strZip3 as text
140
141
142###################################
143#リストに
144set listURL to {strZip1, strZip2, strZip3} as list
145
146#保存先
147set ocidHomeDirURL to appFileManager's homeDirectoryForCurrentUser()
148set strSetSubePath to ("Library/Application Support/bin/ffmpeg/" & strVerSion & "") as text
149set ocidDistDirPathURL to ocidHomeDirURL's URLByAppendingPathComponent:(strSetSubePath) isDirectory:(true)
150set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init()
151ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
152set ocidDistDirPath to ocidDistDirPathURL's |path|()
153set boolDirExists to appFileManager's fileExistsAtPath:(ocidDistDirPath) isDirectory:(true)
154if boolDirExists is false then
155   set listDone to appFileManager's createDirectoryAtURL:(ocidDistDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)
156   if (item 1 of listDone) is false then
157      set strErrorNO to (item 2 of listDone)'s code() as text
158      set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
159      refMe's NSLog("■:" & strErrorNO & strErrorMes)
160      log "createDirectoryAtURL エラーしました" & strErrorNO & strErrorMes
161      return false
162   end if
163end if
164#解凍するためのレンポラリー(再起動時に自動で削除されます)
165set ocidTempDirURL to appFileManager's temporaryDirectory()
166set ocidUUID to refMe's NSUUID's alloc()'s init()
167set ocidUUIDString to ocidUUID's UUIDString
168set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true)
169set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s init()
170ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
171set ocidMakeDirPath to ocidSaveDirPathURL's |path|()
172set boolDirExists to appFileManager's fileExistsAtPath:(ocidMakeDirPath) isDirectory:(true)
173if boolDirExists is false then
174   set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error|:(reference)
175   if (item 1 of listDone) is false then
176      set strErrorNO to (item 2 of listDone)'s code() as text
177      set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
178      refMe's NSLog("■:" & strErrorNO & strErrorMes)
179      log "createDirectoryAtURL エラーしました" & strErrorNO & strErrorMes
180      return false
181   end if
182end if
183
184#順番に処理
185repeat with itemURL in listURL
186   #
187   set ocidSourceFilePath to (refMe's NSString's stringWithString:(itemURL))
188   set ocidSourceFilePathURL to (refMe's NSURL's alloc()'s initWithString:(ocidSourceFilePath))
189   set ocidFileName to ocidSourceFilePathURL's lastPathComponent()
190   #
191   set ocidZipFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidFileName) isDirectory:(false))
192   set ocidZipFilePath to ocidZipFilePathURL's |path|()
193   ##NSDATAダウンロード
194   set ocidOption to (refMe's NSDataReadingMappedIfSafe)
195   set listResponse to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidSourceFilePathURL) options:(ocidOption) |error|:(reference))
196   if (item 2 of listResponse) = (missing value) then
197      log "initWithContentsOfURL 正常処理"
198      set ocidSaveData to (item 1 of listResponse)
199   else if (item 2 of listResponse) ≠ (missing value) then
200      set strErrorNO to (item 2 of listResponse)'s code() as text
201      set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
202      refMe's NSLog("■:" & strErrorNO & strErrorMes)
203      log ocidSource1FilePathURL's |path|() as text
204      return "initWithContentsOfURL エラーしました" & strErrorNO & strErrorMes
205   end if
206   
207   ##NSDATAテンポラリーへ保存
208   set ocidOption to (refMe's NSDataWritingAtomic)
209   set listDone to (ocidSaveData's writeToURL:(ocidZipFilePathURL) options:(ocidOption) |error|:(reference))
210   if (item 1 of listDone) is true then
211      log "writeToURL 正常処理"
212   else if (item 2 of listDone) ≠ (missing value) then
213      set strErrorNO to (item 2 of listDone)'s code() as text
214      set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
215      refMe's NSLog("■:" & strErrorNO & strErrorMes)
216      log ocidZip1FilePathURL's |path|() as text
217      return "writeToURL エラーしました" & strErrorNO & strErrorMes
218   end if
219   #古いバイナリーはゴミ箱に
220   set ocidFileName to ocidFileName's stringByDeletingPathExtension()
221   set ocidDistFilePathURL to (ocidDistDirPathURL's URLByAppendingPathComponent:(ocidFileName) isDirectory:(false))
222   set listDone to (appFileManager's trashItemAtURL:(ocidDistFilePathURL) resultingItemURL:(missing value) |error|:(reference))
223   ########################
224   #解凍
225   set strCmd to ("/usr/bin/unzip  \"" & ocidZipFilePath & "\" -d \"" & ocidDistDirPath & "\"") as text
226   set strResponse to doZshShellScript(strCmd)
227   if strResponse is false then
228      return "解凍に失敗しました"
229   end if
230end repeat
231
232########################
233##シンボリックリンク処理
234set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSUserDomainMask))
235set ocidAppSupportDirPathURL to ocidURLsArray's firstObject()
236set ocidExecDirPathURL to ocidAppSupportDirPathURL's URLByAppendingPathComponent:("bin/ffmpeg") isDirectory:(true)
237
238set listBinName to {"ffmpeg", "ffplay", "ffprobe"} as list
239
240repeat with itemBinName in listBinName
241   #シンボリックリンクを
242   set ocidLinkFilePathURL to (ocidExecDirPathURL's URLByAppendingPathComponent:(itemBinName) isDirectory:(false))
243   #ゴミ箱に入れて
244   set listDone to (appFileManager's trashItemAtURL:(ocidLinkFilePathURL) resultingItemURL:(ocidLinkFilePathURL) |error|:(reference))
245   #バイナリー
246   set strSubePath to ("" & strVerSion & "/" & itemBinName & "") as text
247   set ocidBinFilePathURL to (ocidExecDirPathURL's URLByAppendingPathComponent:(strSubePath) isDirectory:(false))
248   set listDone to (appFileManager's createSymbolicLinkAtURL:(ocidLinkFilePathURL) withDestinationURL:(ocidBinFilePathURL) |error|:(reference))
249   set strBinFilePath to ocidBinFilePathURL's |path|() as text
250   do shell script ("/usr/bin/xattr -c '" & strBinFilePath & "'")
251end repeat
252
253########################
254#解凍前のファイルをゴミ箱へ
255set listDone to (appFileManager's trashItemAtURL:(ocidSaveDirPathURL) resultingItemURL:(ocidSaveDirPathURL) |error|:(reference))
256
257
258########################
259#保存先を開く
260set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
261set boolDone to appSharedWorkspace's openURL:(ocidDistDirPathURL)
262log "処理終了"
263return boolDone
264
265
266
267##########################
268# 【N】ZSH 実行
269to doZshShellScript(argCommandText)
270   set strCommandText to argCommandText as text
271   log "コマンド開始" & return & strCommandText & return
272   set strExec to ("/bin/zsh -c '" & strCommandText & "'") as text
273   ##########
274   #コマンド実行
275   try
276      set strResnponse to (do shell script strExec) as text
277      log "コマンド終了"
278   on error
279      return false
280   end try
281   return strResnponse
282end doZshShellScript
283
284
285##############################
286#すでにインストール済みで
287#ユーザーがRC設定している場合は
288#パスが通るのでこれがエラーにならない
289to doChkInstall(argBinName)
290   try
291      #ランチD
292      set strCmd to ("/bin/zsh -c '/usr/bin/which " & argBinName & "'")
293      set strResponse to (do shell script strCmd) as text
294      return strResponse
295   on error strErrMsg number numErrNo
296      set strCmd to ("/bin/zsh -c \"[[ -f '/usr/local/bin/" & argBinName & "' ]] && echo \\\"TRUE\\\" || echo \\\"FALSE\\\"\"")
297      set strResponse to (do shell script strCmd) as text
298      if strResponse is "FALSE" then
299         return false
300      else if strResponse is "TRUE" then
301         set strResponse to ("/usr/local/bin/" & argBinName & "")
302      end if
303   end try
304end doChkInstall
AppleScriptで生成しました