The yt-dlp package provides a Python3 CLI utility to download audio and video files from thousands of websites, including YouTube. It can convert downloads into other formats using FFmpeg.
If you're downloading videos from YouTube, be aware that the platform often makes changes that break yt-dlp. In this case, there is usually a newer version, in which you should upgrade.
cURL, FFmpeg, make-ca, and Node.js
brotli (with Python3 bindings), certifi, Requests, and Urllib3
Install yt-dlp by running the following commands:
pip3 wheel -w dist --no-build-isolation --no-deps --no-cache-dir $PWD
Now, as the root user:
pip3 install --no-index --find-links=dist --no-cache-dir --no-user yt_dlp
YouTube has made it so JavaScript challenges need to be done in order to
pull from its site. If you download YouTube videos using this package,
download a JavaScript runtime/engine like Node.js. The following
instructions assume you have it installed. Next, create a system
configuration file, telling yt-dlp to use Node.js for JS challenges and
automatically download the challenge scripts required, as the root
user:
cat > /etc/yt-dlp.conf << EOF
--js-runtimes node --remote-components ejs:github
EOFNow yt-dlp will use Node.js to solve JS challenges when downloading YouTube videos, automatically downloading scripts by yt-dlp to do so.
-w dist: Builds the appropriate
“wheel” for this module in the directory
dist.
--no-build-isolation: Tells
pip3 to run the build in the system environment
instead of creating a temporary build environment.
--no-deps: Prevents pip3 from
building wheels for the project's dependencies.
--no-index: Ignores the package index
(only looking at --find-links URLs instead).
--find-links dist: Looks for links to archives
such as wheel (.whl) files in the
directory dist.
--no-cache-dir: Disables the cache to prevent
a warning when installing as the root user.
--no-user: Prevent mistakenly running the
install command as a non-root user.
--upgrade: Upgrade the package to the newest
available version. This option is used with the install command
if a version of the package is already installed.
--force-reinstall: Reinstall the package even if
it is up-to-date. This option is used with the install command
if reinstalling the package or reverting to an earlier version
of the package.
--no-deps: Do not install package dependencies.
This option may be needed with the --upgrade or
--force-reinstall options.