yt-dlp (YouTube DownLoader Plus) is a free open-source command-line tool, a fork of youtube-dl for downloading video and audio from thousands of websites, e.g. YouTube, SoundCloud, Bandcamp, etc. The content may be legally free or purchased music, podcasts, audiobooks, etc., which you want to save locally for many reasons.
I've written these scripts for myself and decided to share it in case someone finds it useful for self-development. I give absolutely NO WARRANTY if you decide to use them. I'm not a professional in shell scripting, I just learn by doing and sharing this how-to motivates me to practice more. I also recommend reading Further Work section below as it contains some warnings.
- Please, keep in mind that by using these scripts you stress the servers/hosts. Don't try to download too much.
- Please, be informed that:
Downloading copyrighted material without permission from the copyright holder is a violation of copyright law. Unauthorized downloading can lead to civil or criminal penalties for copyright infringement.
- Telegram channel "Декрабизация", RU: https://t.me/decrabru/58.
- Telegram chat group "LinuxCamp", RU: https://t.me/linuxcamp_chat/18467.
In Termux or a terminal of other Debian-like apt-capable environment run:
## Install ##
# Turn off `sudo` in Termux:
if [ ! -z $TERMUX_VERSION ]; then alias sudo=''; fi
# Update information about packages:
sudo apt update
# Upgrade all installed packages to the latest versions:
sudo apt upgrade
# Install:
# 1) `curl` and `wget` -- used for downlaoding files from the web.
# 2) `python3` -- required to execute a `yt-dlp` binary.
# 3) `ffmpeg` -- used by `yt-dlp` for converting downloaded media to mp3, flac or other format.
sudo apt install --yes curl wget python3 ffmpeg
# WARNING: The following commands are dangerous!
# 1) Via `curl` it downloads `install.sh` script from one of GitHub's domains.
# Make sure you trust the `url` variable below.
# Verify the domain, username and gist id. The username and id must match with the url of
# this page (gist) from the address bar of your browser.
# 2) The downloaded script's content is "piped down" (fed to) via `|` (pipe operator) to `sh` (shell).
# 3) The shell executes commands passed to its' input and installs aliases.
url='https://gist.githubusercontent.com/ilyaigpetrov/834a956685f3bc5738dc1de20e7aeb5e/raw/install.sh'
curl --silent $url | sh
# 4) The `.` (dot operator) executes commands from file `~/.bash_aliases` populated during the install
# in order to make the aliases usable in your _current_ shell session.
. ~/.bash_aliasesTo uninstall:
## Uninstall ##
myTmp="$(mktemp)"
cat ~/.bash_aliases | sed 's/^/un/' | sed 's/=.*//' | grep ' my-' > $myTmp
. $myTmp
sed --in-place '/ my-/d' ~/.bash_aliases
### Optionally ###
# BE CAREFUL: These tools to be deleted may be used by
# other applications. `apt` will warn you about the dependants.
sudo apt remove curl wget python3 ffmpeg
# Remove `yt-dlp`.
# You may need to install `which` tool via `apt` first.
sudo rm $(which yt-dlp)cd ./music
mkdir ./from-internet
cd ./from-internet
# Download mp3 from a YouTube video:
my-audio-downloader mp3 https://www.youtube.com/watch?v=VIDEO_ID_HERE
# Want to convert the source media format to flac?
# Keep in mind that if the original quality
# is poor, flac won't make it any better.
# Anyway, just replace mp3 with flac:
my-audio-downloader flac https://soundcloud.com/ARTIST_NAME_HERE/TRACK_TITLE_HERE
# Download mp3(s) for some item (e.g. a playlist) from
# a SoundCloud short url:
my-audio-downloader mp3 https://on.soundcloud.com/SOME_ID_HERE
# Download the best quality and don't convert it:
my-audio-downloader-best https://soundcloud.com/ARTIST_NAME_HERE/TRACK_TITLE_HERE- The uninstaller script just uses
my-to identify aliases for removal. This may easily happen to clash with aliases by other apps. - The
yt-dlpoutput template isn't perfect. E.g. I don't like the usage ofautonumberas a fallback. - My shell coding skills need more practice.
- WARNING: The output template for a filename may be vulnerable to code injections. E.g. some track or artist name may include unsafe characters or shell commands.