13

YouTube has started "age restricting" many videos, and I can't download them with youtube-dl.

For example

youtube-dl https://www.youtube.com/watch?v=xeZ3k2ywQ6Y

Results in this:

user@droplet~/user# youtube-dl https://www.youtube.com/watch?v=xeZ3k2ywQ6Y
[youtube] xeZ3k2ywQ6Y: Downloading webpage
[youtube] xeZ3k2ywQ6Y: Refetching age-gated info webpage
WARNING: unable to download video info webpage: HTTP Error 410: Gone
ERROR: Sign in to confirm your age
This video may be inappropriate for some users.

I tried youtube-dl with -u and -p as it has those options and for the username I tried the email address I would log in to YouTube with, and I tried the username.

user@user:~/user# ./youtube-dl -u _____ -p _____ "https://www.youtube.com/watch?v=xeZ3k2ywQ6Y"
[youtube] Downloading login page
[youtube] Looking up account info
WARNING: Unable to look up account info: HTTP Error 400: Bad Request
[youtube] xeZ3k2ywQ6Y: Downloading webpage
[youtube] xeZ3k2ywQ6Y: Refetching age-gated info webpage
WARNING: unable to download video info webpage: HTTP Error 410: Gone
ERROR: Sign in to confirm your age
This video may be inappropriate for some users.
user@user:~/user# 

As you see, it doesn't work.

I can view it from my web browser when I log in, but I can't access it with youtube-dl.

Giacomo1968
  • 58,727
barlop
  • 25,198

2 Answers2

15

youtube-dl hasn't been updated in a while. As of writing, the last update was late 2021, and we are now mid 2022.

There is a better alternative, yt-dlp

It is a fork of youtube-dl, that is more frequently updated, and faster. They mention it here comparing yt-dlp to youtube-dl: https://linuxconfig.org/yt-dlp-vs-youtube-dl

And it has no problem downloading that video.

An example of usage is at my answer here:

Note: As of January 2024, and quite a bit before, I find in my tests neither of them work for any videos. (whether the video is age restricted or not). YouTube tightened down since they started a paid subscription service. There is the website YTBvideoly that I mentioned in the above link in a note that works for me. yt5s.biz is another that I tested recently and works.

barlop
  • 25,198
4

To download age restricted youtube videos with youtube-dl, you need to do the following:

  1. Sign in to Youtube on your Web Browser, let's say Google Chrome.
  2. Install the following extension: Get cookies.txt
  3. While browsing youtube, click on the extension and export the cookies captured by the extension to a file, say ~/cookies.txt
  4. Run youtube-dl with the option --cookies

Sample command:

youtube-dl -f best https://www.youtube.com/watch?v=mgDtC61bH98 --cookies ~/cookies.txt
Joel G Mathew
  • 191
  • 1
  • 1
  • 6