yt-dlp It's, without a doubt, the best software for downloading YouTube videos. It does much more than that, and it's not limited to videos from Google's popular platform, but its use may not be the most intuitive in all cases. It's been a while since we wrote a guide It was easy to use this fantastic tool, but it was incomplete. It wasn't our goal to explain everything the instructions explain, but there was something important we didn't include.
If you want to download videos at their highest quality, using yt-dlp is very simple: enter the name of the program followed by the link and press enter. If the above fails, it may be because some devices require the link to be in quotes. That's it, unless you come across a age-restricted videoWhat can we do in that case?
yt-dlp can download using cookies
There are many ways to watch age-restricted videos without an account, but none currently work. Two of them are adding the letters "nsfw" before "youtube" or "repeat" after it, which leads us to two different services that, at least at the time of writing, have stopped working. It's also said that changing "watch?v=" to "/embed/" removes the restriction, but that doesn't work either. YouTube makes changes almost daily, and what works today is likely to stop working tomorrow.
But the developers of yt-dlp are the quickest to act. The most basic command—yt-dlp "link"—can't handle these restricted videos, but it can if we allow it to use YouTube cookies. The process would be as follows:
- Of course, if yt-dlp isn't installed, we'll install it. It may be in the official distribution repositories, but you can also download yt-dlp.py from your GitHub page and launch it from the path where it is located after giving it execution permissions — chmod -x yt-dlp.py –.
- We need to have a Google account and be logged into YouTube in the browser.
- We launch the following command:
yt-dlp --cookies-from-browser browser "link"
And that would be all.
The previous flag is self-explanatory, but the rest needs to be explained a little:
- yt-dlp is the software.
- --cookies-from-browser That's what makes the magic happen. The Spanish translation is "browser cookies."
- navigator This is the name of the browser we're logged into on YouTube. For example, instead of "browser," you should use "firefox" without the quotation marks, as long as you're logged in.
- "link", which is usually in quotation marks, is the link to the video.
In short, we say, "Launch yt-dlp, use the Firefox browser cookies, and download the link."
Other use of cookies
There is another way to use cookies, but I think it's more tedious, and the only reason I see is if we don't want to remain logged in to YouTube. Furthermore, it's possible, and even likely, that Google will detect a change or whatever it wants, and this method could stop working at any time—not because of the method itself, but because the cookies we'll download will no longer be valid. But it's another option, and we'll explain it.
From the previous command you only have to change two things:
- –cookies-from-browser will be just –cookies.
- The browser name will be the path to a text file that we will create previously.
To use this method, you need to get the cookies from youtube.com — preferably the root of the domain, not a video page — and save them to a text file. The best way is to use an extension like cookie-editor, which in addition to editing them allows them to be exported to a format compatible with yt-dlp.
Once the extension is installed, go to youtube.com, click on the extension, and then click "Export."
He will ask us the format, and we have to choose "Netscape". Clicking the format button will copy it to the clipboard. We need to paste that text into a file that can have any name we want, but "cookies.txt" would be fine. If we want to be more specific about what cookies it contains, we can use another name like "yt-cookies.txt." The point is, we need to know the name, the path, and the extension, which must be .txt.
As we have already explained, all that remains is to use the correct command, which in this case would be:
yt-dlp --cookies /path/to/cookies.txt "link-to-video"
IMPORTANT: Cookies contain information about our session and should not be shared with anyone.
Download any video
And this would be the way. Knowing this, the only thing left would be private videos, that is, those that are only shared with specific users and cannot be accessed any other way. But we could still access all the others.