@cloud411716/fancy-webnovel 0.1.47 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -176,28 +176,29 @@ function spawnScraper(platform, length, outDir) {
176
176
  return new Promise(async (resolve) => {
177
177
  const { spawn } = await import('child_process');
178
178
  const args = scraperArgs(platform, length, outDir);
179
- // 先尝试 9222 端口(Chrome CDP),没有 Chrome 则尝试 9223
180
179
  const ports = ['9222', '9223'];
181
180
  let portIdx = 0;
182
181
 
183
182
  function tryPort(port) {
184
183
  const scraperScript = join(dirname(fileURLToPath(import.meta.url)), 'scrapers', args.script);
185
184
  const fullArgs = ['--port', port, ...args.extra];
185
+ // stderr 透传到父进程 stderr,用户实时看到进度
186
186
  const p = spawn('node', [scraperScript, ...fullArgs], {
187
187
  timeout: 120000,
188
- stdio: ['ignore', 'pipe', 'pipe'],
188
+ stdio: ['ignore', 'pipe', 'inherit'],
189
189
  });
190
- let out = '', err = '';
190
+ let out = '';
191
191
  p.stdout.on('data', d => { out += d.toString(); });
192
- p.stderr.on('data', d => { err += d.toString(); });
193
192
  p.on('close', (code) => {
194
193
  if (code === 0 && out.trim()) {
195
- resolve({ ok: true, output: out, stderr: err });
194
+ resolve({ ok: true, output: out, stderr: '' });
196
195
  } else if (portIdx < ports.length - 1) {
197
196
  portIdx++;
198
197
  tryPort(ports[portIdx]);
199
198
  } else {
200
- resolve({ ok: false, output: out, error: err || `exit ${code}` });
199
+ // 截取 stderr 末尾 300 字符,避免过长
200
+ const errTail = out.trimEnd().slice(-300);
201
+ resolve({ ok: false, output: out, error: errTail || `exit ${code}` });
201
202
  }
202
203
  });
203
204
  p.on('error', (e) => {
@@ -88,6 +88,8 @@ function buildBookListJS() {
88
88
  }
89
89
  return list.map(function(b){return {
90
90
  bookId:String(b.bookId||b.book_id||''),
91
+ title:b.bookName||b.book_name||b.title||b.name||'',
92
+ author:b.authorName||b.author_name||b.author||'',
91
93
  read_count:b.read_count||b.readCount||b.read||'',
92
94
  wordNumber:b.wordNumber||b.word_number||b.wordCount||'',
93
95
  creationStatus:(b.creationStatus!=null?b.creationStatus:(b.creation_status!=null?b.creation_status:b.status)),
@@ -314,39 +316,31 @@ function scrapeChannel(ch, type) {
314
316
  }
315
317
  if (books.length > TOP) books = books.slice(0, TOP);
316
318
 
317
- // 分批解码真实书名/作者/简介/题材/评分/标签
318
- const bookIds = books.map((b) => String(b.bookId));
319
- const details = fetchDetails(PORT, bookIds);
319
+ // 直接用列表页数据,跳过详情页(字体反爬导致详情页不可靠)
320
+ // const bookIds = books.map((b) => String(b.bookId));
321
+ // const details = fetchDetails(PORT, bookIds);
320
322
 
321
323
  bodyLines.push(`## ${cat.name} — ${books.length} 本`, "");
322
324
 
323
325
  for (let i = 0; i < books.length; i++) {
324
326
  const b = books[i];
325
- const info = details[String(b.bookId)] || {};
327
+ // const info = details[String(b.bookId)] || {};
326
328
  totalBooks++;
327
- const resolved = !!info.title;
329
+ const resolved = !!b.title;
328
330
  if (resolved) resolvedTitles++;
329
331
 
330
- const title = info.title || "(标题待解析)";
331
- const author = info.author || "未知";
332
- const category = info.category || b.category || "";
332
+ const title = b.title || "(标题待解析)";
333
+ const author = b.author || "未知";
334
+ const category = b.category || "";
333
335
  const catSeg = category ? ` · ${category}` : "";
334
336
 
335
337
  bodyLines.push(`### #${i + 1} ${title}`);
336
338
  bodyLines.push(
337
339
  `*${author}${catSeg} · ${fmtStatus(b.creationStatus)} · ${fmtReads(b.read_count)} 在读 · ${fmtWords(b.wordNumber)}字*`
338
340
  );
339
- if (info.tags) bodyLines.push(`**标签:** ${info.tags}`);
340
341
  bodyLines.push(`**最新更新:** ${b.lastChapterTitle || "未知"}`);
341
342
  bodyLines.push(`**bookId:** ${b.bookId}`);
342
343
  bodyLines.push(`[作品页](https://fanqienovel.com/page/${b.bookId})`);
343
- const desc = cleanDesc(info.desc);
344
- if (desc) {
345
- bodyLines.push("");
346
- bodyLines.push("**简介**");
347
- bodyLines.push("");
348
- bodyLines.push(desc);
349
- }
350
344
  bodyLines.push("");
351
345
  }
352
346