Memory Wiki
← Back to logs

youtube-cookie-check · Jul 08 15:43

Jul 08, 2026 · 08:42 PM
Ended: Jul 08, 2026 · 08:43 PM
User
[IMPORTANT: You are running as a scheduled cron job. DELIVERY: Your final response will be automatically delivered to the user — do NOT use send_message or try to deliver the output yourself. Just produce your report/output as your final response and the system handles the rest. SILENT: If there is genuinely nothing new to report, respond with exactly "[SILENT]" (nothing else) to suppress delivery. Never combine [SILENT] with content — either report your findings normally, or say [SILENT] and nothing more.]

Run the YouTube cookie validity checker script and notify if cookies need updating.
Assistant
{"success": true, "name": "yt-dlp-cookie-management", "description": "Automate checking and refreshing YouTube cookies for yt-dlp to avoid bot detection errors.", "tags": [], "related_skills": [], "content": "---\nname: yt-dlp-cookie-management\ndescription: Automate checking and refreshing YouTube cookies for yt-dlp to avoid bot detection errors.\ncategory: media\nversion: 1.0\n---\n\nWhen YouTube rotates auth cookies frequently, yt-dlp may return \"Sign in to confirm you're not a bot\" errors. This skill provides a self-healing mechanism: a validity checker script and a cron job that runs periodically to verify cookies and alert when refresh is needed.\n\n## Triggers\n- You see yt-dlp errors like \"Sign in to confirm you're not a bot\" or \"Video unavailable\" due to auth.\n- You want to proactively monitor cookie validity to avoid interruptions in YouTube media extraction workflows.\n- You need to sync YouTube cookies from a Windows machine to a Linux server automatically.\n\n## Steps\n1. **Deploy the cookie checker script (Linux/server side)**\n - Place the checker script at a convenient location (e.g., /root/scripts/autoyt_cookie_checker.py or ~/scripts/yt-dlp-cookie-checker.py).\n - Ensure it is executable (chmod +x).\n - The script should:\n - Accept a cookies file path (default /root/cookies.txt).\n - Use yt-dlp with --cookies to fetch metadata from a known-good public video.\n - Detect the bot‑challenge string in stderr/stdout.\n - Return exit code 0 on success, non‑zero with a clear message on failure.\n - Back up the existing cookies before any replacement to a timestamped backup directory.\n - Use a stable, public test video unlikely to be removed or region‑blocked (e.g., Rick Astley – \"Never Gonna Give You Up\", dQw4w9WgXcQ).\n - **Pitfall:** When testing the upload endpoint, never send raw test bytes; they overwrite /root/cookies.txt. Use a separate validation path or restore from backup afterward.\n\n2. **Set up periodic verification (Linux/server side)**\n - Create a cron job (or Hermes cronjob) that runs the checker at your desired interval (e.g., every 6 hours).\n - Configure the job to deliver a notification only when the checker fails (so you’re alerted only when action is needed).\n - Example Hermes cronjob command:\n ``\n hermes cronjob create \\\n --name \"yt-dlp-cookie-check\" \\\n --schedule \"every 6h\" \\\n --prompt \"Run the YouTube cookie validity checker script and notify if cookies need updating.\" \\\n --deliver origin\n `\n\n3. **Deploy the Windows sync script (client side)**\n - Copy the Windows multi-browser sync script to the Windows machine (e.g., C:\\hermes-cookie-sync\\sync.py).\n - Install dependencies: pip install browser_cookie3 requests\n - The script watches three sources:\n - **Browser extension POST** to " target="_blank" rel="noopener">http://127.0.0.1:5006/ — preferred because it bypasses locked DBs.\n - **Manual uploads:** C:\\hermes-cookie-sync\\cookies.txt — any change is uploaded as-is.\n - **Browser databases:** Chrome, Edge, and Opera cookie stores. When a browser DB changes, the script extracts only youtube.com and google.com cookies, converts them to Netscape format, and uploads them.\n - It maintains per-source state hashes so it only uploads on actual changes.\n - It posts to the Linux server endpoint (http://:5005/upload-cookies) with the API key header.\n - Run it as a background process or scheduled task.\n\n4. **Set up the browser extension (when DB is locked)**\n - If browser cookie databases are locked while the browser is running, install the lightweight Chrome extension from templates/chrome-extension-cookie-sync/.\n - The extension uses Manifest V3, requests cookies permission for youtube.com and google.com, and posts Netscape-format cookies to http://127.0.0.1:5006/ every 5 minutes.\n - The local sync.py receiver forwards them to the Linux server.\n - This avoids direct DB reads entirely and works while the browser is running.\n\n5. **Respond to a failure alert**\n - When notified, export fresh YouTube cookies from your browser:\n - Chrome/Chromium → Settings → Privacy and security → Cookies and other site data →\n \"See all cookies and site data\" → Search for youtube.com → Export (Netscape format).\n - Save the exported file as /root/cookies.txt (overwriting the old one).\n - Re‑run the checker to confirm validity.\n - Alternatively, fix the issue on the Windows side and let the sync script auto-upload.\n\n## Pitfalls\n- Using an invalid or expired test video can cause false negatives. Choose a stable, public video (e.g., Rick Astley – \"Never Gonna Give You Up\", dQw4w9WgXcQ) that is unlikely to be removed or region‑blocked.\n- The checker must ignore non‑authentication errors (e.g., video unavailable due to copyright) – treat those as cookie‑related only if the bot‑challenge string appears.\n- Cookies must be in Netscape format (the format yt-dlp expects). Browser‑export extensions often provide this directly; otherwise, use a conversion tool.\n- Do not store cookies in world‑readable locations; restrict permissions to root or the user running yt-dlp.\n- On Windows, browser cookie databases may be locked while the browser is running. The sync script should log the failure and continue; a manual export can be used as a fallback.\n- When testing the upload endpoint, avoid sending raw test data that overwrites the real cookies file; use a separate validation path or restore from backup.\n\n## References\n- references/windows-browser-sync.md – Windows client setup details, browser DB paths, and known quirks.\n- yt-dlp documentation: https://github.com/yt-dlp/yt-dlp#cookies\n- Netscape cookie file format: https://curl.se/docs/http-cookies.html\n\n## Templates\n- templates/chrome-extension-cookie-sync/ – Manifest V3 Chrome extension that pushes YouTube/Google cookies to the local sync.py receiver on 127.0.0.1:5006. Use this when browser cookie databases are locked.\n\n## Scripts\n- scripts/yt-dlp-cookie-checker.py – a ready‑to‑use checker that implements the steps above (see scripts/).\n- scripts/sync_windows_browsers.py – Windows client that watches cookies.txt` and browser DBs (Chrome, Edge, Opera), extracts YouTube/Google cookies in Netscape format, and uploads them to the Linux sync endpoint.\n", "path": "media/yt-dlp-cookie-management/SKILL.md", "skill_dir": "/root/.hermes/skills/media/yt-dlp-cookie-management", "linked_files": {"references": ["references/windows-browser-sync.md"], "templates": ["templates/chrome-extension-cookie-sync/manifest.json"], "scripts": ["scripts/yt-dlp-cookie-checker.py", "scripts/sync_windows_browsers.py"]}, "usage_hint": "To view linked files, call skill_view(name, file_path) where file_path is e.g. 'references/api.md' or 'assets/config.yaml'", "required_environment_variables": [], "required_commands": [], "missing_required_environment_variables": [], "missing_credential_files": [], "missing_required_commands": [], "setup_needed": false, "setup_skipped": false, "readiness_status": "available"}
Assistant
{"status": "error", "error": "BLOCKED: execute_code runs arbitrary local Python (including subprocess calls that bypass shell-string approval checks). Cron jobs run without a user present to approve it. Use normal tools instead, or set approvals.cron_mode: approve only if this cron profile is intentionally trusted.", "tool_calls_made": 0, "duration_seconds": 0}
Assistant
{"output": "total 20\ndrwxr-xr-x 2 root root 4096 Jul 8 15:05 .\ndrwxr-xr-x 5 root root 4096 Jul 8 15:22 ..\n-rw------- 1 root root 4499 Jul 8 15:05 sync_windows_browsers.py\n-rw------- 1 root root 3076 Jul 8 09:43 yt-dlp-cookie-checker.py", "exit_code": 0, "error": null}
Assistant
{"output": "Checking YouTube cookies validity...\n[ERROR] yt-dlp failed: WARNING: skipping cookie file entry due to invalid length 1: 'TEST_E2E=1783542394\\n'\nERROR: '/root/cookies.txt' does not look like a Netscape format cookies file\nWARNING: skipping cookie file entry du\n\nTo fix:\n1. Export fresh cookies from your browser (Chrome/Chromium):\n Settings → Privacy and security → Cookies and other site data →\n See all cookies and site data → Search for youtube.com →\n Click the download/export button (or use a cookie-export extension).\n2. Save the exported cookies as Netscape format to /root/cookies.txt\n3. Re-run this script to verify.\n\nYou can also place a new cookies file at /tmp/new_cookies.txt and run:\n cp /tmp/new_cookies.txt /root/cookies.txt", "exit_code": 1, "error": null}
Assistant
YouTube cookie validity check failed. The cookies file at /root/cookies.txt is invalid or expired.

Details:
Checking YouTube cookies validity...
[ERROR] yt-dlp failed: WARNING: skipping cookie file entry due to invalid length 1: 'TEST_E2E=1783542394\n'
ERROR: '/root/cookies.txt' does not look like a Netscape format cookies file
WARNING: skipping cookie file entry du

To fix:
1. Export fresh cookies from your browser (Chrome/Chromium):
Settings → Privacy and security → Cookies and other site data →
See all cookies and site data → Search for youtube.com →
Click the download/export button (or use a cookie-export extension).
2. Save the exported cookies as Netscape format to /root/cookies.txt
3. Re-run this script to verify.

You can also place a new cookies file at /tmp/new_cookies.txt and run:
cp /tmp/new_cookies.txt /root/cookies.txt


YouTube cookie validity check failed. The cookies file at /root/cookies.txt is invalid or expired.

Details:
Checking YouTube cookies validity...
[ERROR] yt-dlp failed: WARNING: skipping cookie file entry due to invalid length 1: 'TEST_E2E=1783542394\n'
ERROR: '/root/cookies.txt' does not look like a Netscape format cookies file
WARNING: skipping cookie file entry du

To fix:
1. Export fresh cookies from your browser (Chrome/Chromium):
Settings → Privacy and security → Cookies and other site data →
See all cookies and site data → Search for youtube.com →
Click the download/export button (or use a cookie-export extension).
2. Save the exported cookies as Netscape format to /root/cookies.txt
3. Re-run this script to verify.

You can also place a new cookies file at /tmp/new_cookies.txt and run:
cp /tmp/new_cookies.txt /root/cookies.txt