YouTube-dl Macro (v9.0.1)

Thanks for your reply @CJK. Replying to the original poster now. youtube-dl seems to do the substitution just fine with the single quotes, at least in iTerm using a zsh shell. I followed the suggestions from the man page and thus far it has worked for me. Good point though that this could be a problem if KM has the youtube-dl substitution tokens as KM variables.

Ah, so the youtube-dl program itself will happily handle the tilde expansion ? Or is it zsh that has different rules about what it does or doesn’t expand inside quotes ?

From reading the man page discussion on output templates, youtube-dl does the expansion using python string formatting operations. I think having the template output text in single quotes prevents the shell from doing its own expansion prior to youtube-dl doing its magic. I don't think it matters whether it's a zsh shell or a bash shell.

1 Like

Actually, I just entered the same command in a bash shell with the same result.

That's pretty cool.

Hey Norm,

This fails to produce a title for me in the Finder:

youtube-dl -f mp4 'https://www.youtube.com/watch?v=HmRYgwZOCNA' -o '~/Downloads/YT/%(title)s.%(ext)s'

Playing around with the quotes doesn't make a difference.

Any idea why?

TIA.

-Chris

Can you please clarify? What do you mean fails to produce a title? Does it say couldn't extract title or something?

The title I get in the Finder is:

_.mp4

Full path:

~/Downloads/YT/_.mp4

-Chris

Not really sure. It worked for me.

I downloaded youtube-dl from homebrew. The version info is:

 $   brew info youtube-dl
youtube-dl: stable 2019.08.13, HEAD
Download YouTube videos from the command-line
https://ytdl-org.github.io/youtube-dl/
/usr/local/Cellar/youtube-dl/2019.08.13 (12 files, 2.1MB) *
  Built from source on 2019-08-27 at 19:59:08
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/youtube-dl.rb
==> Options
--HEAD
	Install HEAD version

How did you install youtube-dl?

Norm

Can someone help me with this yt-dl command: youtube-dl -f mp4 -o "/Users/me/Downloads" URL

What is wrong with me changing the download folder? The error I get is "unable to open for writing: [Errno 21] Is a directory: "

From this discussion thread, it would appear you need to specify a file path as the output, which cannot be a folder path. You're basically asking it to save the file as ~/Downloads, which, if it were go ahead and do that, would overwrite your entire downloads folder and replace it with a song I can't imagine is so amazing it would be worth the sacrifice.

Hey Norm,

Using MacPorts.

youtube-dl --version
--> 2019.07.16

I see this is a bit older than the Homebrew version.

Okay, I uninstalled the MacPorts exe and installed the HB exe – and this seems to have fixed the problem.

Thanks.

-Chris

Both MacPorts and Homebrew now have v2019.09.01

I confirm that both work correctly on my macOS 10.12.6 (Sierra) system.

-ccs

Glad the updated version worked. Thanks for the update!

Norm

1 Like

When executing the youtube-dl command in a terminal it gives you a nice download progress indication that updates until it reaches 100%

[download] 100% of 19.86MiB in 05:10

When I execute the same thing in KM using the Execute Shell Script action, I lose this progress indication and I don't know when the D/L is complete until the KM macro finishes. It would be nice to be able to get some idea that the D/L is happening and that the D/L is not hung. Any idea on how to do this?

Hey Chris,

That's not going to happen any time soon if at all.

Keyboard Maestro's Execute a Shell Script action is a script-runner mechanism and not a terminal that can manage interactive I/O.

If you want a progress indicator then script the Terminal.app with AppleScript.

-Chris

Thanks. I'll check out scripting terminal.

--Chris

Don't forget to search the forum...

Execute a Script in Terminal

Hi All,

YouTube removed my YouTube-DL video from their platform. Is YouTube-DL still working well for everyone?

@ccstone thank you, that worked beautifully.

@bocciaman youtube-dl is working fine for me.

1 Like