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.
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 &
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:
Pass a video URL to the Shortcut
Create file 1234.txt with 1 line of content being the video URL
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?