feat(pixiv): add Pixiv adapter #403
Merged
jackwener merged 13 commits intojackwener:mainfrom Mar 25, 2026
Merged
Conversation
Add support for Pixiv (pixiv.net) with the following commands: - ranking: daily/weekly/monthly illustration rankings - search: search illustrations by keyword/tag - user: view artist profile info - illusts: list illustrations by artist - detail: view illustration details (tags, stats) - download: download original-quality images All commands use COOKIE strategy to reuse Chrome's logged-in session. YAML adapters for simple API fetches (ranking, detail, user), TypeScript for complex logic (search, illusts, download with Referer header). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- search.test.ts: auth error, result parsing, limit, empty results (4 tests) - illusts.test.ts: auth error, empty user, two-step fetch, limit (4 tests) - download.test.ts: auth error, no images, Referer header, partial failure (4 tests) - Add pixiv to vitest adapter project include list - Add 5 pixiv commands to E2E browser-auth graceful failure tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ranking: use /ranking.php?format=json (not /ajax/ranking which 404s) - ranking: fix JSON path from data.body.contents to data.contents - user/detail: rename hyphenated args (user-id → uid, illust-id → id) to fix YAML template evaluation (dot access doesn't support hyphens) All 6 commands verified working against live Pixiv API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…uate Address CodeRabbit review: all user inputs (query, userId, illustId, idsParam) passed to page.evaluate are now serialized via JSON.stringify instead of direct string interpolation, preventing code injection in browser context. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- ranking.yaml: add | json filter to page/limit args for defense-in-depth - user.yaml: guard illusts/manga/novels with typeof check for robustness - Extract shared createPageMock to test-utils.ts, deduplicate across 3 test files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test-utils.ts: slim down to minimal mock (goto, evaluate, getCookies) with overrides support, matching upstream's pragmatic mock style - Add missing download command to E2E browser-auth graceful failure tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- detail.yaml: add url to columns to match description mentioning "URLs" - All adapters: differentiate HTTP errors — 401/403 → AuthRequiredError, 404 → "not found", others → generic "request failed (HTTP N)" - Tests: use beforeAll to cache registry lookup, avoiding repeated reads from global singleton - Tests: assert error type (AuthRequiredError) not just message content - Tests: add dedicated test cases for non-auth errors (500) and 404 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add pixiv.md documentation page under docs/adapters/browser/ - Update docs/adapters/index.md with pixiv entry - Add Pixiv to sidebar in docs/.vitepress/config.mts - Update README.md and README.zh-CN.md adapter tables - Add pixiv to download support tables in both READMEs Completes the documentation checklist for the pixiv adapter PR. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use CommandExecutionError instead of raw Error for HTTP failures - Add page.goto() before page.evaluate() to establish browser context - Fix search keyword double-encoding in URL construction - Fix ranking.yaml using rating_count instead of illust_bookmark_count - Throw on batch detail fetch failure instead of silent empty return - Add beforeEach mock reset in download tests - Add novels column to user.yaml output Ensures pixiv adapter follows upstream CliError conventions and handles edge cases correctly before submitting to upstream. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace technical Referer header detail with user-facing description - Describe what users care about: original quality and multi-page support Technical details belong in code comments, not user-facing docs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ranking mode examples including R18 variants - Add search filter examples (mode, order, pagination) - Organize examples by command category for readability Users need to know available options without reading source code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Validate illust-id is numeric to prevent path traversal - Move URL parsing inside per-item try block for graceful error handling - Add auth error handling for batch detail request (consistent with step 1) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…on & batch support - Create utils.ts with pixivFetch() for unified navigate + fetch + error handling - Refactor search.ts, illusts.ts, download.ts to use pixivFetch (DRY) - Add user-id/illust-id numeric validation in TS adapters - Add batch pagination in illusts.ts for limit > 48 (Pixiv server limit) - Add comment explaining Pixiv search API dual keyword requirement - Update tests: new invalid-ID test cases, aligned mock format with pixivFetch
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.
Description
Add Pixiv (pixiv.net) adapter with 6 commands for browsing rankings, searching illustrations, viewing artist profiles, listing works, viewing details, and downloading original-quality images.
All commands use the COOKIE strategy, reusing Chrome's logged-in Pixiv session via Browser Bridge. YAML adapters handle simple API fetches (ranking, detail, user), while TypeScript adapters handle complex logic (search with pagination, illusts with two-step fetch, download with Referer header).
Type of Change
Checklist
Documentation (if adding/modifying an adapter)
docs/adapters/(if new adapter)docs/adapters/index.mdtable (if new adapter)docs/.vitepress/config.mts(if new adapter)README.md/README.zh-CN.mdwhen command discoverability changedCliErrorsubclasses instead of rawErrorCommands
pixiv rankingpixiv search <query>pixiv user <uid>pixiv illusts <user-id>pixiv detail <id>pixiv download <illust-id>Screenshots / Output
Verification
Technical Notes
/ranking.php?format=json(not/ajax/rankingwhich returns 404)i.pximg.net) requiresReferer: https://www.pixiv.net/— handled viahttpDownloaddirectly rather thandownloadMediato pass custom headerspage.evaluateare serialized viaJSON.stringifyto prevent code injectiontest-utils.tswith minimal page mock factory to reduce duplication across test filesSummary by CodeRabbit
Release Notes
New Features
Documentation
Tests