Yt-dlp & RunCommand

This is what I using for years. For download videos by yt-dlp.
I just changed theterminal.applescript in RunCommand.popclipext
RunCommand.popclipext.zip (11.1 KB)

(previous was youtube-dl)

tell application "Terminal"
	activate
	-- If there are no open windows, open one.
	if (count of windows) is less than 1 then
		do script ""
	end if
	set theTab to selected tab in first window
	do script "yt-dlp " & "{popclip text}" in theTab
end tell

.sh version (running without open Terminal)

yt-dlp.popclipext.zip (12.1 KB)

2 Likes

Thanks for sharing @kxxc, it’s a good example of how to wire up PopClip to your own scripts and utilities.

Of course we must first install the downloader with:

brew install yt-dlp


I had a look in the .sh version script to learn from it:

cd & yt-dlp $POPCLIP_TEXT &

My observations:

  • that the cd command changes directory to user home directory
  • The trailing & means that the command returns without blocking so PopClip will not “spin”

The effect is to download the video will download to home directory in the background

1 Like

I found the original .sh credit and thanks to him:

https://github.com/k4rtik/popclip-ytdl/issues/2

AI helped me with this

iTerm

#popclip
name: Yt-dlp
icon: iconify:solar:download-bold-duotone
requirements: ["urls"]
actions:
  - title: Yt-dlp
    language: AppleScript
    applescript: |
      tell application "iTerm"
          activate
          if (count of windows) = 0 then
              create window with default profile
          end if
          tell current window
              set newTab to create tab with default profile
              tell current session of newTab
                  write text "yt-dlp " & "{popclip text}" & " ; osascript -e 'display notification \"Done\" with title \"Yt-dlp\"'"
              end tell
          end tell
      end tell

Terminal

#popclip
name: Yt-dlp
icon: iconify:solar:download-bold-duotone
requirements: ["urls"]
actions:
  - title: Yt-dlp
    language: AppleScript
    applescript: |
      tell application "Terminal"
        activate
        if (count of windows) = 0 then
          do script ""
        end if
        do script "yt-dlp {popclip text} ; osascript -e 'display notification \"Done\" with title \"Yt-dlp\"'" in front window
      end tell