9

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

so

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 username I tried the email address i'd 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

barlop
  • 23,849
  • https://askubuntu.com/questions/1342218/how-do-i-enable-youtube-dl-to-bypass-the-age-restriction-on-youtube – Gantendo May 27 '22 at 03:47

2 Answers2

13

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 it 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

https://askubuntu.com/questions/1342197/why-is-youtube-dl-blocking-me-from-downloading-youtube-videos-which-are-supposed/1410983#1410983

Note- As of Jan 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.

barlop
  • 23,849
  • note- found that out speaking to a ubuntu expert, though it's not specific to ubuntu – barlop May 27 '22 at 04:43
  • 1
    and by 'faster', it looks like a 3 minute download for something youtube-dl was taking 6+ hrs and failing with. So yes. Definitely faster. Much faster. – ClioCJS Oct 27 '22 at 05:39
  • My experience is quite different. To Barlop's suggestion that yt is faster than dl I have yet to experience this myself, both are fast. Also regarding the error, yt has the exact same issue as dl for many videos. Example: https://www.youtube.com/watch?v=yVsdKoUCBuI spits out "ERROR: [youtube] yVsdKoUCBuI: Sign in to confirm your age. This video may be inappropriate for some users." using yt. Unlike ClioCJS I have never spent more than a few minutes downloading lengthy videos although every once in a while youtube.com drip feeds the stream chunks making it take longer using either tool. – ubuntux Jan 12 '24 at 13:57
  • @ubuntux i've updated my answer. – barlop Jan 12 '24 at 14:14
3

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