9

I tried downloading a particular YouTube video using youtube-dl (in terminal) and got the following display:

[youtube] 8_Ik8elX96w: Downloading webpage
[youtube] 8_Ik8elX96w: Downloading embed webpage
[youtube] 8_Ik8elX96w: Refetching age-gated info webpage
ERROR: This video may be inappropriate for some users.

The URL for the video is: https://www.youtube.com/watch?v=8_Ik8elX96w

I've been told that this is to do with YouTube age restrictions and that I need youtube-dl to log in to my YouTube account to bypass the restriction; and this requires can be enabled by supplying the required cookie set for YouTube log-in in the command line. (youtube-dl does not access YouTube via my browser, so manually logging in through my browser does not bypass the restriction for youtube-dl.)

If this is the correct way to bypass the restriction, please tell me how to find the cookie path to type into the command line and the procedure for entering it there. I am using Firefox; apparently the method of finding the required cookie text is different for each browser.

4
  • 3
  • Don't ask the same question twice.
    – heynnema
    Jun 2, 2021 at 13:46
  • @heynnema The first question about was why it is happening. I also asked whether there is a work around, in the body of that question. This question is asking what the work-around is and how I do it. Nobody gave me specific instructions for this in response to the first question. So no, there is no answer posted for this to the first question. Did you bother to read it before wisecracking?
    – Allan
    Jun 2, 2021 at 16:54
  • 2
    Both questions are about a third-party program not supplied by Ubuntu, and a third-party YouTube video, also having nothing to do with Ubuntu. Both questions are actually off-topic on this web site. Do youtube-dl -h for more help.
    – heynnema
    Jun 2, 2021 at 17:19

4 Answers 4

10

yt-dlp looks like a fork of youtube-dl and works as expected. You can install it as follows (from the project's GitHub 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
5

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
4

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).
1
  • 3
    With youtube-dl version 2021.12.17 the --cookies option works indeed, you can export all of of your YouTube cookies in Netscape format with this chrome.google.com/webstore/detail/get-cookiestxt/… Chrome extension (make sure you run it on the tab where you have a logged in YouTube page).
    – reim
    Jan 2, 2022 at 15:21
4

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .