Downloading Age Restricted Videos With Youtube-DL

Recently I wanted to download a YouTube video using YouTube-DL, but received the following error message:

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.

Although I disagree strongly with YouTube’s increasing habit of haphazardly applying age restrictions on videos, I still wanted a local copy of the video.

The solution is to pass a cookie to YouTube as part of the download process in YouTube-DL. I was able to accomplish that with the following steps.

  1. I installed the Get Cookies extension in Chrome. This extension allows users to export cookies for a site as a text file.
  2. I then visited YouTube.com, while I was logged in, and clicked on the Get
    Cookies icon. Then I clicked on the “Export” button to download my YouTube cookies as a text file.
  3. This created a youtube.com_cookies.txt file that I then copied into the YouTube-DL directory on my laptop.
  4. Finally I ran the following command in YouTube-DL to pass the cookie to YouTube and download the video:
youtube-dl -f bestvideo+bestaudio --merge-output-format mkv --all-subs --cookies youtube.com_cookies.txt [YouTube URL]

11 thoughts on “Downloading Age Restricted Videos With Youtube-DL”

  1. For those still unable to make it work because of the AttributeError: 'bool' object has no attribute 'split' error you can also try 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 the python3 command is working first. Also make sure that the path to your cookies file is correct.

  2. Worked perfectly. Get Cookies saves the file in your Download folder and if you copy paste the youtube-dl command you have to add “.\” in front and edit the cookie file name.

  3. Make sure the filename is correct. The example above isn’t. Works with “youtube.com_cookies.txt”

  4. This works perfectly. For those who don’t get it to work, please try and add quotation marks to the YouTube URL, namely ‘https://www.youtube.com/watch?v=videocode’. I need quotation marks to get this working in iTerm. Also, just drag the cookie file to the terminal window and your will get the full path.. but that’s just plain good practice doing anything with the terminal on a Mac..

  5. I can’t make this work. I exported the cookie while on the YouTube page and signed in. I used the –cookies option to give it the cookie file and it still gives me the same error about it being age restricted.

Leave a Reply