How to Set Up YouTube with Cookies for Age-Restricted Videos in Agent Reach

Agent Reach authenticates YouTube requests through yt-dlp using browser cookies, enabling seamless access to age-restricted and member-only content via the youtube-cookies configuration key.

Agent Reach is an open-source content retrieval framework that processes YouTube videos through the yt-dlp backend. When you encounter age-restricted videos or channel membership content, you must configure YouTube with cookies to authenticate requests as a logged-in user. This guide walks through the exact implementation in the Panniantong/Agent-Reach repository, showing you how to set up YouTube with cookies for age-restricted videos using the official CLI and configuration system.

Agent Reach delegates all YouTube video retrieval to yt-dlp, which requires valid authentication cookies to bypass age verification gates. The system stores your cookie source preference in the global configuration file (~/.agent-reach/config.yaml) under the key youtube_cookies_from.

When this configuration is present, the YouTubeChannel class hands control to yt-dlp with the --cookies-from-browser flag. This flag instructs yt-dlp to read cookies directly from your browser's SQLite database or a specified file path, authenticating requests exactly as your logged-in browser would.

The relevant implementation spans three core components:

  • agent_reach/cli.py (lines 1092–1096): Handles the configure sub-command and persists the cookie source to the config file via config.set("youtube_cookies_from", value)

  • agent_reach/channels/youtube.py: Defines the YouTube channel logic and validates yt-dlp availability before processing

  • agent_reach/utils/paths.py: Contains render_ytdlp_fix_command() which constructs the yt-dlp command including the cookie authentication flag

Configuring YouTube Cookies via CLI

Use the configure sub-command to specify your browser profile or cookie file location. Agent Reach supports standard browser identifiers or absolute paths to custom cookie stores.

For standard browser profiles:

agent-reach configure youtube-cookies chrome

For Firefox or Edge:

agent-reach configure youtube-cookies firefox
agent-reach configure youtube-cookies edge

For non-standard installations or custom cookie files, provide the absolute path to the browser profile directory:

agent-reach configure youtube-cookies /home/user/.config/google-chrome/Default

Verifying the Configuration

Confirm that your setting was persisted correctly by inspecting the configuration file:

agent-reach config show | grep youtube_cookies_from

The output should display:

youtube_cookies_from: chrome

This value is stored in agent_reach/config.py and written to the YAML configuration file at ~/.agent-reach/config.yaml.

Fetching Age-Restricted Content

Once configured, Agent Reach automatically applies cookies when processing YouTube URLs. The execution flow follows this path:

  1. YouTubeChannel.check verifies that yt-dlp is installed and a JavaScript runtime is available

  2. YouTubeChannel.transcribe initiates the download process

  3. render_ytdlp_fix_command() in agent_reach/utils/paths.py appends --cookies-from-browser <value> to the yt-dlp invocation

  4. yt-dlp reads the cookies from your browser store and authenticates the request to YouTube's servers

To retrieve a restricted video:

agent-reach read https://www.youtube.com/watch?v=RESTRICTED_ID

To extract subtitles or transcripts from member-only content:

agent-reach read --transcribe https://youtu.be/RESTRICTED_ID

Technical Implementation Details

The cookie integration relies on a specific chain of method calls across the Agent Reach codebase. When you execute agent-reach configure youtube-cookies chrome, the cli.py module parses the command and calls config.set("youtube_cookies_from", "chrome") at lines 1092–1096.

During video processing, the YouTubeChannel class in agent_reach/channels/youtube.py delegates to yt-dlp. The utility function render_ytdlp_fix_command() constructs the final command string, automatically injecting the --cookies-from-browser flag with the value retrieved from the configuration. This allows yt-dlp to access your browser's encrypted cookie store (Chrome's SQLite database, Firefox's cookies.sqlite, etc.) without requiring manual cookie extraction.

Summary

  • Agent Reach uses yt-dlp as the backend for YouTube video retrieval, which requires authentication for restricted content

  • Configure cookie sources using agent-reach configure youtube-cookies <browser|path> to store the value in ~/.agent-reach/config.yaml

  • The system supports standard browsers (Chrome, Firefox, Edge) or absolute paths to profile directories

  • During execution, agent_reach/utils/paths.py constructs the yt-dlp command with the --cookies-from-browser flag

  • This authentication flow enables access to age-restricted videos and member-only content without manual cookie file management

Frequently Asked Questions

Agent Reach supports any browser that yt-dlp can read cookies from, including Chrome, Edge, and Firefox. You can specify these by name (chrome, firefox, edge) or provide the absolute path to the browser's profile directory if using a non-standard installation.

Yes. While the examples show browser identifiers like chrome, you can provide an absolute path to any directory containing valid browser cookies. For example: agent-reach configure youtube-cookies /path/to/custom/cookie/store. yt-dlp will attempt to read the cookie database from that location.

The cookie source is stored in the youtube_cookies_from key within the global configuration file at ~/.agent-reach/config.yaml. This is managed by agent_reach/config.py and written when you run the configure sub-command handled in agent_reach/cli.py (lines 1092–1096).

Why does Agent Reach need my browser cookies for age-restricted videos?

YouTube requires authentication to verify age or channel membership status before serving restricted content. By configuring cookies, you allow yt-dlp to present the same session tokens your browser uses, satisfying YouTube's authentication checks. Without this configuration, yt-dlp cannot access videos behind age-verification or paywalls.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →