How to Configure YouTube Cookies for Age-Restricted and Member-Only Videos in Agent-Reach
Agent-Reach leverages yt-dlp to download YouTube content, and you can unlock access to age-restricted or channel-membership videos by configuring the youtube-cookies setting to point to your browser's cookie store using the CLI command agent-reach configure youtube-cookies <browser>.
Agent-Reach is an open-source intelligence tool that processes YouTube videos through yt-dlp. When you need to access age-restricted or member-only content, you must configure YouTube cookies so the downloader can authenticate requests using your logged-in browser session.
How Cookie Authentication Works in Agent-Reach
Agent-Reach delegates video downloading to yt-dlp, which supports reading cookies directly from browser SQLite databases. When you configure YouTube cookies for age-restricted videos, Agent-Reach stores the cookie source location in its global configuration and passes it to yt-dlp via the --cookies-from-browser flag.
The configuration flow involves these core components:
agent_reach/cli.py(lines 1092–1096): Handles theconfiguresub-command and persists theyoutube_cookies_fromvalueagent_reach/config.py: Manages the YAML configuration file at~/.agent-reach/config.yamlagent_reach/channels/youtube.py: Validates yt-dlp installation and triggers the download processagent_reach/utils/paths.py: Containsrender_ytdlp_fix_command()which constructs the yt-dlp command including the cookie flag
Configuring YouTube Cookies via CLI
Setting the Cookie Source
Run the configure command to specify which browser contains your YouTube login session:
agent-reach configure youtube-cookies chrome
Supported values include browser names (chrome, firefox, edge, safari) or absolute paths to browser profile directories:
agent-reach configure youtube-cookies /home/user/.config/google-chrome/Default
Verifying the Configuration
Confirm the setting was written to your configuration file:
agent-reach config show | grep youtube_cookies_from
Expected output:
youtube_cookies_from: chrome
Processing Restricted Videos
Once configured, Agent-Reach automatically includes cookies when processing URLs:
# Fetch an age-restricted video
agent-reach read https://www.youtube.com/watch?v=RESTRICTED_ID
# Extract transcripts from member-only content
agent-reach read --transcribe https://youtu.be/MEMBER_ONLY_ID
Implementation Details
When you execute agent-reach configure youtube-cookies, the CLI writes the value to the youtube_cookies_from key in ~/.agent-reach/config.yaml. During video processing, the YouTubeChannel class in agent_reach/channels/youtube.py validates that yt-dlp is installed and that a JavaScript runtime is available.
The function render_ytdlp_fix_command() in agent_reach/utils/paths.py constructs the final yt-dlp command, appending --cookies-from-browser <value> when the configuration key exists. This allows yt-dlp to authenticate with YouTube using your existing browser session, bypassing age-verification and membership checks.
Summary
- Agent-Reach uses yt-dlp to download YouTube content, which requires authentication cookies for restricted videos
- Configure the cookie source using
agent-reach configure youtube-cookies <browser|path> - The setting is stored as
youtube_cookies_fromin~/.agent-reach/config.yamlviaagent_reach/cli.py - During execution,
agent_reach/utils/paths.pyappends the--cookies-from-browserflag to yt-dlp commands - This enables processing of age-restricted and member-only videos without manual cookie extraction
Frequently Asked Questions
Why do I need cookies for age-restricted videos?
YouTube requires authentication to verify age or membership status before serving restricted content. yt-dlp can read these authentication tokens from your browser's cookie store, allowing Agent-Reach to download videos that would otherwise return HTTP 403 or "content unavailable" errors.
Can I use a custom cookie file instead of a browser profile?
Yes. While the examples show browser names like chrome or firefox, you can provide an absolute path to any directory containing the browser's SQLite cookie database. For example: agent-reach configure youtube-cookies /path/to/custom/cookies.sqlite.
Where is the cookie configuration stored?
The configuration is persisted in the global Agent-Reach configuration file at ~/.agent-reach/config.yaml under the key youtube_cookies_from. This file is managed by agent_reach/config.py and written to by the CLI handler in agent_reach/cli.py at lines 1092–1096.
What happens if yt-dlp cannot read my browser cookies?
If yt-dlp fails to access the specified browser profile—due to permissions, encryption, or the browser being locked—Agent-Reach will return an error indicating the video is unavailable. Ensure your browser is closed or use a copy of the cookie database to avoid file locking issues on Windows or macOS.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →