feat: add user commands, auto-detect browser, optimize performance
- Add user/user-posts/followers/following commands - Add UserProfile model and GraphQL API methods - Add print_user_profile and print_user_table formatters - Auto-detect browser for cookies (Chrome → Edge → Firefox → Brave) - Remove --browser option from all commands - Remove cookie verification (v1.1 endpoints are gone) - Use hardcoded fallback query IDs first (skip slow JS bundle scan) - Update FEATURES from latest twitter-openapi config - Fix user-posts: add required withVoice variable - Add tweet URL links in feed output - Add error handling to all user commands
This commit is contained in:
84
README.md
84
README.md
@@ -1,6 +1,6 @@
|
||||
# Twitter CLI
|
||||
|
||||
从你的 Twitter/X 首页抓取推文,智能筛选高价值内容,AI 自动生成摘要。
|
||||
Twitter/X 命令行工具 — 读取 Timeline、管理推文。
|
||||
|
||||
**零 API Key** — 使用浏览器 Cookie 认证,免费访问 Twitter。
|
||||
|
||||
@@ -19,38 +19,70 @@ twitter feed
|
||||
|
||||
## 使用方式
|
||||
|
||||
### 读取
|
||||
|
||||
```bash
|
||||
# 完整 pipeline:抓取 50 条 → 筛选 top 20 → AI 总结
|
||||
# 抓取首页 timeline
|
||||
twitter feed
|
||||
|
||||
# 自定义抓取条数
|
||||
twitter feed --count 50
|
||||
|
||||
# 只抓取 + 筛选,跳过 AI 总结
|
||||
twitter feed --no-summary
|
||||
|
||||
# JSON 输出(可重定向到文件)
|
||||
twitter feed --json > tweets.json
|
||||
|
||||
# 对已有数据做筛选 + 总结
|
||||
twitter feed --input tweets.json
|
||||
twitter feed --max 50
|
||||
|
||||
# 跳过筛选
|
||||
twitter feed --no-filter
|
||||
|
||||
# 指定浏览器
|
||||
twitter feed --browser firefox
|
||||
# JSON 输出
|
||||
twitter feed --json > tweets.json
|
||||
|
||||
# 从已有数据加载
|
||||
twitter feed --input tweets.json
|
||||
|
||||
|
||||
# 抓取收藏
|
||||
twitter bookmarks
|
||||
twitter bookmarks --count 30 --json
|
||||
twitter favorite
|
||||
twitter favorite --max 30 --json
|
||||
```
|
||||
|
||||
### 用户
|
||||
|
||||
```bash
|
||||
# 查看用户资料
|
||||
twitter user elonmusk
|
||||
|
||||
# 列出用户推文
|
||||
twitter user-posts elonmusk --max 20
|
||||
|
||||
# 查看粉丝
|
||||
twitter followers elonmusk --max 30
|
||||
|
||||
# 查看关注
|
||||
twitter following elonmusk --max 30
|
||||
```
|
||||
|
||||
### 发推
|
||||
|
||||
```bash
|
||||
# 发新推文
|
||||
twitter post "Hello World"
|
||||
|
||||
# 回复推文
|
||||
twitter reply <tweet_id> "这是回复内容"
|
||||
|
||||
# 引用转推(传 URL 或 ID 均可)
|
||||
twitter quote <tweet_url_or_id> "这是引用内容"
|
||||
|
||||
# 删除推文(会有确认提示)
|
||||
twitter delete <tweet_id>
|
||||
|
||||
# 跳过删除确认
|
||||
twitter delete <tweet_id> --yes
|
||||
```
|
||||
|
||||
## Pipeline
|
||||
|
||||
```
|
||||
抓取 (GraphQL API) → 筛选 (Engagement Score) → AI 总结
|
||||
50 条 top 20 按主题分组
|
||||
抓取 (GraphQL API) → 筛选 (Engagement Score)
|
||||
50 条 top 20
|
||||
```
|
||||
|
||||
### 筛选算法
|
||||
@@ -62,10 +94,6 @@ score = 1.0 × likes + 3.0 × retweets + 2.0 × replies
|
||||
+ 5.0 × bookmarks + 0.5 × log10(views)
|
||||
```
|
||||
|
||||
### AI 总结
|
||||
|
||||
支持 **OpenAI-compatible**(doubao / deepseek / openai)和 **Anthropic**(Claude)两种 API 格式。
|
||||
|
||||
## 配置
|
||||
|
||||
编辑 `config.yaml`:
|
||||
@@ -83,18 +111,11 @@ filter:
|
||||
replies: 2.0
|
||||
bookmarks: 5.0
|
||||
views_log: 0.5
|
||||
|
||||
ai:
|
||||
provider: "openai" # "openai" or "anthropic"
|
||||
api_key: "" # 或设置环境变量 AI_API_KEY
|
||||
model: "doubao-seed-2.0-code"
|
||||
base_url: "https://ark.cn-beijing.volces.com/api/coding"
|
||||
language: "zh-CN"
|
||||
```
|
||||
|
||||
### Cookie 配置
|
||||
|
||||
**方式 1:自动提取**(推荐) — 确保 Chrome 已登录 x.com,程序自动通过 `browser-cookie3` 读取。
|
||||
**方式 1:自动提取**(推荐) — 确保浏览器已登录 x.com,程序自动通过 `browser-cookie3` 按 Chrome → Edge → Firefox → Brave 顺序尝试读取。
|
||||
|
||||
**方式 2:环境变量** — 设置:
|
||||
|
||||
@@ -111,10 +132,9 @@ export TWITTER_CT0=your_ct0
|
||||
twitter_cli/
|
||||
├── __init__.py # 版本信息
|
||||
├── cli.py # CLI 入口 (click)
|
||||
├── client.py # Twitter GraphQL API Client
|
||||
├── client.py # Twitter GraphQL API Client (GET + POST)
|
||||
├── auth.py # Cookie 提取 (env / browser-cookie3)
|
||||
├── filter.py # Engagement scoring + 筛选
|
||||
├── summarizer.py # AI 总结 (OpenAI + Anthropic)
|
||||
├── formatter.py # Rich 终端输出 + JSON
|
||||
├── config.py # YAML 配置加载
|
||||
└── models.py # 数据模型 (dataclass)
|
||||
|
||||
Reference in New Issue
Block a user