What I am trying to achieve:
- Click a YouTube link in an app
- This URL is used by my
youtube-dl
script to download the video youtube-dl
is configured to download the highest quality video and audio, then use ffmpeg to combine them into one file
What I have so far:
I use Finicky as my default browser. This gives me control over what browsers open certain links based on rules I write for it. The long and short of the tool is that it detects YouTube links, converts them from their usual form (e.g. https://www.youtube.com/watch?v=XxXxXxXXX_X
) to the shortened, share-friendly form (e.g. https://youtu.be/XxXxXxXXX_X
), then sends this to an AppleScript.
The AppleScript is saved as an app and is below.
#!/bin/zsh
on open location input
do shell script "youtube-dl " & input
end open location
This runs the shell script youtube-dl https://youtu.be/XxXxXxXXX_X
. When I type this exact command into Terminal everything works perfectly: youtube-dl
does it's thing, including doing something with ffmpeg to combine the downloaded files. However, when this AppleScript runs it's like ffmpeg isn't involved. I get a video file and an audio file.
I think my issue is in my AppleScript, but I am out of my depths with it. What can I do to make my AppleScript run things just like they run in Terminal?