feat(weibo): add statuses command to fetch user timeline#1256
Conversation
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
left a comment
There was a problem hiding this comment.
Thanks for the PR. I reviewed the current head (40f1ae47) against current main; this needs changes before content review can continue.
Required changes:
-
Rebase onto latest
mainand resolve conflicts. GitHub currently reportsCONFLICTING/DIRTY, mainly becausecli-manifest.jsonand adapter surface have moved substantially since this branch. -
Drop the Z-Library files from this PR. This PR mixes two unrelated sites (
weiboandzlibrary), and currentmainalready haszlibrary/search,zlibrary/info, docs, manifest entries, and tests. Keeping the stale Z-Library implementation here would reintroduce old genericCliError/ silent clamp patterns and duplicate already-landed work. If you still want a Z-Library follow-up, please open a separate PR based on latestmain. -
Rename
weibo statusesbefore merge.statusesis Weibo/API jargon and does not fit the existing command family (userprofile,postdetail,feedpersonal timeline,search,comments). Please useweibo 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. -
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, andREADME.zh-CN.mdstill do not mention the command. -
Add contract tests for the Weibo command. At minimum cover: bad
--limit/--pagefail before fetch, screen-name-to-uid resolution, API error envelope -> typed failure, empty/malformed payload behavior, and row shape includingid/mblogid/urlround-trip intoweibo post <mblogid>. -
Replace silent argument coercion/clamping with upfront typed validation.
Math.min(kwargs.limit || 15, 50)andkwargs.page || 1silently accept0, negative values, floats, and non-useful values. They should throwArgumentErrorbefore browser/API work. This project has been removing silent clamps. -
Tighten typed error boundaries. Non-2xx / API envelope errors should become
CommandExecutionError; auth/login failures should becomeAuthRequiredErrorwhere 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.
Summary
Adds
opencli weibo statuses <id>command to fetch a specific user's Weibo timeline.Currently opencli supports:
weibo user <id>— user profileweibo post <id>— single post detailweibo feed— personal for-you / following timelineBut there is no way to list a specific user's statuses. This PR fills that gap.
What Changed
clis/weibo/statuses.js/ajax/statuses/mymblog?uid=<uid>&page=<page>&feature=0API (discovered via browser network capture)id,mblogid,text,isLongText,created_at,reposts,comments,likes,pic_num,url, plusretweetedandpage_infowhen availableUsage
Test Plan
opencli validatepassesNotes
textis capped at 500 chars in list view; useweibo post <mblogid>for full long-text expansion