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
If you wish to download YouTube videos, apply a patch to add Node.js as a default JavaScript engine [4]:
patch -Np0 << EOF --- yt_dlp/options.py +++ yt_dlp/options.py @@ -467 +467 @@ - default=['deno'], + default=['deno', 'node'], @@ -473 +473 @@ - 'Only "deno" is enabled by default. The highest priority runtime that is both enabled and ' + 'Only "deno" and "node" are enabled by default. The highest priority runtime that is both enabled and ' EOF
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
-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.