Add question, answers, answer, article, user, search commands#1
Open
tamnd wants to merge 3 commits into
Open
Conversation
Six gated commands behind --cookie/ZHIHU_COOKIE, reading Zhihu v4 API endpoints for question detail, answer lists, single answers, column articles, user profiles, and search. Also upgrades kit to v0.4.0, refactors the library into api/wire/ids/ops files, and rewrites all docs.
- HotItem now carries excerpt and followers (follower_count)
- Question carries excerpt, author_token, and a topics list ([]string)
- Answer carries excerpt; URL falls back to /answer/{id} when question ID is absent
- Article carries excerpt
- User carries thanked and avatar_url
- SearchResult carries author, author_token, and votes
- Wire converters updated to populate the new fields
- include params updated to request the new fields from the v4 API
- Fix double URL-encoding in suggest (ops.go passed QueryEscape output to
api.go which encoded again; now plain string passes through)
- Rewrite guides/adding-a-command.md and guides/resource-uris.md with real
Zhihu content instead of generic scaffold copy
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.
Summary
--cookie/ZHIHU_COOKIE:question,answers,answer,article,user,searchany-cli/kitfrom v0.2.0 to v0.4.0api.go,wire.go,ids.go,ops.gofiles--cookieflag +ZHIHU_COOKIEenv →kit.Config.Extra["cookie"]→Config.Cookie→Cookie+Authorization: BearerheadersTest plan
go test ./...passes (all 25 tests green)go build ./...passes (CGO_ENABLED=0)zhihu hotfetches live data without cookiezhihu suggest 人工智能returns suggestionszhihu question <id>with cookie returns question fieldszhihu question <id>without cookie exits 4zhihu answers <id>with cookie returns listzhihu answer <id>with cookie returns single answerzhihu article <id>with cookie returns articlezhihu user <token>with cookie returns profilezhihu search <query>with cookie returns results