Conversation
|
| const authors = (ld.author || []) | ||
| .map(a => (a.name || '').trim()) |
There was a problem hiding this comment.
Fixed in 855c6e0. The JSON-LD author value is now normalized before names are read: an array, a single Person object, a plain string, or a missing/null value all work. I tested each shape (plus a mixed array) with synthetic JSON-LD, and a live novel still parses its authors.
| const first = await getApi<ChapterContentData>(base); | ||
| const pages = [first]; | ||
| for (let p = 2; p <= first.pageMetas.length; p++) { | ||
| pages.push(await getApi<ChapterContentData>(base + '?weightPage=' + p)); |
There was a problem hiding this comment.
Later chapter pages go unchecked
The routine plugin check reads one sample chapter but does not check a fixed two-page response. A later change to pageMetas or weightPage could drop the rest of a long chapter while that check still passes. Add a test that verifies text from both pages.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Not adding a test here: this repo has no unit-test harness for plugins, and building one is out of scope for this PR. I checked the two-page path against the live site instead: book/shadow-slave-r2k2ivbd6ez4/gpp58s44jc is split over two weight pages (50 + 53 blocks), and parseChapter returned all 103 paragraphs.
Adds a standalone English plugin for ReChapters.
Closes #2485
What it supports
The site is a Next.js app with a public JSON API, so the plugin uses that API in most places instead of scraping HTML:
/api/search, 20 per page. It pages by building the site's offset cursor. "Latest" sorts by last chapter update. Filters: sort (popularity, latest update, rating, rating count, chapter count, word count) and status (ongoing / completed)./api/search?q=…sorted by relevance, with the same paging.authorfield is accepted as an array, a single object or a string); genres come from the tag list and status from the status pill. The complete chapter list is fetched from/api/book/{id}/chapters/buckets, then each bucket of about 100 chapters is fetched in ascending order, 5 buckets at a time./api/book/…/content(no login needed for these chapters). Long chapters are split into several pages, and all of them are fetched. The text blocks are plain text, and they are HTML-escaped into<p>elements, so the output can't contain markup,on*attributes orjavascript:URLs.The site has wallet and purchase endpoints. Every chapter I sampled across about 25 popular novels was free (
accessLevel: 0,isVip: false), so the plugin has no special handling for paid chapters.How it was tested
npm run check:plugin -- plugins/english/rechapters.ts: all four checks PASS (popular: 20 novels, search: 20 results, parseNovel: 1432 chapters, parseChapter: 10255 chars).[];authoris an array, a single object, a string, a mixed array, or missing/null.eslintandprettier --checkpass on the new file, andnpm run build:compilesucceeds. Repo-widenpm run lintstill reports errors, but they are in files this PR doesn't change (plugins/arabic/rewayatfans.ts,plugins/english/wetriedtls.ts).This PR was written by an AI agent (Claude Code), and no human has reviewed it yet.