Skip to content

feat: Add browser cookie authentication for age-restricted videos#565

Open
PhilBrk8 wants to merge 5 commits intojdepoix:masterfrom
PhilBrk8:master
Open

feat: Add browser cookie authentication for age-restricted videos#565
PhilBrk8 wants to merge 5 commits intojdepoix:masterfrom
PhilBrk8:master

Conversation

@PhilBrk8
Copy link
Copy Markdown

Summary

Re-implements cookie authentication using browser cookie extraction (similar to yt-dlp's approach), enabling access to age-restricted video transcripts.

  • Extract cookies directly from browser databases (no manual cookie file export needed)
  • Support for Chrome, Firefox, Edge, Brave, Chromium, Opera, and Vivaldi
  • Cross-platform: Linux, macOS, and Windows
  • Optional dependencies via pip install 'youtube-transcript-api[cookies]'

Usage

Python API:
from youtube_transcript_api import YouTubeTranscriptApi

api = YouTubeTranscriptApi(cookies_from_browser='chrome')
transcript = api.fetch('VIDEO_ID')

CLI

youtube_transcript_api VIDEO_ID --cookies-from-browser firefox

Test plan

[x] Unit tests for cookie extraction (test_cookies.py)
[x] Platform detection tests (Linux/macOS/Windows)
[x] Browser path resolution tests
[x] Firefox cookie extraction (unencrypted)
[x] Chrome cookie extraction with mocked decryptor
[x] Error handling for unsupported browsers
[x] All existing tests pass (93 passed, 5 skipped)
The 5 skipped tests are pre-existing disabled tests for the old cookie_path file-based approach.

Implement cookie extraction from browser databases, similar to yt-dlp's
approach. Supports Chrome, Firefox, Edge, Brave, Chromium, Opera, and
Vivaldi across Linux, macOS, and Windows.

- _cookies.py: Browser detection and cookie extraction logic
- _decryptors.py: Platform-specific cookie decryption (AES-CBC/GCM, DPAPI)
- Add cookies_from_browser parameter to YouTubeTranscriptApi
- Add --cookies-from-browser CLI flag
- Update AgeRestricted error with auth instructions
- Add CookieError, CookiePathInvalid, CookieInvalid exceptions
@rijony
Copy link
Copy Markdown

rijony commented Mar 27, 2026

Hello,
I'm interested by cookies auth and saw your pull request.
I'm wondering why your proposition wasn't merged.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants