polish: cookie header string parsing + Cookie-Editor guide + server user path

Key improvements:
- twitter-cookies now accepts BOTH formats:
  1. Full cookie header string from Cookie-Editor export
  2. Two separate values (auth_token ct0)
  Automatically detects which format was pasted.

- New docs/cookie-export.md guide for server users
  Recommends Cookie-Editor Chrome extension (one-click export)
  Fallback: manual F12 → Network → Cookie header

- Install guide now has two clear paths:
  Path A (local): --from-browser chrome (one command, all cookies)
  Path B (server): Cookie-Editor extension export (30 sec per site)

- Better error messages with accepted format examples
This commit is contained in:
Panniantong
2026-02-24 07:02:44 +01:00
parent b264070a8d
commit 89b3eaf5da
3 changed files with 125 additions and 42 deletions
+27 -8
View File
@@ -309,11 +309,28 @@ def _cmd_configure(args):
print(f"❌ Failed: {e}")
elif args.key == "twitter-cookies":
# Expect: auth_token ct0
parts = value.split()
if len(parts) == 2:
config.set("twitter_auth_token", parts[0])
config.set("twitter_ct0", parts[1])
# Accept two formats:
# 1. auth_token ct0 (two separate values)
# 2. Full cookie header string: "auth_token=xxx; ct0=yyy; ..."
auth_token = None
ct0 = None
if "auth_token=" in value and "ct0=" in value:
# Full cookie string — parse it
for part in value.replace(";", " ").split():
if part.startswith("auth_token="):
auth_token = part.split("=", 1)[1]
elif part.startswith("ct0="):
ct0 = part.split("=", 1)[1]
elif len(value.split()) == 2 and "=" not in value:
# Two separate values: AUTH_TOKEN CT0
parts = value.split()
auth_token = parts[0]
ct0 = parts[1]
if auth_token and ct0:
config.set("twitter_auth_token", auth_token)
config.set("twitter_ct0", ct0)
print(f"✅ Twitter cookies configured!")
print("Testing Twitter access...", end=" ")
@@ -321,7 +338,7 @@ def _cmd_configure(args):
import subprocess
result = subprocess.run(
["birdx", "search", "test", "-n", "1",
"--auth-token", parts[0], "--ct0", parts[1]],
"--auth-token", auth_token, "--ct0", ct0],
capture_output=True, text=True, timeout=15,
)
if result.returncode == 0 and result.stdout.strip():
@@ -333,8 +350,10 @@ def _cmd_configure(args):
except Exception as e:
print(f"❌ Failed: {e}")
else:
print("Usage: agent-eyes configure twitter-cookies AUTH_TOKEN CT0")
print(" (two values separated by space)")
print("Could not find auth_token and ct0 in your input.")
print(" Accepted formats:")
print(" 1. agent-eyes configure twitter-cookies AUTH_TOKEN CT0")
print(' 2. agent-eyes configure twitter-cookies "auth_token=xxx; ct0=yyy; ..."')
elif args.key == "xhs-cookie":
config.set("xhs_cookie", value)