Skip to content

Using your cookies in yt‐dlp

Fred Vatin edited this page May 6, 2026 · 1 revision

Introduction

yt-dlp often requires a valid cookie to download content from YouTube. Similarly, downloading from 𝕏 (Twitter) requires cookies if the post is from a private account.

Current supported browsers for yt-dlp:

  • firefox
  • edge
  • chrome
  • chromium
  • opera
  • safari
  • brave
  • vivaldi
  • whale

For an up-to-date list, check the --cookies-from-browser section in the official repository.


Recommendation

yt-dlp can extract cookies directly from a browser, profile, or container. For more details, refer to the yt-dlp FAQ.

Why Firefox is preferred

It is highly recommended to use Firefox. Chromium-based browsers (Edge, Chrome, Brave, etc.) often encrypt cookie databases or prevent easy access, which can prevent yt-dlp from reading them easily. See this issue for technical context.

Best Practice: Dedicated Profile

Creating a dedicated Firefox profile for yt-dlp is the most secure and efficient method:

  1. Security: It isolates your main browsing data.
  2. Performance: yt-dlp loads cookies faster from a smaller, specific profile.
  3. Maintenance: If a cookie expires, simply open this profile, log in again, and close it.

Example Setup: If you created a Firefox profile named Youtube:

  1. On Windows, go to %appdata%\Mozilla\Firefox\Profiles.
  2. Identify the folder name (e.g., oo49eawy.Youtube).
  3. In your yt-download.ps1 script (around line 42), configure it as follows:
New-Variable -Name UseBrowser -Value $true -Option Constant
# Format: "browser:profile_directory_name"
New-Variable -Name browserCookies -Value "firefox:oo49eawy.Youtube" -Option Constant

Exporting to cookies.txt

Caution

This method is discouraged for security reasons. Please read the Security section below before proceeding.

If you must use a standalone file, you can export cookies using the terminal:

yt-dlp --cookies-from-browser firefox --cookies cookies.txt

If yt-dlp fails to access the browser data directly, use these verified extensions:


Security

If you use a cookies.txt file, store it in a secure location (e.g., your Documents folder or an encrypted drive) and update your yt-download.ps1 script:

New-Variable -Name UseBrowser -Value $false -Option Constant
New-Variable -Name myCookies -Value "C:/path/to/your/secure/cookies.txt"

Critical Warnings

  • Privacy: A cookies.txt file contains sensitive session tokens. If stolen, an attacker can hijack your active sessions without needing your password.
  • Minimalism: Always edit the file to remove cookies for unrelated websites. Only keep the strictly necessary entries.
  • Protection: Enable Two-Factor Authentication (2FA) on all accounts used with these cookies.
  • Access Control: Ensure the file is only readable by your user account or administrator.

Clone this wiki locally