Bash function for yt-dlp with drag and drop capability.
Type yt
in terminal and press Enter
key then drag and drop url from your web browser into terminal to download the video.
There is not need to type command and press Enter
with each new link.
You can paste next url as soon as last download is finish (you will see [download] 100%
and empty new line in terminal).
It is possible to paste new url while last one is still in progress, but if you add more than one, download will fail (all urls will be treated as one).
To terminate process press Ctrl+C
or simply close the terminal.
Install yt-dlp and make sure it is working properly (e.g. try executing yt-dlp --version
).
To add function for your user (Linux, macOS, etc.): To install it right away for all UNIX users (Linux, macOS, etc.), type:
sudo curl -L https://raw.githubusercontent.com/lukdz/youtube-dnd/master/yt -o /usr/local/bin/yt
sudo chmod a+rx /usr/local/bin/yt
Alternatively you can add content of bash_function
file from this repository to ~/.bash_aliases
on Ubuntu or ~/.bash_profile
on macOS.
Default program used to process URLs is yt-dlp
with --update
argument on startup.
This can be changed by setting environmental variable with name of selected program and option.
To make changes persistent add the following example to ~/.bash_aliases
file on Ubuntu or ~/.bash_profile
on macOS.
export YT_DOWNLOADER="yt-dlp"
export YT_DOWNLOADER="youtube-dl"
# for macOS to avoid issues with python version
export YT_DOWNLOADER="/usr/bin/python3 /usr/local/bin/youtube-dl"
It possible to modify the link before passing them to command line tool for example to use with wkhtmltopdf to render HTML into PDF:
wkslug () {
wkhtmltopdf \
"$1" \
"$(echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+//g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z).pdf"
}
export -f wkslug
export YT_DOWNLOADER="wkslug"
export YT_START_ARG=${YT_START_ARG:---version}
adding third link while first one is downloading, causes second and third to merge togetherfixed by running downloader in the backgroundread function is broken onread function on zsh useszsh
-k
option instead of-n