Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save robby-robby/0cdc82761999cfce7a3cb00c14542a9d to your computer and use it in GitHub Desktop.
Save robby-robby/0cdc82761999cfce7a3cb00c14542a9d to your computer and use it in GitHub Desktop.

A Siri shortcut to download youtube.com copied in the clipboard (via yt-dlp)

First: ๐Ÿ‘‰ Install yt-dlp

Second: ๐Ÿ‘‚ A conversation...

User

I want to make a siri shortcut for macos which runs a terminal command in ~/Desktop with the argument which is in the clip board

Assistant

Here's how you can create a Siri Shortcut on MacOS that runs a terminal command on the Desktop with the argument from your clipboard:

  1. Open "Automator" (you can press โŒ˜ + space and then type in "Automator" and hit enter).

  2. Choose "New Document".

  3. Select "Quick Action" and then choose "Workflow receives current text in any application".

  4. At the top of the workflow area, adjust "Workflow receives current" from "text" to "URLs".

  5. Add a new "Run Applescript" action.

  6. In the "AppleScript" text box, clear the default text and put the following code instead:

    on run {input, parameters}
        get the clipboard
        set theClipboard to the result
        set cmd to "cd ~/Desktop && " & theClipboard
        do shell script cmd
        return input
    end run
    
  7. Save the Quick Action (File > Save). Call it something recognizable, like "Execute Terminal Command".

  8. Open "System Preferences".

  9. Go to "Keyboard".

  10. Select "Shortcuts" tab.

  11. In the left pane, select "Services".

  12. Scroll down to find your quick action and assign it a keyboard shortcut.

This will capture the content of the clipboard, prepend it with yt-dlp, and then execute it in your terminal. This assumes that yt-dlp is installed and accessible from your terminal. If not, you will need to install it first.

Save the Quick Action and follow the remaining steps to assign a keyboard shortcut as mentioned in my previous instructions.

Now, whenever you copy a video URL to your clipboard and use the keyboard shortcut you set up, your Mac will run the yt-dlp command on your Desktop with that URL as the argument. [!WARNING] Remember to always be careful when executing terminal commands, especially ones that you've copied from somewhere. They could possible harm your system.

This will capture the content of the clipboard, prepend it with yt-dlp, and then execute it in your terminal. This assumes that yt-dlp is installed and accessible from your terminal. If not, you will need to install it first.

Save the Quick Action and follow the remaining steps to assign a keyboard shortcut as mentioned in my previous instructions.

Now, whenever you copy a video URL to your clipboard and use the keyboard shortcut you set up, your Mac will run the yt-dlp command on your Desktop with that URL as the argument.

[!DANGER] Again, please be careful when using terminal commands and only run commands that you trust!

Note: This specifically requires a URL to be selected when you activate the keyboard shortcut for this to work. If you still want to use URLs from the clipboard, ignore changing the workflow settings and continue to use the previous AppleScript code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment