I am hoping to make an automator application that prompts the user for input (i.e. youtube url), and downloads it using youtube-dl (already installed via Homebrew). After this, I am trying to use the command youtube-dl URL_HERE -e
which fetches the title of the video. I am hoping to make a notification that says "successfully downloaded TITLE_VIDEO" after it downloads successfully (if it downloads succesfully). I am using the "Run Applescript" command of automator.
This is all I've gotten so far:
display dialog "What is the youtube URL you want to download?" default answer ""
set answer to text returned of result
tell application "Terminal"
activate
do script with command "youtube-dl -f 140 " & answer
end tell
display notification "Successfully downloaded " & TITLE_HERE sound name "Blow"
I'm new to applescript, so only basic functions/ones that can be explained easily.
What I'm thinking is to do the terminal command youtube-dl URL_HERE -e
which will return the title of the video (TITLE), and set that to a variable and then pass that variable to display notification
Best Answer
Nice - a simple UI like that could be very useful in many situations!
Try this:
Unfortunately the youtube-dl script did not actually download the video when using the -e flag, (and an error occurred when trying to use the --exec CMD option).
Ended up just running the command twice; First download to /tmp, then get title.
Could also use the process id (pid) to track progress, etc.. :)
Update: I could not get the output of certain commands through applescript, like 'nettop'. There are probably ways to fix it. Here is my sloppy attempt at implementing a pid checking.. :)