How do I enable youtube-dl to bypass the age restriction on YouTube?
Solution 1:
yt-dlp looks like a fork of youtube-dl
and works as expected. You can install it as follows (from the project's GutHub page):
UNIX users (GNU/Linux, macOS, BSD) can also install the latest release one of the following ways:
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp sudo chmod a+rx /usr/local/bin/yt-dlp
sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp sudo chmod a+rx /usr/local/bin/yt-dlp
sudo aria2c https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp sudo chmod a+rx /usr/local/bin/yt-dlp
Solution 2:
You can try this workaround using Python 3.x with the following command (I've added the --verbose
flag in case of debugging):
python3 /usr/local/bin/youtube-dl -f bestvideo+bestaudio \
--all-subs --cookies $PWD/youtube.com_cookies.txt \
"https://www.youtube.com/watch?v=VIDEO_ID_HERE" --verbose
Make sure to do the following first:
- Ensure the
python3
is installed, that the command is working, and that it actually runs a version of Python 3.x. - Make sure that the path to your cookies file is correct.
- Make sure that you have the latest version of youtube-dl installed (
youtube-dl --version
). - Ensure the absolute file path for the youtube-dl binary or installation (In a UNIX-like terminal use
which youtube-dl
).
Solution 3:
There is a workaround, but not exactly by using youtube-dl
. Currently the best method to access Youtube's age-restricted videos (without logging in) is to use the Invidious network, which provides an alternate method of accessing Youtube's video content. For example you can use the main site of Invidious network, https://yewtu.be/ . Invidious network sites provide a download option under each video.
There is also an application called FreeTube that allows to view and download Youtube videos. It can automatically use Invidious servers in case it can't download the video from Youtube directly.