1

How do I use the --cookies option to youtube-dl to download a Youtube video? Can anyone provide a worked example of how to obtain the relevant cookies for Youtube and put it in the appropriate format for youtube-dl?

Context: I want to download a private Youtube video. For various reasons, the method of logging into my Google account is complicated and involves two-factor authentication and not supported by youtube-dl's existing command-line options. Therefore, it seems the best way is to log in manually in my browser, obtain the authentication cookies somehow, and use the --cookies option -- but I can't find a worked example of how to do this.

  • Did you try generating an app password in your google account dashboard and using that when providing your credentials to YouTube-dl? – wateroverflow9102 Jan 27 at 0:54
  • 1
    @wateroverflow9102, no! That's a great idea, thank you for the suggestion. – D.W. Jan 27 at 2:05
  • I think the cookie method would also work, but this might prove to be a more long-term solution since you wouldn’t have to repeat this process every once in a while after the session expires... – wateroverflow9102 Jan 27 at 2:23
2

Once you get the cookies, you only need to run youtube-dl --cookies /pathtocookiefile

If you use Chrome and accept third-party plugins to read your cookies.
Just try this cookie.txt,open the youtube then click cookie.txt plugin.
One more click ,you can download the cookie file for one tab or all. enter image description here

If you want do it manual in Chrome. F12 > Application > Storage > Cookies.
You need convert cookie list to Netscape format cookies file

#domain          HTTP/Secure    Expires      Name Value  
.youtube.com     TRUE/FALSE    1548523767    GPS    1

You must log in to answer this question.

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