Skip to content

fix(bilibili): use actual user UID instead of 0 for favorite command#333

Merged
jackwener merged 1 commit intojackwener:mainfrom
zhanghui67:fix/bilibili-favorite-uid
Mar 24, 2026
Merged

fix(bilibili): use actual user UID instead of 0 for favorite command#333
jackwener merged 1 commit intojackwener:mainfrom
zhanghui67:fix/bilibili-favorite-uid

Conversation

@zhanghui67
Copy link
Contributor

Summary

  • Fix bilibili favorite command returning empty results
  • Changed up_mid: 0 to use the actual logged-in user's UID via getSelfUid()

Problem

The opencli bilibili favorite command was always returning empty results because the API call used up_mid: 0 which doesn't return any favorite folders.

Solution

Import and use getSelfUid() to fetch the current user's UID before querying the favorite folders API.

Test

Before fix:

$ opencli bilibili favorite
(no data)

After fix:

$ opencli bilibili favorite --limit 5
  bilibili/favorite
┌──────┬──────────────────────────────────────┬─────────────────┬─────────┐
│ Rank │ Title                                │ Author          │ Plays   │
├──────┼──────────────────────────────────────┼─────────────────┼─────────┤
│ 1    │ 神经网络通用近似定理详解              │ 数理分享        │ 9535    │
│ 2    │ DGX Spark vs Mac Studio              │ 至顶AI实验室    │ 30285   │
│ ...  │ ...                                  │ ...             │ ...     │
└──────┴──────────────────────────────────────┴─────────────────┴─────────┘

The favorite command was using up_mid: 0 which returns empty results. Now it correctly fetches the current user UID using getSelfUid().
Copy link
Owner

@jackwener jackwener left a comment

Choose a reason for hiding this comment

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

Review summary:

Priority Issue File Action
P1 Missing regression coverage for the UID-dependent folder lookup src/clis/bilibili/favorite.ts Fixed by adding src/clis/bilibili/favorite.test.ts

The functional fix is correct: bilibili favorite should query /x/v3/fav/folder/created/list-all with the logged-in user's real UID, not 0.

I pushed a small follow-up commit to lock this behavior with a targeted unit test. Validation on the updated branch:

  • npx vitest run src/clis/bilibili/favorite.test.ts src/clis/bilibili/dynamic.test.ts
  • npm run typecheck
  • npm test
  • npm run build

Approve.

@jackwener jackwener merged commit 9f2aa3b into jackwener:main Mar 24, 2026
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