Skip to content

feat(bilibili): add --top to fetch pinned comments#2106

Open
henrycjchen wants to merge 1 commit into
jackwener:mainfrom
henrycjchen:feat/bilibili-top-comments
Open

feat(bilibili): add --top to fetch pinned comments#2106
henrycjchen wants to merge 1 commit into
jackwener:mainfrom
henrycjchen:feat/bilibili-top-comments

Conversation

@henrycjchen

Copy link
Copy Markdown
Contributor

What

Adds a --top flag to bilibili comments that returns only the video's pinned (置顶) comments.

The comments command already calls /x/v2/reply/main, whose response carries top_replies (the pinned comments) alongside regular replies — but that field was discarded. This surfaces it, no new API needed.

opencli bilibili comments BV1dd7r6oEpf --top

Behavior

  • --top reads data.top_replies, reusing the existing formatReplyRow (same shape as regular replies).
  • --top is mutually exclusive with --parent — 楼中楼 threads (/x/v2/reply/reply) have no top_replies; passing both raises ArgumentError before any request.
  • requireReplies generalized to accept a key; an absent top_replies is treated as empty, and an empty pinned list raises EmptyResultError.

Tests

TDD, added to comments.test.js:

  • --top returns top_replies
  • --top + --parentArgumentError (no request made)
  • --top with no pinned comment → EmptyResultError

All 90 bilibili tests pass; typecheck clean; cli-manifest.json rebuilt; docs updated.

Live verification

Ran against BV1dd7r6oEpf — returned the pinned comment from 陈鲁豫-慢谈 (870 likes, with the episode timeline).

🤖 Generated with Claude Code

The comments command already fetches /x/v2/reply/main, whose response
includes top_replies (置顶评论) alongside regular replies but discarded
them. Add a --top flag that returns only the pinned comments.

- --top reads data.top_replies (reusing formatReplyRow)
- --top is mutually exclusive with --parent (楼中楼 threads have no
  top_replies) and raises ArgumentError before any request
- generalize requireReplies to accept a key; absent top_replies is
  treated as empty, and an empty pinned list raises EmptyResultError

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant