feat(bilibili): add --top to fetch pinned comments#2106
Open
henrycjchen wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
--topflag tobilibili commentsthat returns only the video's pinned (置顶) comments.The
commentscommand already calls/x/v2/reply/main, whose response carriestop_replies(the pinned comments) alongside regularreplies— but that field was discarded. This surfaces it, no new API needed.Behavior
--topreadsdata.top_replies, reusing the existingformatReplyRow(same shape as regular replies).--topis mutually exclusive with--parent— 楼中楼 threads (/x/v2/reply/reply) have notop_replies; passing both raisesArgumentErrorbefore any request.requireRepliesgeneralized to accept a key; an absenttop_repliesis treated as empty, and an empty pinned list raisesEmptyResultError.Tests
TDD, added to
comments.test.js:--topreturnstop_replies--top+--parent→ArgumentError(no request made)--topwith no pinned comment →EmptyResultErrorAll 90 bilibili tests pass; typecheck clean;
cli-manifest.jsonrebuilt; docs updated.Live verification
Ran against
BV1dd7r6oEpf— returned the pinned comment from 陈鲁豫-慢谈 (870 likes, with the episode timeline).🤖 Generated with Claude Code