Using macOS's Script Editor I made an application containing the following script. It accepts a plain text URL as an input. It works when I send it one input, let it finish executing the script, then send it a new input. If I send it a second input while one is already running, the second input does nothing.
How can I change the script and/or application so I can send it a second (or third, fourth, etc.) input while it is already running?
#!/usr/bin/osascript
on open location input
do shell script "/usr/local/bin/yt-dlp " & quoted form of input
end open location
How it works
Instead of a web browser, I have Finicky set as my default web browser. Finicky can be programmed to do all sorts of stuff based on the URL (e.g. Open Google Meet links in Google Chrome, Open Zoom links in Firefox, etc.).
However, Finicky can use any application to open a link, not just web browsers. I have configured Finicky to send certain URLs to the above script.
Here is the part of my .finicky.js
config file that matches certain URLs and opens them with the AppleScript app.
handlers: [
{
match: /^https?:\/\/www\.youtube\.com\/.*$/,
browser: "com.apple.ScriptEditor.id.open-URL"
}
]
Click a link in an app → Finicky sends it to the AppleScript app → the app runs a shell script → the script is run and outputs a file
How I use this
I keep my video subscriptions in NetNewsWire. As I scroll through the new articles in my RSS app I press enter to open them using my default browser. Finicky sends some URLs to Safari and others to my little app, which then runs the shell script and outputs a file. Now I have to wait for each to finish. I'd like to not have to worry about this and continue adding URLs as I scroll through feed items. Either adding them to a queue or running multiple versions of the script is a solution, but this is where I hit a wall and can't figure it out.
P.S. I call it an application because Script Editor allows me to save it as a .app file. I understand it's not really an application.