Skip to content

feat(weibo): add statuses command to fetch user timeline#1256

Open
ZepPellN wants to merge 2 commits into
jackwener:mainfrom
ZepPellN:feat/weibo-statuses
Open

feat(weibo): add statuses command to fetch user timeline#1256
ZepPellN wants to merge 2 commits into
jackwener:mainfrom
ZepPellN:feat/weibo-statuses

Conversation

@ZepPellN

@ZepPellN ZepPellN commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds opencli weibo statuses <id> command to fetch a specific user's Weibo timeline.

Currently opencli supports:

  • weibo user <id> — user profile
  • weibo post <id> — single post detail
  • weibo feed — personal for-you / following timeline

But there is no way to list a specific user's statuses. This PR fills that gap.

What Changed

  • New adapter: clis/weibo/statuses.js
  • Uses /ajax/statuses/mymblog?uid=<uid>&page=<page>&feature=0 API (discovered via browser network capture)
  • Resolves screen_name → uid automatically if a non-numeric ID is provided
  • Returns rich metadata: id, mblogid, text, isLongText, created_at, reposts, comments, likes, pic_num, url, plus retweeted and page_info when available

Usage

# By UID
opencli weibo statuses 1233486457 --limit 5

# By screen name
opencli weibo statuses "高飞" --limit 10 --page 2

# JSON output
opencli weibo statuses 1233486457 --limit 5 -f json

Test Plan

  • opencli validate passes
  • E2E tested against real Weibo user pages (authenticated cookie session)
  • Both numeric UID and screen_name resolution work
  • Long text flag, retweeted content, and page_info are correctly extracted
  • Pagination (--page) works

Notes

  • Requires cookie authentication (same as other weibo commands)
  • text is capped at 500 chars in list view; use weibo post <mblogid> for full long-text expansion

jean added 2 commits April 29, 2026 00:20
Add Z-Library adapter with two browser-based commands:

- `search` — Search books by title, author, or ISBN.
  Navigates to /s/<query> and extracts results from
  <z-bookcard> shadow DOM custom elements.

- `info` — Get book details and available download formats
  from a book page URL.

Uses Strategy.COOKIE with browser automation to bypass
Cloudflare protection. The adapter reuses the user's existing
Z-Library login cookies from system Chrome.

Known limitation: actual file downloading requires Playwright's
download event handling (page.on('download')). OpenCLI's browser
automation does not currently intercept file downloads. Users
needing to download files should use Playwright to navigate to
the book URLs discovered by this adapter.
Add `opencli weibo statuses <id>` command to fetch a user's
Weibo statuses/timeline via /ajax/statuses/mymblog API.

Supports:
- uid (numeric) or screen_name as positional arg
- --limit (max 50, default 15)
- --page for pagination
- Returns: id, mblogid, text, isLongText, created_at,
  reposts, comments, likes, pic_num, url
- Includes retweeted content and page_info when available

Closes gap where opencli weibo had user/profile and single
post fetch, but no way to list a specific user's statuses.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I reviewed the current head (40f1ae47) against current main; this needs changes before content review can continue.

Required changes:

  1. Rebase onto latest main and resolve conflicts. GitHub currently reports CONFLICTING/DIRTY, mainly because cli-manifest.json and adapter surface have moved substantially since this branch.

  2. Drop the Z-Library files from this PR. This PR mixes two unrelated sites (weibo and zlibrary), and current main already has zlibrary/search, zlibrary/info, docs, manifest entries, and tests. Keeping the stale Z-Library implementation here would reintroduce old generic CliError / silent clamp patterns and duplicate already-landed work. If you still want a Z-Library follow-up, please open a separate PR based on latest main.

  3. Rename weibo statuses before merge. statuses is Weibo/API jargon and does not fit the existing command family (user profile, post detail, feed personal timeline, search, comments). Please use weibo user-posts <id> as the clearer user task: list posts for a specific user. Update module path, command name, docs, manifest, function/test names, and PR body accordingly.

  4. Add docs and manifest/index sync for the new Weibo command. Current PR only changes cli-manifest.json; docs/adapters/browser/weibo.md, docs/adapters/index.md, and README.zh-CN.md still do not mention the command.

  5. Add contract tests for the Weibo command. At minimum cover: bad --limit / --page fail before fetch, screen-name-to-uid resolution, API error envelope -> typed failure, empty/malformed payload behavior, and row shape including id/mblogid/url round-trip into weibo post <mblogid>.

  6. Replace silent argument coercion/clamping with upfront typed validation. Math.min(kwargs.limit || 15, 50) and kwargs.page || 1 silently accept 0, negative values, floats, and non-useful values. They should throw ArgumentError before browser/API work. This project has been removing silent clamps.

  7. Tighten typed error boundaries. Non-2xx / API envelope errors should become CommandExecutionError; auth/login failures should become AuthRequiredError where distinguishable; true no-result should not silently return []. Avoid raw browser/evaluate errors leaking as untyped exceptions.

After the rebase + scope cleanup, I can re-review the Weibo-only diff in detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants