feat: Add browser cookie authentication for age-restricted videos#565
Open
PhilBrk8 wants to merge 5 commits intojdepoix:masterfrom
Open
feat: Add browser cookie authentication for age-restricted videos#565PhilBrk8 wants to merge 5 commits intojdepoix:masterfrom
PhilBrk8 wants to merge 5 commits intojdepoix:masterfrom
Conversation
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
|
Hello, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-implements cookie authentication using browser cookie extraction (similar to yt-dlp's approach), enabling access to age-restricted video transcripts.
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 firefoxTest 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.