hello eveyone i d like to convert this terminal command to download video to apple script command so i can pass to it video title(w) and download url (currentURL)
Terminal Command example:
[format]cd /Users/Al3/Desktop
/usr/local/bin/yt-dlp --user-agent “Mozilla/5.0 (Macintosh; Intel Mac OS X 12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36” --referer “*” --external-downloader /usr/local/bin/aria2c --external-downloader-args “–check-certificate=false -j16 -x16 -s16 -k1M” --ffmpeg-location “/usr/local/bin/ffmpeg” “https://s-delivery36.mxdcontent.net/v/911e337eda9bf6c65ac539ab606ee857.mp4?s=wp2pN18OkY9cqP8QLFhrMg&e=1654156052&_t=1654139443” --output “5.mp4”[/format]
Apple Script :
if currentURL contains "hls" or currentURL contains "m3u8" then
display dialog "Password" default answer ""
set w to text returned of the result
tell application "Finder" to set homeFolder to path to home folder
do shell script "/usr/local/bin/node /usr/local/lib/node_modules/osx-notifier/bin/osx-notifier.js --type info --title \"Video Download\" --subtitle \"New video download started\" --message " & quoted form of currentURL
tell application "Finder" to set homeFolder to path to home folder
** need help** --> do shell script ..........
cd /Users/Al3/Desktop
/usr/local/bin/yt-dlp --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36" --referer "*" --external-downloader /usr/local/bin/aria2c --external-downloader-args "--check-certificate=false -j16 -x16 -s16 -k1M" --ffmpeg-location "/usr/local/bin/ffmpeg" "currentURL" --output " & POSIX path of homeFolder & "Desktop/" & w & ".mp4\"
do shell script "/usr/local/bin/node /usr/local/lib/node_modules/osx-notifier/bin/osx-notifier.js --type pass --title \"Video Download\" --subtitle \"Video download successful\" --message " & quoted form of w
end if
thanks for the help!
Hi.
I think this turns it into a workable shell script command, but I haven’t been able to test it, of course.
do shell script "cd /Users/Al3/Desktop ; /usr/local/bin/yt-dlp --user-agent \"Mozilla/5.0 (Macintosh; Intel Mac OS X 12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36\" --referer \"*\" --external-downloader /usr/local/bin/aria2c --external-downloader-args \"--check-certificate=false -j16 -x16 -s16 -k1M\" --ffmpeg-location \"/usr/local/bin/ffmpeg\" " & quoted form of currentURL & " --output " & quoted form of ((POSIX path of homeFolder) & "Desktop/" & w & ".mp4")
path to is a Standard Additions command. It doesn’t belong to the Finder. So you could leave out those two 'tell application “Finder” to ’ portions of text in your script. In fact there’s no point in having the command twice anyway. Another thing is that path to can get the path to the desktop directly, which would save some concatenation if the desktop’s always going to be the destination:
if currentURL contains "hls" or currentURL contains "m3u8" then
display dialog "Password" default answer ""
set w to text returned of the result
do shell script "/usr/local/bin/node /usr/local/lib/node_modules/osx-notifier/bin/osx-notifier.js --type info --title \"Video Download\" --subtitle \"New video download started\" --message " & quoted form of currentURL
do shell script "cd /Users/Al3/Desktop ; /usr/local/bin/yt-dlp --user-agent \"Mozilla/5.0 (Macintosh; Intel Mac OS X 12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36\" --referer \"*\" --external-downloader /usr/local/bin/aria2c --external-downloader-args \"--check-certificate=false -j16 -x16 -s16 -k1M\" --ffmpeg-location \"/usr/local/bin/ffmpeg\" " & quoted form of currentURL & " --output " & quoted form of (POSIX path of (path to desktop) & w & ".mp4")
do shell script "/usr/local/bin/node /usr/local/lib/node_modules/osx-notifier/bin/osx-notifier.js --type pass --title \"Video Download\" --subtitle \"Video download successful\" --message " & quoted form of w
end if
To debug errors in long do shell script commands, it makes sense to write them down first in a more readable form. Test and debug following example yourself, because I can’t test it for you:
if currentURL contains "hls" or currentURL contains "m3u8" then
display dialog "Password" default answer ""
set w to text returned of the result
tell application "Finder" to set homeFolder to path to home folder
do shell script "/usr/local/bin/node /usr/local/lib/node_modules/osx-notifier/bin/osx-notifier.js
--type info
--title \"Video Download\"
--subtitle \"New video download started\"
--message " & quoted form of currentURL
tell application "Finder" to set homeFolder to path to home folder
-- ** need help** --
do shell script "cd /Users/Al3/Desktop;
/usr/local/bin/yt-dlp
--user-agent \"Mozilla/5.0 (Macintosh; Intel Mac OS X 12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36\"
--referer " * "
--external-downloader /usr/local/bin/aria2c --external-downloader-args \"
--check-certificate=false -j16 -x16 -s16 -k1M\"
--ffmpeg-location \"/usr/local/bin/ffmpeg\"" & quoted form of currentURL & "
--output \" & POSIX path of homeFolder & \"Desktop/\" & w & \".mp4\""
do shell script "/usr/local/bin/node /usr/local/lib/node_modules/osx-notifier/bin/osx-notifier.js
--type pass
--title \"Video Download\"
--subtitle \"Video download successful\"
--message " & quoted form of w
end if
thank you very much works perfectly!