fix(route/nhentai): fix detail route image src extraction and bypass Cloudflare with Puppeteer#22140
Open
FlanChanXwO wants to merge 8 commits into
Open
fix(route/nhentai): fix detail route image src extraction and bypass Cloudflare with Puppeteer#22140FlanChanXwO wants to merge 8 commits into
FlanChanXwO wants to merge 8 commits into
Conversation
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the nhentai routes to rely on a browser automation flow for login/torrent fetching (likely to handle Cloudflare), and updates route metadata accordingly.
Changes:
- Replace cookie acquisition and torrent download logic with a Puppeteer-driven approach (plus cookie refresh on expiry).
- Make nhentai routes declare Puppeteer as required and add a new maintainer.
- Improve image URL extraction robustness and adjust date parsing defaulting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| lib/routes/nhentai/util.tsx | Switches cookie + torrent retrieval to browser automation, refines image extraction/date parsing |
| lib/routes/nhentai/search.ts | Declares Puppeteer requirement and updates maintainers |
| lib/routes/nhentai/index.ts | Declares Puppeteer requirement and updates maintainers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+27
to
36
| const { page, destroy } = await getPuppeteerPage(loginUrl, { | ||
| onBeforeLoad: async (page) => { | ||
| const allowedTypes = new Set(['document', 'script', 'xhr', 'fetch', 'stylesheet']); | ||
| await page.setRequestInterception(true); | ||
| page.on('request', (request) => { | ||
| allowedTypes.has(request.resourceType()) ? request.continue() : request.abort(); | ||
| }); | ||
| }, | ||
| followRedirect: false, | ||
| gotoConfig: { waitUntil: 'domcontentloaded' }, | ||
| }); |
Comment on lines
+291
to
+297
| .map((ele) => { | ||
| const img = $(ele); | ||
| const src = img.attr('data-src') || img.attr('src'); | ||
| return src ? new URL(src, baseUrl).href : null; | ||
| }) | ||
| .filter((src) => src !== null) | ||
| .map((src) => src.replace(/(.+)(\d+)t\.(.+)/, (_, p1, p2, p3) => `${p1}${p2}.${p3}`)) |
| ...simple, | ||
| title: $('div#info > h2').text() || $('div#info > h1').text(), | ||
| pubDate: parseDate($('time').attr('datetime')), | ||
| pubDate: parseDate($('time').attr('datetime') || ''), |
Comment on lines
+39
to
+53
| await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
|
|
||
| let currentUrl = page.url(); | ||
| let title = await page.title(); | ||
|
|
||
| let attempts = 0; | ||
| // eslint-disable-next-line no-await-in-loop | ||
| while ((title.includes('Just a moment') || currentUrl.includes('challenges.cloudflare')) && attempts < 10) { | ||
| // eslint-disable-next-line no-await-in-loop | ||
| await new Promise((resolve) => setTimeout(resolve, 3000)); | ||
| currentUrl = page.url(); | ||
| // eslint-disable-next-line no-await-in-loop | ||
| title = await page.title(); | ||
| attempts++; | ||
| } |
Comment on lines
+14
to
16
| requirePuppeteer: true, | ||
| antiCrawler: true, | ||
| supportBT: true, |
Comment on lines
+18
to
20
| requirePuppeteer: true, | ||
| antiCrawler: true, | ||
| supportBT: true, |
Contributor
|
Successfully generated as following: http://localhost:1200/nhentai/search/language:chinese+blue+archive/detail - Failed ❌http://localhost:1200/nhentai/index/parody/blue archive/detail - Success ✔️<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>nhentai - parody - blue archive</title>
<link>https://nhentai.net/parody/blue-archive/</link>
<atom:link href="http://localhost:1200/nhentai/index/parody/blue%20archive/detail" rel="self" type="application/rss+xml"></atom:link>
<description>hentai - Powered by RSSHub</description>
<generator>RSSHub</generator>
<webMaster>contact@rsshub.app (RSSHub)</webMaster>
<language>en</language>
<lastBuildDate>Sun, 31 May 2026 14:28:29 GMT</lastBuildDate>
<ttl>5</ttl>
<item>
<title></title>
<description><h1>0 pages</h1><br></description>
<link>https://nhentai.net/g/653594/</link>
<guid isPermaLink="false">https://nhentai.net/g/653594/</guid>
<pubDate>Invalid Date</pubDate>
</item>
<item>
<title></title>
<description><h1>0 pages</h1><br></description>
<link>https://nhentai.net/g/653510/</link>
<guid isPermaLink="false">https://nhentai.net/g/653510/</guid>
<pubDate>Invalid Date</pubDate>
</item>
<item>
<title></title>
<description><h1>0 pages</h1><br></description>
<link>https://nhentai.net/g/653493/</link>
<guid isPermaLink="false">https://nhentai.net/g/653493/</guid>
<pubDate>Invalid Date</pubDate>
</item>
<item>
<title></title>
<description><h1>0 pages</h1><br></description>
<link>https://nhentai.net/g/653482/</link>
<guid isPermaLink="false">https://nhentai.net/g/653482/</guid>
<pubDate>Invalid Date</pubDate>
</item>
<item>
<title></title>
<description><h1>0 pages</h1><br></description>
<link>https://nhentai.net/g/653455/</link>
<guid isPermaLink="false">https://nhentai.net/g/653455/</guid>
<pubDate>Invalid Date</pubDate>
</item>
</channel>
</rss> |
Contributor
Auto ReviewNo clear rule violations found in the current diff. |
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.
Involved Issue / 该 PR 相关 Issue
Close # None
Example for the Proposed Route(s) / 路由地址示例
New RSS Route Checklist / 新 RSS 路由检查表
PuppeteerNote / 说明
This PR focuses on fixing the detail mode for existing /nhentai routes.