Synopsis

Export Netscape HTTP Cookie File from browser using the Get cookies.txt LOCALLY extension and pass the cookie path with --cookies flag in yt-dlp as authentication method.

Background

Possible and notable ways for authentication are plaintext --username & --password, --netrc, and --cookies (along with --cookies-from-browser). Username and password method may be configured to use OAuth but that has been deprecated. While yt-dlp supports the --cookies-from-browser flag to extract cookies directly from installed browsers, it can encounter issues with Chromium-based browsers due to changes in their storage mechanisms (cookies locked, and DPAPI).

This can be mitigated by using Firefox, but the preferred method is the extract cookies for specific site locally and point to that file for yt-dlp to use. This offers flexibility on choosing which account to use and simplifies the overall process.

Procedure

  1. Open a chromium browser (like Chrome or Edge)
  2. Install the extension Get cookies.txt LOCALLY
  3. Open Incognito or InPrivate window and open the website requiring login
  4. Sign in using preferred account
  5. Extract the cookies for that site using the extension installed earlier
  6. Save the cookie file at %LOCALAPPDATA%/yt-dlp/cookies.txt

Usage

Pass the following flag when using yt-dlp:

--cookies "%LOCALAPPDATA%/yt-dlp/cookies.txt"

References: