I am trying to create a workflow in order to automate the start-up (and closing) of ytdlp, to download videos via command line. However, I don't understand how to make it recognise that [download] 100% of appears in the terminal, which would indicate that the process is finished and trigger the closing of the application. This, however, does not happen, I lack some know-how and cannot understand from the instructions on the site. See below.
Since you're typing a shell command in Terminal why don't you use KM's inbuilt action to run a shell command? You then won't need to muck about with Terminal.
I admit I am a novice, I simply copied the string to the shell execution command but the macro does not activate, giving an error. Where do I go wrong?
The shell environment in KM is different to that in Terminal insofar as KM's shell has a bare-bones path environment set up. As a result it won't know where yt-dl is installed on your Mac. The easiest way round this is to specify the full path to yt-dl.
You're not providing the video URL to the KM action.
Searching the KM forum for yt-dlp came up with this:
Take a look as it should help you. You should also study the wiki page I linked to previously as it contains important information about paths.
You might also want to search the KM forum for "YouTube" so see how others use KM to download videos.
Sorry I can't be more expansive with my help as I'm really time-constrained right now.
Because yt-dlp doesn't take the file path from standard input. Put the path into a variable, then use that variable in your "Execute Shell Script" action.
It's always a good idea to provide your actual macro when you've a problem, not an image of it, so that people can give you an edited (and hopefully working!) version. You haven't, so here's an example of both the error and the fix, using ls as a proxy for yt-dlp:
Run the macro and you'll see the first "Execute" ignores /Applications and instead lists the contents of / -- the current working directory. The second "Execute", 5 seconds later, does list /Applications because the path has been provided via the KM variable Local_path.
I thank you. I'm starting to understand, but I still haven't managed to bypass the last test, which is to copy-paste the last element of the system clipboard after the string (I attach screen and macro). How could I do this? By creating another variable?
Yes! Check out the section "Using Keyboard Maestro Variables" on the wiki page:
You'll want to set a new variable to text using the %Clipboard% token and then use that variable into your script, as shell scripts can't use keyboard maestro tokens directly.