#include-once #include #Region Globals_DepMngr Global $__aDependency[5][2] = [ _ ["powershell", ""], _ ["curl", ""], _ ["ffmpeg", "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip"], _ ["youtube-dl", "https://yt-dl.org/downloads/latest/youtube-dl.exe"], _ ["magick", "https://imagemagick.org/script/download.php"] _ ] #EndRegion Func _DepMngr($nDependencyIndex, $bRetry = False) $sDependency = $__aDependency[$nDependencyIndex][0] If Run($sDependency, @ScriptDir, @SW_HIDE, 6) == 0 Then If @error == 1 Then If $bRetry Then MsgBox(16, "Fatal Dependency Error", "The dependency: "&$sDependency&" is still missing from the path."&@CRLF&"This failed to be resolved automatically."&@CRLF&"Please add it to the path or the current directory.") Exit(3) EndIf If $nDependencyIndex <= 1 Then MsgBox(16, "Fatal Dependency Error", "The dependency: "&$sDependency&" is missing from the path."&@CRLF&"This cannot be resolved automatically."&@CRLF&"Please add it to the path or the current directory.") Exit(1) Else If MsgBox(52, "Dependency Error", "The dependency: "&$sDependency&" is missing from the path."&@CRLF&"Would you like to automatically install it to this folder from:"&@CRLF&@CRLF&$__aDependency[$nDependencyIndex][1]) == 6 Then Switch $nDependencyIndex Case 2 ;ffmpeg Local $fTempFile = _TempFile(@TempDir, "~", ".zip") ConsoleWrite("TempFile: "&$fTempFile&@CRLF) ConsoleWrite("curl -L "&$__aDependency[$nDependencyIndex][1]&" -o "&$fTempFile&@CRLF) RunWait("curl -L "&$__aDependency[$nDependencyIndex][1]&" -o "&$fTempFile, @ScriptDir, @SW_SHOW) $fTempFolder = StringTrimRight(_TempFile(@TempDir, "~", ""), 1) ConsoleWrite("TempFolder: "&$fTempFolder&@CRLF) ConsoleWrite("powershell Expand-Archive "&$fTempFile&" "&$fTempFolder&@CRLF) RunWait("powershell Expand-Archive "&$fTempFile&" "&$fTempFolder, @ScriptDir, @SW_SHOW) FileDelete($fTempFile) Local $aTmp = _FileListToArrayRec($fTempFolder, "ffmpeg.exe", 1, 1) If $aTmp[0] > 0 Then ConsoleWrite("Move: "&$fTempFolder&"\"&$aTmp[1]&" > "&'"'&@ScriptDir&'\ffmpeg.exe"'&@CRLF) FileMove($fTempFolder&"\"&$aTmp[1], '"'&@ScriptDir&'\ffmpeg.exe"') EndIf DirRemove($fTempFolder, 1) _DepMngr($nDependencyIndex, True) Case 3 ;youtube-dl ConsoleWrite("curl -L "&$__aDependency[$nDependencyIndex][1]&' -o "'&@ScriptDir&'\youtube-dl.exe"'&@CRLF) RunWait("curl -L "&$__aDependency[$nDependencyIndex][1]&' -o "'&@ScriptDir&'\youtube-dl.exe"', @ScriptDir, @SW_SHOW) _DepMngr($nDependencyIndex, True) Case 4 ;magick Local $fTempFile = _TempFile(@TempDir, "~", ".html") ConsoleWrite("TempFile: "&$fTempFile&@CRLF) ConsoleWrite("curl -L "&$__aDependency[$nDependencyIndex][1]&' -o "'&$fTempFile&'"'&@CRLF) RunWait("curl -L "&$__aDependency[$nDependencyIndex][1]&' -o "'&$fTempFile&'"', @ScriptDir, @SW_SHOW) $sTmp = FileRead($fTempFile) FileDelete($fTempFile) $sTmp = StringRegExp($sTmp, '.+?-portable-Q16-x64\.zip<\/a>', 1)[0] $fTempFile = _TempFile(@TempDir, "~", ".zip") ConsoleWrite("curl -L "&$sTmp&' -o "'&$fTempFile&'"'&@CRLF) RunWait("curl -L "&$sTmp&' -o "'&$fTempFile&'"', @ScriptDir, @SW_SHOW) $fTempFolder = StringTrimRight(_TempFile(@TempDir, "~", ""), 1) ConsoleWrite("TempFolder: "&$fTempFolder&@CRLF) ConsoleWrite("powershell Expand-Archive "&$fTempFile&" "&$fTempFolder&@CRLF) RunWait("powershell Expand-Archive "&$fTempFile&" "&$fTempFolder, @ScriptDir, @SW_SHOW) FileDelete($fTempFile) Local $aTmp = _FileListToArrayRec($fTempFolder, "ffmpeg.exe", 1, 1) If $aTmp[0] > 0 Then FileDelete($fTempFolder&"\"&$aTmp[1]) EndIf RunWait('robocopy /E "'&$fTempFolder&'" .\') DirRemove($fTempFolder, 1) _DepMngr($nDependencyIndex, True) EndSwitch Else Exit(2) EndIf EndIf EndIf EndIf EndFunc