Skip to content

Instantly share code, notes, and snippets.

@shredthaGNAR
Created April 27, 2022 02:20
Show Gist options
  • Save shredthaGNAR/e6d6ac2b8ba63ffc0d42430cfbd06c29 to your computer and use it in GitHub Desktop.
Save shredthaGNAR/e6d6ac2b8ba63ffc0d42430cfbd06c29 to your computer and use it in GitHub Desktop.
Youtube DLP Bash Script

youtube-dlp-bash

No copying URL! No pressing paste or enter!!

You select your text, and activate this script by a hotkey shortcut (e.g F9) and you instantly download the video!
No pressing enter or confirmation or whatever bs. Literally 1 button download, couldn't be smoother. No "copy" -> "select input field" -> "paste" -> "enter" on whatever video downloader

#!/bin/sh

# Replace /username/ with your username under home directory
# or replace the entire path with wherever you want these videos to be saved.
xclip -o | xargs -r yt-dlp -P "/home/username/videos"

Now, you may want to write the URL yourself, or paste it manually, or press enter to confirm the url yourself before downloading.

#!/bin/sh

# Give your input to dmenu (bash could work, but ? character triggers zsh globs and other annoying terminal bugs)
targeturl="$(dmenu -p Download </dev/null)"

# Pass targeturl to youtube downloader (works for any kind of video)
yt-dlp -P /home/username/videos "$targeturl"

The above works for this, pretty much opens dmenu and whatever you type is passed onto yt-dlp. Middle mouse button works for pasting, but just use ctrl+Y for pasting onto dmenu, for efficiency (imagine using mouse)
But if you don't want to paste and enter, not even copy, the optimal is obviously the very first script.

Obviously map both scripts to hotkeys, so you can download videos effortlessly.

Ah and ofc, it needs youtube-dl. youtube-dlp in this case (it is objectively superior)

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