Skip to content

feat: add WeRead adapter with 7 commands#89

Merged
jackwener merged 1 commit intojackwener:mainfrom
Astro-Han:worktree-weread-adapter
Mar 19, 2026
Merged

feat: add WeRead adapter with 7 commands#89
jackwener merged 1 commit intojackwener:mainfrom
Astro-Han:worktree-weread-adapter

Conversation

@Astro-Han
Copy link
Contributor

Summary

Closes #82. Adds a WeRead (微信读书) adapter with 7 commands covering search, rankings, book details, bookshelf, and note export.

Public commands (no login required, Node.js fetch):

  • weread search <keyword> — search books
  • weread ranking [category] — book rankings (all / rising / category ID)

Private commands (cookie auth via browser):

  • weread book <bookId> — book details
  • weread shelf — personal bookshelf
  • weread notebooks — list books with highlights/notes
  • weread highlights <bookId> — underlines in a book
  • weread notes <bookId> — personal notes/thoughts on a book

Architecture

  • Shared helper src/clis/weread/utils.ts with two fetch modes:
    • fetchWebApi — Node.js direct fetch for public endpoints (weread.qq.com/web/*)
    • fetchWithPage — browser page.evaluate for private endpoints (i.weread.qq.com/*)
  • Each command file is a thin 20-30 line wrapper using cli() registration
  • Follows existing patterns from bilibili (browser fetch) and xiaoyuzhou (public fetch + utils in subdirectory)

Verified API endpoints

Endpoint Status
weread.qq.com/web/search/global ✅ Returns JSON
weread.qq.com/web/bookListInCategory/{cat} ✅ Returns JSON
i.weread.qq.com/* Requires cookie auth (errcode -2010 without)

Note: Community docs claim book/info and bestbookmarks are public, but our testing confirmed they require cookies.

Test plan

  • Unit tests for formatDate, fetchWebApi, fetchWithPage (15 tests)
  • E2E tests for weread search and weread ranking in public-commands.test.ts
  • Typecheck passes
  • Build passes (201 manifest entries)
  • Manual smoke test: weread search python, weread ranking all
  • Private commands need manual testing with a logged-in Chrome session
  • shelf.progress, book.rating, notebooks.noteCount field mappings are from community docs and marked with TODO for runtime verification

Add weread adapter for issue jackwener#82, covering search, rankings, book details,
bookshelf, notebooks, highlights, and notes.

Public commands (no login required):
- weread search <keyword> — search books
- weread ranking [category] — book rankings (all/rising/category ID)

Private commands (cookie auth via browser):
- weread book <bookId> — book details
- weread shelf — personal bookshelf
- weread notebooks — books with highlights/notes
- weread highlights <bookId> — underlines in a book
- weread notes <bookId> — personal notes on a book

Closes jackwener#82
@jackwener jackwener merged commit edb21ca into jackwener:main Mar 19, 2026
9 checks passed
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.

[Feature]: 有没有考虑增加微信读书的cli

2 participants