Mixing Shortcuts with my Mac and Hazel for Youtube-DL and Overcast

Some fun mixed automation I’m toying with. Nothing insanely fancy but useful for me.

I used to run a shortcut to SSH to my mac mini and run youtube-dl for me. The only annoying thing is I couldn’t figure out a way to run it and have the shortcut return immediately (vs waiting on the command to finish on my mac). I assume this was operator error as I only know the extreme basics of command line. And I mean like how to look up my uptime and not much more.

So I have moved to running a shortcut that drops the url in a text file, syncing through icloud. When my Mac sees it Hazel then fires off the script for youtube-dl and takes care of downloading it for me.

I have two shortcut options, Video or Audio. If it’s a Video one it goes into my plex folder. If I choose audio then ultimately I want to hear it like a podcast so a second script also runs @AndrewM’s Overcast script and uploads the audio into my Overcast account.

Pushover can send me notifications to let me know it’s done but I’m still tweaking those.

Fun stuff.

2 Likes

A variation on this classic:

1 Like

If you still want to go back to the original command line approach, in all flavours of Unix / Linux you can run a process in the background (so the command line prompt will return immediately rather than after the process completes) from the command line. To do this just add an ampersand (“&” character) at the end of the command line ie youtube-dl &

1 Like

I tried that but it was still waiting before coming back.

For what it may be worth, I’ve used screen for background processing previously and that always worked well.

https://ss64.com/osx/screen.html

I’ll check that out. Thanks!

Love this setup, I just set it up for myself and had a little trouble figuring out the Hazel config, so for others curious, here’s how I did it:

And the bash script is: url=$(cat $1);youtube-dl $url. This just sets the variable url to the contents of the matched file, then runs youtube-dl with it.

On the Shortcuts side, I’m simply creating a new text file with a random filename (e.g. 1234.txt) with the contents being the video URL. This could be expanded to allow multiple lines in a single file but I didn’t feel the need for that.

So basic flow is:

  1. Pass a video URL to the Shortcut
  2. Create file 1234.txt with 1 line of content being the video URL
  3. Hazel detects a file in this directory
  4. Hazel passes the contents to youtube-dl
  5. Hazel deletes the text file
1 Like

Thanks of this one, easier than my setup.

1 issue I ran into is I can’t force mp4 download in this way, YouTube-dl starts, but I end up with about 5-6 .part files, not merged. Have you seen this before?