@acanthis-dec/linovelib 1.1.2 → 1.2.0
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/README.md +4 -1
- package/README.zh-CN.md +4 -1
- package/assets/THIRD-PARTY-NOTICES.md +18 -0
- package/assets/captcha_cropped.onnx +0 -0
- package/dist/index.d.mts +5 -13
- package/dist/index.mjs +358 -149
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -17
package/README.md
CHANGED
|
@@ -50,7 +50,10 @@ const client = new LinovelibClient(
|
|
|
50
50
|
|
|
51
51
|
const results = await client.searchNovels("keyword");
|
|
52
52
|
const novel = await client.getNovelInfo("example-id");
|
|
53
|
-
const chapterHtml = await client.getChapter(
|
|
53
|
+
const chapterHtml = await client.getChapter(
|
|
54
|
+
"example-novel-id",
|
|
55
|
+
"example-chapter-id",
|
|
56
|
+
);
|
|
54
57
|
```
|
|
55
58
|
|
|
56
59
|
## API
|
package/README.zh-CN.md
CHANGED
|
@@ -50,7 +50,10 @@ const client = new LinovelibClient(
|
|
|
50
50
|
|
|
51
51
|
const results = await client.searchNovels("keyword");
|
|
52
52
|
const novel = await client.getNovelInfo("example-id");
|
|
53
|
-
const chapterHtml = await client.getChapter(
|
|
53
|
+
const chapterHtml = await client.getChapter(
|
|
54
|
+
"example-novel-id",
|
|
55
|
+
"example-chapter-id",
|
|
56
|
+
);
|
|
54
57
|
```
|
|
55
58
|
|
|
56
59
|
## API
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 第三方声明
|
|
2
|
+
|
|
3
|
+
`assets/captcha_cropped.onnx` 是 [ddddocr](https://github.com/sml2h3/ddddocr)
|
|
4
|
+
`common_old.onnx` 的**裁剪版本**(仅把输出层 `(1024, 8210)` 裁到 `(1024, 63)`,
|
|
5
|
+
其余权重与结构未改动),直接取自 npm 包
|
|
6
|
+
[`captcha-ocr-model`](https://www.npmjs.com/package/captcha-ocr-model),
|
|
7
|
+
以 MIT 许可再分发。
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
The MIT License (MIT)
|
|
11
|
+
Copyright © 2022 <copyright holders>
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
```
|
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { BinaryResponse,
|
|
1
|
+
import { BinaryResponse, BrowserProfileName, FlareSolverrOptions } from "@acanthis-dec/browser-fetch";
|
|
2
2
|
import { Novel, NovelSearchResult } from "@acanthis-dec/core";
|
|
3
3
|
import { StorageService } from "@acanthis-dec/storage";
|
|
4
4
|
import { Logger } from "winston";
|
|
5
|
-
|
|
6
|
-
//#region src/novel.d.ts
|
|
7
5
|
interface NovelUpdateInfo {
|
|
8
6
|
coverUrl: string;
|
|
9
7
|
chapterCount: number;
|
|
10
8
|
}
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/client.d.ts
|
|
13
9
|
type SessionOptions = {
|
|
14
10
|
enabled: false;
|
|
15
11
|
} | {
|
|
@@ -36,12 +32,12 @@ type LinovelibClientOptions = {
|
|
|
36
32
|
cookies: CookieStoreOptions;
|
|
37
33
|
proxy?: string | undefined;
|
|
38
34
|
};
|
|
39
|
-
declare class LinovelibClient {
|
|
35
|
+
export declare class LinovelibClient {
|
|
40
36
|
private storage?;
|
|
41
37
|
private fetchClient;
|
|
42
38
|
private novelChapterQueue;
|
|
43
39
|
private novelInfoQueue;
|
|
44
|
-
private
|
|
40
|
+
private searchSession;
|
|
45
41
|
private options?;
|
|
46
42
|
private logger?;
|
|
47
43
|
private isSessionValid?;
|
|
@@ -60,9 +56,5 @@ declare class LinovelibClient {
|
|
|
60
56
|
getCover(url: string, referer?: string): Promise<BinaryResponse>;
|
|
61
57
|
getChapter(novelId: string, chapterId: string): Promise<string | undefined>;
|
|
62
58
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
declare function novelIdToCoverUrl(novelId: string): string;
|
|
66
|
-
//#endregion
|
|
67
|
-
export { LinovelibClient, type LinovelibClientOptions, type SessionOptions, novelIdToCoverUrl };
|
|
68
|
-
//# sourceMappingURL=index.d.mts.map
|
|
59
|
+
export declare function novelIdToCoverUrl(novelId: string): string;
|
|
60
|
+
export type { LinovelibClientOptions, SessionOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BrowserFetchClient, CloudflareBlockError, defaultRetryPolicy } from "@acanthis-dec/browser-fetch";
|
|
2
2
|
import { deepmerge } from "deepmerge-ts";
|
|
3
|
-
import z
|
|
4
|
-
import { buildDescrambleMapping
|
|
3
|
+
import z, { z as z$1 } from "zod";
|
|
4
|
+
import { buildDescrambleMapping } from "@acanthis-dec/core";
|
|
5
5
|
import * as cheerio from "cheerio";
|
|
6
6
|
import { load } from "cheerio";
|
|
7
7
|
import { deobfuscate } from "@acanthis-dec/deobfuscator";
|
|
@@ -10,20 +10,27 @@ import traverseModule from "@babel/traverse";
|
|
|
10
10
|
import * as t from "@babel/types";
|
|
11
11
|
import PQueue from "p-queue";
|
|
12
12
|
import { Mutex } from "async-mutex";
|
|
13
|
-
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import { readFile } from "node:fs/promises";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { decode } from "fast-png";
|
|
18
|
+
// src/coefficients.ts
|
|
14
19
|
const traverse = traverseModule.default ?? traverseModule;
|
|
15
|
-
const descrambleCoefficientsSchema = z.object({
|
|
16
|
-
modulus: z.number().int(),
|
|
17
|
-
increment: z.number().int(),
|
|
18
|
-
multiplier: z.number().int(),
|
|
19
|
-
seedOffset: z.number().int(),
|
|
20
|
-
seedMultiplier: z.number().int()
|
|
20
|
+
const descrambleCoefficientsSchema = z$1.object({
|
|
21
|
+
modulus: z$1.number().int(),
|
|
22
|
+
increment: z$1.number().int(),
|
|
23
|
+
multiplier: z$1.number().int(),
|
|
24
|
+
seedOffset: z$1.number().int(),
|
|
25
|
+
seedMultiplier: z$1.number().int()
|
|
21
26
|
});
|
|
22
27
|
function getObfuscatedPart(fullCode) {
|
|
23
28
|
return fullCode.split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "").slice(-2).join("\n");
|
|
24
29
|
}
|
|
25
30
|
async function extractCoefficients(script) {
|
|
26
|
-
const
|
|
31
|
+
const obfuscatedPart = getObfuscatedPart(script);
|
|
32
|
+
const deObfCode = await deobfuscate(obfuscatedPart);
|
|
33
|
+
const ast = parse(deObfCode, {
|
|
27
34
|
sourceType: "module",
|
|
28
35
|
plugins: ["jsx"]
|
|
29
36
|
});
|
|
@@ -73,8 +80,7 @@ async function getCoefficientsFromPage(html, fetchClient, cachedVersion) {
|
|
|
73
80
|
version
|
|
74
81
|
};
|
|
75
82
|
}
|
|
76
|
-
|
|
77
|
-
//#region src/utils.ts
|
|
83
|
+
// src/utils.ts
|
|
78
84
|
function extractNovelIdFromUrl(url) {
|
|
79
85
|
const match = url.match(/\/novel\/(\d+)\.html/);
|
|
80
86
|
return match ? match[1] : void 0;
|
|
@@ -188,8 +194,7 @@ function transformContent(content) {
|
|
|
188
194
|
};
|
|
189
195
|
return content.replace(/./g, (char) => contentTransDict[char] || char);
|
|
190
196
|
}
|
|
191
|
-
|
|
192
|
-
//#region src/chapter.ts
|
|
197
|
+
// src/chapter.ts
|
|
193
198
|
function extractChapterId($) {
|
|
194
199
|
const scriptTags = $("script");
|
|
195
200
|
let chapterId = "";
|
|
@@ -247,7 +252,8 @@ async function decrypt(html, fetchClient, cachedJsVersion, cachedCoefficients) {
|
|
|
247
252
|
const mapping = buildDescrambleMapping(sortableEntries.length, seed, coefficients, 20);
|
|
248
253
|
const restoredChildren = [...allChildren];
|
|
249
254
|
sortableEntries.forEach((entry, i) => {
|
|
250
|
-
const
|
|
255
|
+
const targetIndex = mapping[i] ?? i;
|
|
256
|
+
const actualSlot = sortableEntries[targetIndex]?.originalPos ?? 0;
|
|
251
257
|
restoredChildren[actualSlot] = entry.element;
|
|
252
258
|
});
|
|
253
259
|
const newContainer = $("<div></div>");
|
|
@@ -287,8 +293,7 @@ async function getChapter(id, novelId, chapterQueue, fetchClient, cachedJsVersio
|
|
|
287
293
|
};
|
|
288
294
|
return content;
|
|
289
295
|
}
|
|
290
|
-
|
|
291
|
-
//#region src/novel.ts
|
|
296
|
+
// src/novel.ts
|
|
292
297
|
function extractVolumesArray(catalog) {
|
|
293
298
|
const $ = cheerio.load(catalog);
|
|
294
299
|
const results = [];
|
|
@@ -419,8 +424,7 @@ async function getUpdateInfo(id, fetchClient, retry) {
|
|
|
419
424
|
chapterCount
|
|
420
425
|
};
|
|
421
426
|
}
|
|
422
|
-
|
|
423
|
-
//#region src/cover.ts
|
|
427
|
+
// src/cover.ts
|
|
424
428
|
function novelIdToCoverUrl(novelId) {
|
|
425
429
|
return `https://www.linovelib.com/files/article/image/${novelId.length > 3 ? novelId[0] : "0"}/${novelId}/${novelId}s.jpg`;
|
|
426
430
|
}
|
|
@@ -434,8 +438,7 @@ async function getVolumeCoverUrl(id, novelId, fetchClient) {
|
|
|
434
438
|
if (!volume) throw new Error(`Volume not found for ID: ${id}`);
|
|
435
439
|
return $(volume).find("a.volume-cover img").attr("data-original") || "";
|
|
436
440
|
}
|
|
437
|
-
|
|
438
|
-
//#region src/queue.ts
|
|
441
|
+
// src/queue.ts
|
|
439
442
|
/**
|
|
440
443
|
* Simple backoff strategy for request rate limiting
|
|
441
444
|
* - Normal delay: 500-1000ms random
|
|
@@ -464,10 +467,10 @@ var NovelChapterQueue = class {
|
|
|
464
467
|
this.client = client;
|
|
465
468
|
this.backoff = new SimpleBackoff();
|
|
466
469
|
this.logger = logger;
|
|
467
|
-
this.queue.
|
|
470
|
+
this.queue.addEventListener("add", () => {
|
|
468
471
|
this.logger?.debug(`[NovelChapterQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`);
|
|
469
472
|
});
|
|
470
|
-
this.queue.
|
|
473
|
+
this.queue.addEventListener("next", () => {
|
|
471
474
|
this.logger?.debug(`[NovelChapterQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `);
|
|
472
475
|
});
|
|
473
476
|
}
|
|
@@ -525,10 +528,10 @@ var NovelInfoQueue = class {
|
|
|
525
528
|
this.backoff = new SimpleBackoff();
|
|
526
529
|
this.chapterQueue = chapterQueue;
|
|
527
530
|
this.logger = logger;
|
|
528
|
-
this.queue.
|
|
531
|
+
this.queue.addEventListener("add", () => {
|
|
529
532
|
this.logger?.debug(`[NovelInfoQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`);
|
|
530
533
|
});
|
|
531
|
-
this.queue.
|
|
534
|
+
this.queue.addEventListener("next", () => {
|
|
532
535
|
this.logger?.debug(`[NovelInfoQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `);
|
|
533
536
|
});
|
|
534
537
|
}
|
|
@@ -602,8 +605,7 @@ var NovelInfoQueue = class {
|
|
|
602
605
|
});
|
|
603
606
|
}
|
|
604
607
|
};
|
|
605
|
-
|
|
606
|
-
//#region src/search/common.ts
|
|
608
|
+
// src/search/common.ts
|
|
607
609
|
function parseSearchHtml($) {
|
|
608
610
|
const results = [];
|
|
609
611
|
$("div.search-html-box div.search-result-list").each((_, el) => {
|
|
@@ -628,139 +630,348 @@ function parseBookHtml($) {
|
|
|
628
630
|
coverUrl: $("div.book-img img").attr("src") || ""
|
|
629
631
|
};
|
|
630
632
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
633
|
+
// src/search/captcha.ts
|
|
634
|
+
const MODEL_FILENAME = "captcha_cropped.onnx";
|
|
635
|
+
const TARGET_HEIGHT = 64;
|
|
636
|
+
const CHARSET = ["", ..."0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"];
|
|
637
|
+
let sessionPromise;
|
|
638
|
+
function moduleDirectory() {
|
|
639
|
+
return fileURLToPath(new URL(".", import.meta.url));
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* 模型可能出现的几个位置:
|
|
643
|
+
* - 环境变量显式指定(部署时最可靠)
|
|
644
|
+
* - 与当前模块同级(api-server 打包后把模型拷到 dist 目录)
|
|
645
|
+
* - 包内 dist/../assets(npm 发布形态 / linovelib tsdown 产物)
|
|
646
|
+
* - 包内 src/search/../../assets(workspace 内直接执行 TS 源码)
|
|
647
|
+
* - 进程工作目录(Docker 镜像内 /app/captcha_cropped.onnx)
|
|
648
|
+
*/
|
|
649
|
+
function resolveModelPath() {
|
|
650
|
+
const candidates = [
|
|
651
|
+
process.env.LINOVELIB_CAPTCHA_MODEL_PATH,
|
|
652
|
+
join(moduleDirectory(), MODEL_FILENAME),
|
|
653
|
+
join(moduleDirectory(), "..", "assets", MODEL_FILENAME),
|
|
654
|
+
join(moduleDirectory(), "..", "..", "assets", MODEL_FILENAME),
|
|
655
|
+
join(process.cwd(), MODEL_FILENAME)
|
|
656
|
+
].filter((candidate) => Boolean(candidate));
|
|
657
|
+
for (const candidate of candidates) if (existsSync(candidate)) return candidate;
|
|
658
|
+
throw new Error(`无法找到搜索验证码识别模型 ${MODEL_FILENAME},尝试过的路径: ${candidates.join(", ")}`);
|
|
659
|
+
}
|
|
660
|
+
async function getSession() {
|
|
661
|
+
if (!sessionPromise) {
|
|
662
|
+
sessionPromise = (async () => {
|
|
663
|
+
const ort = await import("onnxruntime-node");
|
|
664
|
+
ort.env.logLevel = "error";
|
|
665
|
+
const model = await readFile(resolveModelPath());
|
|
666
|
+
return await ort.InferenceSession.create(model, {
|
|
667
|
+
executionProviders: ["cpu"],
|
|
668
|
+
graphOptimizationLevel: "all",
|
|
669
|
+
intraOpNumThreads: 1,
|
|
670
|
+
interOpNumThreads: 1
|
|
671
|
+
});
|
|
672
|
+
})();
|
|
673
|
+
sessionPromise.catch(() => {
|
|
674
|
+
sessionPromise = void 0;
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
return sessionPromise;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* 验证码字符使用高饱和度颜色绘制在浅色噪点背景上。
|
|
681
|
+
* 直接转灰度会让部分颜色的字符与背景对比度不足,因此同时尝试多种通道变换,
|
|
682
|
+
* 让模型对同一张图投票,可以明显降低误识别率。
|
|
683
|
+
*/
|
|
684
|
+
function channelVariants(image) {
|
|
685
|
+
const { width, height, channels, data } = image;
|
|
686
|
+
const total = width * height;
|
|
687
|
+
const saturation = new Uint8Array(total);
|
|
688
|
+
const maxChannel = new Uint8Array(total);
|
|
689
|
+
const minChannel = new Uint8Array(total);
|
|
690
|
+
for (let i = 0; i < total; i++) {
|
|
691
|
+
const offset = i * channels;
|
|
692
|
+
const r = data[offset] ?? 0;
|
|
693
|
+
const g = data[offset + 1] ?? r;
|
|
694
|
+
const b = data[offset + 2] ?? g;
|
|
695
|
+
const max = Math.max(r, g, b);
|
|
696
|
+
const min = Math.min(r, g, b);
|
|
697
|
+
saturation[i] = max - min;
|
|
698
|
+
maxChannel[i] = max;
|
|
699
|
+
minChannel[i] = min;
|
|
700
|
+
}
|
|
701
|
+
return [
|
|
702
|
+
saturation,
|
|
703
|
+
maxChannel,
|
|
704
|
+
minChannel
|
|
705
|
+
];
|
|
706
|
+
}
|
|
707
|
+
function resizeBilinear(source, sourceWidth, sourceHeight, targetWidth, targetHeight) {
|
|
708
|
+
const output = new Uint8Array(targetWidth * targetHeight);
|
|
709
|
+
const scaleX = sourceWidth / targetWidth;
|
|
710
|
+
const scaleY = sourceHeight / targetHeight;
|
|
711
|
+
for (let y = 0; y < targetHeight; y++) {
|
|
712
|
+
const sourceY = Math.min(sourceHeight - 1, Math.max(0, (y + .5) * scaleY - .5));
|
|
713
|
+
const y0 = Math.floor(sourceY);
|
|
714
|
+
const y1 = Math.min(sourceHeight - 1, y0 + 1);
|
|
715
|
+
const weightY = sourceY - y0;
|
|
716
|
+
for (let x = 0; x < targetWidth; x++) {
|
|
717
|
+
const sourceX = Math.min(sourceWidth - 1, Math.max(0, (x + .5) * scaleX - .5));
|
|
718
|
+
const x0 = Math.floor(sourceX);
|
|
719
|
+
const x1 = Math.min(sourceWidth - 1, x0 + 1);
|
|
720
|
+
const weightX = sourceX - x0;
|
|
721
|
+
const topLeft = source[y0 * sourceWidth + x0] ?? 0;
|
|
722
|
+
const topRight = source[y0 * sourceWidth + x1] ?? topLeft;
|
|
723
|
+
const bottomLeft = source[y1 * sourceWidth + x0] ?? topLeft;
|
|
724
|
+
const bottomRight = source[y1 * sourceWidth + x1] ?? bottomLeft;
|
|
725
|
+
const top = topLeft + (topRight - topLeft) * weightX;
|
|
726
|
+
const bottom = bottomLeft + (bottomRight - bottomLeft) * weightX;
|
|
727
|
+
output[y * targetWidth + x] = Math.round(top + (bottom - top) * weightY);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return output;
|
|
731
|
+
}
|
|
732
|
+
function decodeCtcOutput(data, dims) {
|
|
733
|
+
const steps = dims[0] ?? 0;
|
|
734
|
+
const classes = dims[dims.length - 1] ?? 0;
|
|
735
|
+
let text = "";
|
|
736
|
+
let previous = -1;
|
|
737
|
+
let confidenceSum = 0;
|
|
738
|
+
for (let step = 0; step < steps; step++) {
|
|
739
|
+
const offset = step * classes;
|
|
740
|
+
let bestIndex = 0;
|
|
741
|
+
let bestValue = Number.NEGATIVE_INFINITY;
|
|
742
|
+
for (let index = 0; index < classes; index++) {
|
|
743
|
+
const value = data[offset + index] ?? Number.NEGATIVE_INFINITY;
|
|
744
|
+
if (value > bestValue) {
|
|
745
|
+
bestValue = value;
|
|
746
|
+
bestIndex = index;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
let expSum = 0;
|
|
750
|
+
for (let index = 0; index < classes; index++) expSum += Math.exp((data[offset + index] ?? 0) - bestValue);
|
|
751
|
+
confidenceSum += expSum > 0 ? 1 / expSum : 0;
|
|
752
|
+
if (bestIndex !== previous && bestIndex !== 0) text += CHARSET[bestIndex] ?? "";
|
|
753
|
+
previous = bestIndex;
|
|
754
|
+
}
|
|
755
|
+
return {
|
|
756
|
+
text,
|
|
757
|
+
confidence: steps > 0 ? confidenceSum / steps : 0
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
function chooseBest(decoded) {
|
|
761
|
+
const fourCharacter = decoded.filter((item) => item.text.length === 4);
|
|
762
|
+
if (fourCharacter.length === 0) return decoded.reduce((best, item) => item.confidence > best.confidence ? item : best);
|
|
763
|
+
const votes = /* @__PURE__ */ new Map();
|
|
764
|
+
for (const item of fourCharacter) {
|
|
765
|
+
const current = votes.get(item.text);
|
|
766
|
+
if (current) {
|
|
767
|
+
current.count += 1;
|
|
768
|
+
current.confidence = Math.max(current.confidence, item.confidence);
|
|
769
|
+
} else votes.set(item.text, {
|
|
770
|
+
count: 1,
|
|
771
|
+
confidence: item.confidence
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
let winner = fourCharacter[0];
|
|
775
|
+
let winnerCount = -1;
|
|
776
|
+
let winnerConfidence = -1;
|
|
777
|
+
for (const [text, vote] of votes) if (vote.count > winnerCount || vote.count === winnerCount && vote.confidence > winnerConfidence) {
|
|
778
|
+
winner = {
|
|
779
|
+
text,
|
|
780
|
+
confidence: vote.confidence
|
|
781
|
+
};
|
|
782
|
+
winnerCount = vote.count;
|
|
783
|
+
winnerConfidence = vote.confidence;
|
|
784
|
+
}
|
|
785
|
+
return winner;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* 识别 linovelib 搜索验证码(4 位数字/字母图片)。
|
|
789
|
+
* 使用 ddddocr 的 common_old 裁剪模型(MIT),见 assets/THIRD-PARTY-NOTICES.md。
|
|
790
|
+
*/
|
|
791
|
+
async function solveCaptcha(image) {
|
|
792
|
+
const decoded = decode(image);
|
|
793
|
+
const targetWidth = Math.round(decoded.width * TARGET_HEIGHT / decoded.height);
|
|
794
|
+
const ort = await import("onnxruntime-node");
|
|
795
|
+
const session = await getSession();
|
|
796
|
+
const inputName = session.inputNames[0];
|
|
797
|
+
const outputName = session.outputNames[0];
|
|
798
|
+
if (!inputName || !outputName) throw new Error("验证码识别模型缺少输入或输出节点");
|
|
799
|
+
const decodedTexts = [];
|
|
800
|
+
for (const variant of channelVariants(decoded)) {
|
|
801
|
+
const resized = resizeBilinear(variant, decoded.width, decoded.height, targetWidth, TARGET_HEIGHT);
|
|
802
|
+
const input = new Float32Array(resized.length);
|
|
803
|
+
for (let i = 0; i < resized.length; i++) input[i] = (resized[i] ?? 0) / 255;
|
|
804
|
+
const output = (await session.run({ [inputName]: new ort.Tensor("float32", input, [
|
|
805
|
+
1,
|
|
806
|
+
1,
|
|
807
|
+
TARGET_HEIGHT,
|
|
808
|
+
targetWidth
|
|
809
|
+
]) }))[outputName];
|
|
810
|
+
if (!output) throw new Error("验证码识别模型没有返回结果");
|
|
811
|
+
decodedTexts.push(decodeCtcOutput(output.data, output.dims));
|
|
812
|
+
}
|
|
813
|
+
if (decodedTexts.length === 0) throw new Error("验证码识别失败:没有任何可用结果");
|
|
814
|
+
return chooseBest(decodedTexts).text;
|
|
815
|
+
}
|
|
816
|
+
// src/search/v3.ts
|
|
817
|
+
const SEARCH_URL = "https://www.linovelib.com/S6/";
|
|
818
|
+
const ORIGIN = "https://www.linovelib.com";
|
|
819
|
+
/** 站点要求两次搜索 POST 之间至少间隔 5 秒,这里留一点余量。 */
|
|
820
|
+
const MIN_SEARCH_INTERVAL_MS = 5200;
|
|
821
|
+
const MAX_VERIFICATION_ATTEMPTS = 3;
|
|
822
|
+
const MAX_RATE_LIMIT_ATTEMPTS = 3;
|
|
823
|
+
const NEXT_PAGE_DELAY_MIN_MS = 300;
|
|
824
|
+
const searchRequestHeaders = {
|
|
825
|
+
origin: ORIGIN,
|
|
826
|
+
referer: `${ORIGIN}/`
|
|
827
|
+
};
|
|
828
|
+
const searchRefererHeaders = {
|
|
829
|
+
origin: ORIGIN,
|
|
830
|
+
referer: SEARCH_URL
|
|
831
|
+
};
|
|
832
|
+
function sleep(ms) {
|
|
833
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
834
|
+
}
|
|
835
|
+
function isVerificationPage(html) {
|
|
836
|
+
return html.includes("name=\"search_challenge\"") || html.includes("<title>搜索验证</title>");
|
|
837
|
+
}
|
|
838
|
+
function isRateLimitedPage(html) {
|
|
839
|
+
return html.includes("两次搜索的间隔时间不得少于");
|
|
663
840
|
}
|
|
664
|
-
|
|
841
|
+
function isBookPage(html) {
|
|
842
|
+
return html.includes("book-html-box");
|
|
843
|
+
}
|
|
844
|
+
/** 搜索验证流程无法自动完成时抛出,便于上层区分站点验证码问题。 */
|
|
845
|
+
var SearchVerificationError = class extends Error {
|
|
846
|
+
constructor(message) {
|
|
847
|
+
super(message);
|
|
848
|
+
this.name = "SearchVerificationError";
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
var SearchRateLimitError = class extends Error {
|
|
665
852
|
constructor(message) {
|
|
666
853
|
super(message);
|
|
667
|
-
this.name = "
|
|
854
|
+
this.name = "SearchRateLimitError";
|
|
668
855
|
}
|
|
669
856
|
};
|
|
670
|
-
|
|
857
|
+
/**
|
|
858
|
+
* 新版搜索会话。
|
|
859
|
+
*
|
|
860
|
+
* 站点现状(2026-11):
|
|
861
|
+
* - 未验证客户端 POST/GET 搜索页会返回「搜索验证」图片验证码页;
|
|
862
|
+
* - 提交正确验证码后服务端会下发约 30 分钟有效的验证 cookie,期间搜索免验证;
|
|
863
|
+
* - 两次搜索间隔不得少于 5 秒,否则返回错误页;
|
|
864
|
+
* - 验证过期后任意搜索/翻页请求都会重新出现验证码页。
|
|
865
|
+
*
|
|
866
|
+
* 该类负责串行化搜索请求、维护最小搜索间隔、自动识别并提交验证码,并复用验证态。
|
|
867
|
+
*/
|
|
868
|
+
var SearchSession = class {
|
|
671
869
|
fetchClient;
|
|
672
870
|
mutex = new Mutex();
|
|
673
|
-
|
|
674
|
-
domain = "www.linovelib.com";
|
|
675
|
-
prefetching = false;
|
|
871
|
+
lastSearchAt = 0;
|
|
676
872
|
constructor(fetchClient) {
|
|
677
873
|
this.fetchClient = fetchClient;
|
|
678
874
|
}
|
|
679
|
-
async
|
|
680
|
-
return
|
|
875
|
+
async search(keyword) {
|
|
876
|
+
return await this.mutex.runExclusive(async () => {
|
|
877
|
+
const html = await this.requestSearch(keyword);
|
|
878
|
+
return await this.parseResults(html);
|
|
879
|
+
});
|
|
681
880
|
}
|
|
682
|
-
async
|
|
683
|
-
|
|
881
|
+
async parseResults(html) {
|
|
882
|
+
const $ = load(html);
|
|
883
|
+
if (isBookPage(html) && $("div.book-html-box").length > 0) return [parseBookHtml($)];
|
|
884
|
+
const results = parseSearchHtml($);
|
|
885
|
+
const totalPages = Number($("em#pagestats").text().match(/1\/(\d+)/)?.[1] ?? "1");
|
|
886
|
+
const nextHref = $("a.next").attr("href");
|
|
887
|
+
if (totalPages > 1 && nextHref) results.push(...await this.collectNextPages(nextHref));
|
|
888
|
+
return results;
|
|
684
889
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
890
|
+
async collectNextPages(startHref) {
|
|
891
|
+
const results = [];
|
|
892
|
+
let href = startHref;
|
|
893
|
+
while (href) {
|
|
894
|
+
await sleep(NEXT_PAGE_DELAY_MIN_MS + Math.random() * 500);
|
|
895
|
+
const html = await this.fetchPage(new URL(href, SEARCH_URL).toString());
|
|
896
|
+
const $ = load(html);
|
|
897
|
+
results.push(...parseSearchHtml($));
|
|
898
|
+
href = $("a.next").attr("href") || void 0;
|
|
899
|
+
}
|
|
900
|
+
return results;
|
|
901
|
+
}
|
|
902
|
+
async fetchPage(url) {
|
|
903
|
+
let response = await this.fetchClient.text(url, { headers: searchRefererHeaders });
|
|
904
|
+
if (response.mimeType !== "text/html") throw new Error(`Unexpected response type: ${response.mimeType}`);
|
|
905
|
+
if (isVerificationPage(response.data)) {
|
|
906
|
+
await this.verifySearch(response.data);
|
|
907
|
+
response = await this.fetchClient.text(url, { headers: searchRefererHeaders });
|
|
908
|
+
if (response.mimeType !== "text/html") throw new Error(`Unexpected response type: ${response.mimeType}`);
|
|
909
|
+
if (isVerificationPage(response.data)) throw new SearchVerificationError("搜索验证后翻页仍被要求验证");
|
|
910
|
+
}
|
|
911
|
+
if (response.data === "") throw new Error("Empty response body when fetching search page");
|
|
912
|
+
return response.data;
|
|
913
|
+
}
|
|
914
|
+
async requestSearch(keyword) {
|
|
915
|
+
for (let attempt = 0; attempt < MAX_RATE_LIMIT_ATTEMPTS; attempt++) {
|
|
916
|
+
await this.waitForSearchSlot();
|
|
917
|
+
const response = await this.fetchClient.text(SEARCH_URL, {
|
|
918
|
+
method: "POST",
|
|
919
|
+
body: new URLSearchParams({ searchkey: keyword }),
|
|
920
|
+
headers: searchRequestHeaders
|
|
921
|
+
});
|
|
922
|
+
this.lastSearchAt = Date.now();
|
|
923
|
+
if (response.mimeType !== "text/html") throw new Error(`Unexpected response type: ${response.mimeType}`);
|
|
924
|
+
if (response.data === "") throw new Error("Empty response body when fetching search results");
|
|
925
|
+
if (isRateLimitedPage(response.data)) continue;
|
|
926
|
+
if (isVerificationPage(response.data)) return await this.verifySearch(response.data);
|
|
927
|
+
return response.data;
|
|
928
|
+
}
|
|
929
|
+
throw new SearchRateLimitError(`搜索请求被站点限流,已重试 ${MAX_RATE_LIMIT_ATTEMPTS} 次`);
|
|
930
|
+
}
|
|
931
|
+
async verifySearch(verificationHtml) {
|
|
932
|
+
let currentHtml = verificationHtml;
|
|
933
|
+
for (let attempt = 0; attempt < MAX_VERIFICATION_ATTEMPTS; attempt++) {
|
|
934
|
+
const $ = load(currentHtml);
|
|
935
|
+
const challenge = $("input[name=search_challenge]").attr("value");
|
|
936
|
+
const searchkey = $("input[name=searchkey]").attr("value");
|
|
937
|
+
const searchtype = $("input[name=searchtype]").attr("value") ?? "all";
|
|
938
|
+
const imageSrc = $("#search-captcha").attr("src");
|
|
939
|
+
if (!challenge || !imageSrc || !searchkey) throw new SearchVerificationError("无法解析搜索验证码页面");
|
|
940
|
+
const image = await this.fetchClient.binary(new URL(imageSrc, SEARCH_URL).toString(), { headers: searchRefererHeaders });
|
|
941
|
+
if (!image.mimeType.startsWith("image/")) throw new SearchVerificationError(`验证码图片响应类型异常: ${image.mimeType}`);
|
|
942
|
+
let code;
|
|
943
|
+
try {
|
|
944
|
+
code = await solveCaptcha(image.data);
|
|
696
945
|
} catch (error) {
|
|
697
|
-
|
|
698
|
-
await refreshSearchTicket(this.fetchClient);
|
|
699
|
-
continue;
|
|
700
|
-
}
|
|
701
|
-
await this.consumeTicket();
|
|
702
|
-
throw error;
|
|
946
|
+
throw new SearchVerificationError(`验证码识别失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
703
947
|
}
|
|
704
|
-
|
|
948
|
+
await this.waitForSearchSlot();
|
|
949
|
+
const response = await this.fetchClient.text(SEARCH_URL, {
|
|
950
|
+
method: "POST",
|
|
951
|
+
body: new URLSearchParams({
|
|
952
|
+
searchkey,
|
|
953
|
+
searchtype,
|
|
954
|
+
search_challenge: challenge,
|
|
955
|
+
search_code: code
|
|
956
|
+
}),
|
|
957
|
+
headers: searchRefererHeaders
|
|
958
|
+
});
|
|
959
|
+
this.lastSearchAt = Date.now();
|
|
960
|
+
if (response.mimeType !== "text/html") throw new Error(`Unexpected response type: ${response.mimeType}`);
|
|
961
|
+
if (!isVerificationPage(response.data)) return response.data;
|
|
962
|
+
currentHtml = response.data;
|
|
963
|
+
}
|
|
964
|
+
throw new SearchVerificationError(`搜索验证码连续识别失败(已尝试 ${MAX_VERIFICATION_ATTEMPTS} 次)`);
|
|
705
965
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
* 这样不会拖慢刚刚那次请求的 return。
|
|
710
|
-
*/
|
|
711
|
-
schedulePrefetch() {
|
|
712
|
-
if (this.prefetching) return;
|
|
713
|
-
this.prefetching = true;
|
|
714
|
-
this.mutex.runExclusive(async () => {
|
|
715
|
-
if (await this.hasValidTicket()) return;
|
|
716
|
-
await refreshSearchTicket(this.fetchClient);
|
|
717
|
-
}).catch((err) => {
|
|
718
|
-
console.error("[SearchTicketManager] prefetch failed:", err);
|
|
719
|
-
}).finally(() => {
|
|
720
|
-
this.prefetching = false;
|
|
721
|
-
});
|
|
966
|
+
async waitForSearchSlot() {
|
|
967
|
+
const elapsed = Date.now() - this.lastSearchAt;
|
|
968
|
+
if (elapsed < MIN_SEARCH_INTERVAL_MS) await sleep(MIN_SEARCH_INTERVAL_MS - elapsed);
|
|
722
969
|
}
|
|
723
970
|
};
|
|
724
|
-
async function
|
|
725
|
-
|
|
726
|
-
const response = await fetchClient.text(`https://www.linovelib.com${path}`, { headers: {
|
|
727
|
-
origin: "https://www.linovelib.com",
|
|
728
|
-
referer: "https://www.linovelib.com/S6/"
|
|
729
|
-
} });
|
|
730
|
-
if (response.mimeType !== "text/html") throw new Error(`Unexpected response type: ${response.mimeType}`);
|
|
731
|
-
if (response.data === "") throw new EmptyBodyError("Empty response body when fetching next page");
|
|
732
|
-
return response.data;
|
|
733
|
-
}));
|
|
734
|
-
const results = [];
|
|
735
|
-
results.push(...parseSearchHtml($));
|
|
736
|
-
if ($("a.next").length > 0) results.push(...await obtainFromNextPage($("a.next").attr("href") || "", fetchClient, ticketManager));
|
|
737
|
-
return results;
|
|
738
|
-
}
|
|
739
|
-
async function searchNovelsV2(keyword, fetchClient, ticketManager) {
|
|
740
|
-
const searchHtml = await ticketManager.runExclusive(async () => {
|
|
741
|
-
const tr = await fetchClient.text("https://www.linovelib.com/S6/", {
|
|
742
|
-
method: "POST",
|
|
743
|
-
body: new URLSearchParams({ searchkey: keyword }),
|
|
744
|
-
headers: {
|
|
745
|
-
origin: "https://www.linovelib.com",
|
|
746
|
-
referer: "https://www.linovelib.com/"
|
|
747
|
-
}
|
|
748
|
-
});
|
|
749
|
-
if (tr?.mimeType !== "text/html") throw new Error(`Unexpected response type: ${tr?.mimeType}`);
|
|
750
|
-
if (tr?.data === "") throw new EmptyBodyError("Empty response body when fetching search results");
|
|
751
|
-
return tr.data;
|
|
752
|
-
});
|
|
753
|
-
const results = [];
|
|
754
|
-
const $ = load(searchHtml);
|
|
755
|
-
if ($("div.book-html-box").length > 0) return [parseBookHtml($)];
|
|
756
|
-
results.push(...parseSearchHtml($));
|
|
757
|
-
const pages = $("em#pagestats").text().match(/1\/(\d+)/)?.[1] || "1";
|
|
758
|
-
if (Number(pages) > 1) results.push(...await obtainFromNextPage($("a.next").attr("href") || "", fetchClient, ticketManager));
|
|
759
|
-
ticketManager.schedulePrefetch();
|
|
760
|
-
return results;
|
|
971
|
+
async function searchNovelsV3(keyword, _fetchClient, session) {
|
|
972
|
+
return await session.search(keyword);
|
|
761
973
|
}
|
|
762
|
-
|
|
763
|
-
//#region src/session.ts
|
|
974
|
+
// src/session.ts
|
|
764
975
|
async function refreshSessionId(fetchClient, loginConfig) {
|
|
765
976
|
await fetchClient.request({
|
|
766
977
|
url: "https://www.linovelib.com/login.php",
|
|
@@ -790,14 +1001,13 @@ async function ensureValidSession(fetchClient, loginConfig) {
|
|
|
790
1001
|
}
|
|
791
1002
|
return true;
|
|
792
1003
|
}
|
|
793
|
-
|
|
794
|
-
//#region src/client.ts
|
|
1004
|
+
// src/client.ts
|
|
795
1005
|
var LinovelibClient = class {
|
|
796
1006
|
storage;
|
|
797
1007
|
fetchClient;
|
|
798
1008
|
novelChapterQueue;
|
|
799
1009
|
novelInfoQueue;
|
|
800
|
-
|
|
1010
|
+
searchSession;
|
|
801
1011
|
options;
|
|
802
1012
|
logger;
|
|
803
1013
|
isSessionValid = void 0;
|
|
@@ -851,7 +1061,7 @@ var LinovelibClient = class {
|
|
|
851
1061
|
this.fetchClient = new BrowserFetchClient(browserFetchOptions);
|
|
852
1062
|
this.novelChapterQueue = new NovelChapterQueue(this.fetchClient, this.logger);
|
|
853
1063
|
this.novelInfoQueue = new NovelInfoQueue(this.fetchClient, this.novelChapterQueue, this.logger);
|
|
854
|
-
this.
|
|
1064
|
+
this.searchSession = new SearchSession(this.fetchClient);
|
|
855
1065
|
}
|
|
856
1066
|
async getNovelInfo(id) {
|
|
857
1067
|
if (this.options?.session.enabled && !this.isSessionValid) this.isSessionValid = await ensureValidSession(this.fetchClient, {
|
|
@@ -872,7 +1082,7 @@ var LinovelibClient = class {
|
|
|
872
1082
|
username: this.options.session.username,
|
|
873
1083
|
password: this.options.session.password
|
|
874
1084
|
});
|
|
875
|
-
return await
|
|
1085
|
+
return await searchNovelsV3(keyword, this.fetchClient, this.searchSession);
|
|
876
1086
|
}
|
|
877
1087
|
async getNovelCover(id) {
|
|
878
1088
|
if (this.options?.session.enabled && !this.isSessionValid) this.isSessionValid = await ensureValidSession(this.fetchClient, {
|
|
@@ -904,7 +1114,7 @@ var LinovelibClient = class {
|
|
|
904
1114
|
username: this.options.session.username,
|
|
905
1115
|
password: this.options.session.password
|
|
906
1116
|
});
|
|
907
|
-
const cachedJsVersion = this.storage ? await this.storage.getCache("chapterlog_js_version", z
|
|
1117
|
+
const cachedJsVersion = this.storage ? await this.storage.getCache("chapterlog_js_version", z.string()) ?? void 0 : void 0;
|
|
908
1118
|
const cachedCoefficients = this.storage ? await this.storage.getCache("coefficients", descrambleCoefficientsSchema) ?? void 0 : void 0;
|
|
909
1119
|
const result = await getChapter(chapterId, novelId, this.novelChapterQueue, this.fetchClient, cachedJsVersion, cachedCoefficients);
|
|
910
1120
|
if (this.storage && result) {
|
|
@@ -914,7 +1124,6 @@ var LinovelibClient = class {
|
|
|
914
1124
|
return result?.content;
|
|
915
1125
|
}
|
|
916
1126
|
};
|
|
917
|
-
//#endregion
|
|
918
1127
|
export { LinovelibClient, novelIdToCoverUrl };
|
|
919
1128
|
|
|
920
1129
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["searchNovels","z"],"sources":["../src/coefficients.ts","../src/utils.ts","../src/chapter.ts","../src/novel.ts","../src/cover.ts","../src/queue.ts","../src/search/common.ts","../src/search/v2.ts","../src/session.ts","../src/client.ts"],"sourcesContent":["import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { DescrambleCoefficients } from \"@acanthis-dec/core\";\nimport { deobfuscate } from \"@acanthis-dec/deobfuscator\";\nimport { parse } from \"@babel/parser\";\nimport traverseModule from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport * as cheerio from \"cheerio\";\nimport { z } from \"zod\";\n\ntype TraverseFunction = typeof traverseModule;\n\nconst traverse =\n\t(traverseModule as unknown as { default?: TraverseFunction }).default ??\n\ttraverseModule;\n\nexport const descrambleCoefficientsSchema = z.object({\n\tmodulus: z.number().int(),\n\tincrement: z.number().int(),\n\tmultiplier: z.number().int(),\n\tseedOffset: z.number().int(),\n\tseedMultiplier: z.number().int(),\n});\n\nfunction getObfuscatedPart(fullCode: string): string {\n\treturn fullCode\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\")\n\t\t.slice(-2)\n\t\t.join(\"\\n\");\n}\n\nexport async function extractCoefficients(\n\tscript: string,\n): Promise<DescrambleCoefficients> {\n\tconst obfuscatedPart = getObfuscatedPart(script);\n\tconst deObfCode = await deobfuscate(obfuscatedPart);\n\tconst ast = parse(deObfCode, { sourceType: \"module\", plugins: [\"jsx\"] });\n\tconst coefficients: Partial<DescrambleCoefficients> = {};\n\ttraverse(ast, {\n\t\tBinaryExpression(path) {\n\t\t\tconst { node } = path;\n\t\t\tif (\n\t\t\t\tnode.operator === \"%\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right) &&\n\t\t\t\tt.isBinaryExpression(node.left.left) &&\n\t\t\t\tnode.left.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.left.right)\n\t\t\t) {\n\t\t\t\tcoefficients.modulus = node.right.value;\n\t\t\t\tconst leftSide = node.left;\n\t\t\t\tif (t.isBinaryExpression(leftSide) && leftSide.operator === \"+\") {\n\t\t\t\t\tif (t.isNumericLiteral(leftSide.right)) {\n\t\t\t\t\t\tcoefficients.increment = leftSide.right.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isBinaryExpression(leftSide.left) &&\n\t\t\t\t\t\tleftSide.left.operator === \"*\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (t.isNumericLiteral(leftSide.left.right)) {\n\t\t\t\t\t\t\tcoefficients.multiplier = leftSide.left.right.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnode.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right)\n\t\t\t) {\n\t\t\t\tconst potentialOffset = node.right.value;\n\t\t\t\tconst potentialMultiplier = node.left.right.value;\n\t\t\t\tconst numberTransformed = node.left.left;\n\t\t\t\tif (\n\t\t\t\t\tt.isCallExpression(numberTransformed) &&\n\t\t\t\t\tt.isIdentifier(numberTransformed.callee) &&\n\t\t\t\t\t(numberTransformed.callee.name === \"Number\" ||\n\t\t\t\t\t\tnumberTransformed.callee.name === \"parseInt\")\n\t\t\t\t) {\n\t\t\t\t\tcoefficients.seedOffset = potentialOffset;\n\t\t\t\t\tcoefficients.seedMultiplier = potentialMultiplier;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\tif (\n\t\tcoefficients.modulus === undefined ||\n\t\tcoefficients.increment === undefined ||\n\t\tcoefficients.multiplier === undefined ||\n\t\tcoefficients.seedOffset === undefined ||\n\t\tcoefficients.seedMultiplier === undefined\n\t) {\n\t\tthrow new Error(\"Failed to extract all coefficients\");\n\t}\n\treturn coefficients as DescrambleCoefficients;\n}\n\nexport function extractChapterLogScriptUrl(html: string): string {\n\tconst $ = cheerio.load(html);\n\tconst chapterLogScriptUrl =\n\t\t$(\n\t\t\t$(\"script\")\n\t\t\t\t.toArray()\n\t\t\t\t.find((el) => {\n\t\t\t\t\tconst scriptContent = $(el).attr(\"src\") || \"\";\n\t\t\t\t\treturn /chapterlog\\.js/.test(scriptContent);\n\t\t\t\t}),\n\t\t).attr(\"src\") || \"\";\n\treturn chapterLogScriptUrl.startsWith(\"http\")\n\t\t? chapterLogScriptUrl\n\t\t: `https://www.linovelib.com${chapterLogScriptUrl}`;\n}\n\nexport interface CoefficientResult {\n\tcoefficients: DescrambleCoefficients;\n\tversion: string;\n}\n\nexport async function getCoefficientsFromPage(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedVersion?: string,\n): Promise<CoefficientResult | undefined> {\n\tconst scriptUrl = extractChapterLogScriptUrl(html);\n\tif (!scriptUrl) {\n\t\tthrow new Error(\"Chapter log script URL not found\");\n\t}\n\tconst version = scriptUrl.match(/chapterlog\\.js\\?(v.*)/)?.[1] || \"\";\n\tif (version === cachedVersion) {\n\t\treturn undefined; // No need to fetch and extract again\n\t}\n\tconst scriptContent = await fetchClient.text(scriptUrl);\n\tif (!scriptContent.mimeType.includes(\"javascript\")) {\n\t\tthrow new Error(\"Fetched content is not JavaScript\");\n\t}\n\tconst coefficients = await extractCoefficients(scriptContent.data);\n\treturn {\n\t\tcoefficients,\n\t\tversion: version,\n\t};\n}\n","export function extractNovelIdFromUrl(url: string): string | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\.html/);\n\treturn match ? match[1] : undefined;\n}\n\nexport interface NovelAndChapterIds {\n\tnovelId: string | undefined;\n\tchapterId: string | undefined;\n}\n\nexport function extractChapterIdFromUrl(\n\turl: string,\n): NovelAndChapterIds | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)\\.html/);\n\tif (match) {\n\t\treturn {\n\t\t\tnovelId: match[1],\n\t\t\tchapterId: match[2],\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function transformChapterName(name: string): string {\n\tconst chapNameTransDict: Record<string, string> = {\n\t\t\"\\u004e\": \"\\u5973\",\n\t};\n\treturn name.replace(/./g, (char) => chapNameTransDict[char] || char);\n}\n\nexport function transformContent(content: string): string {\n\tconst contentTransDict: Record<string, string> = {\n\t\t\"\\u201c\": \"\\u300c\",\n\t\t\"\\u201d\": \"\\u300d\",\n\t\t\"\\u2018\": \"\\u300e\",\n\t\t\"\\u2019\": \"\\u300f\",\n\t\t\"\\ue82c\": \"\\u7684\",\n\t\t\"\\ue852\": \"\\u4e00\",\n\t\t\"\\ue82d\": \"\\u662f\",\n\t\t\"\\ue819\": \"\\u4e86\",\n\t\t\"\\ue856\": \"\\u6211\",\n\t\t\"\\ue857\": \"\\u4e0d\",\n\t\t\"\\ue816\": \"\\u4eba\",\n\t\t\"\\ue83c\": \"\\u5728\",\n\t\t\"\\ue830\": \"\\u4ed6\",\n\t\t\"\\ue82e\": \"\\u6709\",\n\t\t\"\\ue836\": \"\\u8fd9\",\n\t\t\"\\ue859\": \"\\u4e2a\",\n\t\t\"\\ue80a\": \"\\u4e0a\",\n\t\t\"\\ue855\": \"\\u4eec\",\n\t\t\"\\ue842\": \"\\u6765\",\n\t\t\"\\ue858\": \"\\u5230\",\n\t\t\"\\ue80b\": \"\\u65f6\",\n\t\t\"\\ue81f\": \"\\u5927\",\n\t\t\"\\ue84a\": \"\\u5730\",\n\t\t\"\\ue853\": \"\\u4e3a\",\n\t\t\"\\ue81e\": \"\\u5b50\",\n\t\t\"\\ue822\": \"\\u4e2d\",\n\t\t\"\\ue813\": \"\\u4f60\",\n\t\t\"\\ue85b\": \"\\u8bf4\",\n\t\t\"\\ue807\": \"\\u751f\",\n\t\t\"\\ue818\": \"\\u56fd\",\n\t\t\"\\ue810\": \"\\u5e74\",\n\t\t\"\\ue812\": \"\\u7740\",\n\t\t\"\\ue851\": \"\\u5c31\",\n\t\t\"\\ue801\": \"\\u90a3\",\n\t\t\"\\ue80c\": \"\\u548c\",\n\t\t\"\\ue815\": \"\\u8981\",\n\t\t\"\\ue84c\": \"\\u5979\",\n\t\t\"\\ue840\": \"\\u51fa\",\n\t\t\"\\ue848\": \"\\u4e5f\",\n\t\t\"\\ue835\": \"\\u5f97\",\n\t\t\"\\ue800\": \"\\u91cc\",\n\t\t\"\\ue826\": \"\\u540e\",\n\t\t\"\\ue863\": \"\\u81ea\",\n\t\t\"\\ue861\": \"\\u4ee5\",\n\t\t\"\\ue854\": \"\\u4f1a\",\n\t\t\"\\ue827\": \"\\u5bb6\",\n\t\t\"\\ue83b\": \"\\u53ef\",\n\t\t\"\\ue85d\": \"\\u4e0b\",\n\t\t\"\\ue84d\": \"\\u800c\",\n\t\t\"\\ue862\": \"\\u8fc7\",\n\t\t\"\\ue81c\": \"\\u5929\",\n\t\t\"\\ue81d\": \"\\u53bb\",\n\t\t\"\\ue860\": \"\\u80fd\",\n\t\t\"\\ue843\": \"\\u5bf9\",\n\t\t\"\\ue82f\": \"\\u5c0f\",\n\t\t\"\\ue802\": \"\\u591a\",\n\t\t\"\\ue831\": \"\\u7136\",\n\t\t\"\\ue84b\": \"\\u4e8e\",\n\t\t\"\\ue837\": \"\\u5fc3\",\n\t\t\"\\ue829\": \"\\u5b66\",\n\t\t\"\\ue85e\": \"\\u4e48\",\n\t\t\"\\ue83a\": \"\\u4e4b\",\n\t\t\"\\ue832\": \"\\u90fd\",\n\t\t\"\\ue808\": \"\\u597d\",\n\t\t\"\\ue841\": \"\\u770b\",\n\t\t\"\\ue821\": \"\\u8d77\",\n\t\t\"\\ue845\": \"\\u53d1\",\n\t\t\"\\ue803\": \"\\u5f53\",\n\t\t\"\\ue828\": \"\\u6ca1\",\n\t\t\"\\ue81b\": \"\\u6210\",\n\t\t\"\\ue83e\": \"\\u53ea\",\n\t\t\"\\ue820\": \"\\u5982\",\n\t\t\"\\ue84e\": \"\\u4e8b\",\n\t\t\"\\ue85a\": \"\\u628a\",\n\t\t\"\\ue806\": \"\\u8fd8\",\n\t\t\"\\ue83f\": \"\\u7528\",\n\t\t\"\\ue833\": \"\\u7b2c\",\n\t\t\"\\ue811\": \"\\u6837\",\n\t\t\"\\ue804\": \"\\u9053\",\n\t\t\"\\ue814\": \"\\u60f3\",\n\t\t\"\\ue80f\": \"\\u4f5c\",\n\t\t\"\\ue84f\": \"\\u79cd\",\n\t\t\"\\ue80e\": \"\\u5f00\",\n\t\t\"\\ue823\": \"\\u7f8e\",\n\t\t\"\\ue849\": \"\\u4e73\",\n\t\t\"\\ue805\": \"\\u9634\",\n\t\t\"\\ue809\": \"\\u6db2\",\n\t\t\"\\ue81a\": \"\\u830e\",\n\t\t\"\\ue844\": \"\\u6b32\",\n\t\t\"\\ue847\": \"\\u547b\",\n\t\t\"\\ue850\": \"\\u8089\",\n\t\t\"\\ue824\": \"\\u4ea4\",\n\t\t\"\\ue85f\": \"\\u6027\",\n\t\t\"\\ue817\": \"\\u80f8\",\n\t\t\"\\ue85c\": \"\\u79c1\",\n\t\t\"\\ue838\": \"\\u7a74\",\n\t\t\"\\ue82a\": \"\\u6deb\",\n\t\t\"\\ue83d\": \"\\u81c0\",\n\t\t\"\\ue82b\": \"\\u8214\",\n\t\t\"\\ue80d\": \"\\u5c04\",\n\t\t\"\\ue839\": \"\\u8131\",\n\t\t\"\\ue834\": \"\\u88f8\",\n\t\t\"\\ue846\": \"\\u9a9a\",\n\t\t\"\\ue825\": \"\\u5507\",\n\t};\n\treturn content.replace(/./g, (char) => contentTransDict[char] || char);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport {\n\tbuildDescrambleMapping,\n\ttype DescrambleCoefficients,\n} from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { AnyNode, Element } from \"domhandler\";\nimport { getCoefficientsFromPage } from \"./coefficients\";\nimport type { NovelChapterQueue } from \"./queue\";\nimport { transformContent } from \"./utils\";\n\nfunction extractChapterId($: cheerio.CheerioAPI): string {\n\tconst scriptTags = $(\"script\");\n\tlet chapterId = \"\";\n\tscriptTags.each((_, el) => {\n\t\tconst scriptContent = $(el).html();\n\t\tif (scriptContent) {\n\t\t\tconst match = scriptContent.match(/chapterid\\s*:\\s*'(\\d+)'/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tchapterId = match[1];\n\t\t\t\treturn false; // Break the loop\n\t\t\t}\n\t\t}\n\t});\n\treturn chapterId;\n}\n\nexport interface DecryptResult {\n\tcontent: string;\n\tversion: string;\n\tcoefficients: DescrambleCoefficients;\n}\n\nasync function decrypt(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult> {\n\tconst $ = cheerio.load(html);\n\tconst coefficientResult = await getCoefficientsFromPage(\n\t\thtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t);\n\tconst version = coefficientResult?.version || cachedJsVersion;\n\tconst coefficients = coefficientResult?.coefficients || cachedCoefficients;\n\tif (!version) {\n\t\tthrow new Error(\"Failed to determine chapterlog.js version\");\n\t}\n\tif (!coefficients) {\n\t\tthrow new Error(\"Failed to obtain descrambling coefficients\");\n\t}\n\tconst chapterId = extractChapterId($);\n\tconst container = $(\"#TextContent, #acontent\");\n\tif (!container.length) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tversion,\n\t\t\tcoefficients: coefficients,\n\t\t};\n\t}\n\n\tcontainer.find(\"p\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst innerHtml = $el.html();\n\t\tif (innerHtml) {\n\t\t\tconst cleanedHtml = innerHtml.replace(/^\\s+|(?<=>)\\s+/g, \"\");\n\t\t\t$el.html(cleanedHtml);\n\t\t}\n\t});\n\n\tcontainer.find(\"img.imagecontent\").each((_, el) => {\n\t\tconst imgSrc = $(el).attr(\"data-src\") || $(el).attr(\"src\");\n\t\tif (imgSrc) {\n\t\t\t$(el).attr(\"src\", imgSrc).removeAttr(\"data-src\");\n\t\t}\n\t});\n\n\tcontainer.find(\"div.dag\").remove();\n\tcontainer.find(\"script\").remove();\n\n\tconst allChildren = container\n\t\t.contents()\n\t\t.toArray()\n\t\t.filter((node) => !(node.type === \"tag\" && node.tagName === \"div\"));\n\tconst sortableEntries: { element: Element; originalPos: number }[] = [];\n\tallChildren.forEach((node, index) => {\n\t\tif (node.type === \"tag\" && node.tagName === \"p\") {\n\t\t\tconst text = $(node).text().trim();\n\t\t\tif (text.length > 0) {\n\t\t\t\tsortableEntries.push({ element: node, originalPos: index });\n\t\t\t}\n\t\t}\n\t});\n\n\tconst seed =\n\t\tparseInt(chapterId, 10) * coefficients?.seedMultiplier +\n\t\tcoefficients?.seedOffset;\n\n\tconst mapping = buildDescrambleMapping(\n\t\tsortableEntries.length,\n\t\tseed,\n\t\tcoefficients,\n\t\t20,\n\t);\n\n\tconst restoredChildren: (AnyNode | null)[] = [...allChildren];\n\n\tsortableEntries.forEach((entry, i) => {\n\t\tconst targetIndex = mapping[i] ?? i;\n\t\tconst actualSlot = sortableEntries[targetIndex]?.originalPos ?? 0;\n\t\trestoredChildren[actualSlot] = entry.element;\n\t});\n\n\tconst newContainer = $(\"<div></div>\");\n\trestoredChildren.forEach((node) => {\n\t\tif (node && node.type === \"tag\") {\n\t\t\tnewContainer.append(node);\n\t\t\tnewContainer.append(\"\\n\");\n\t\t}\n\t});\n\n\treturn {\n\t\tcontent: newContainer.html() || \"\",\n\t\tversion,\n\t\tcoefficients: coefficients,\n\t};\n}\n\nexport async function getChapter(\n\tid: string,\n\tnovelId: string,\n\tchapterQueue: NovelChapterQueue,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult | undefined> {\n\tconst firstPageHtml = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com/novel/${novelId}/${id}.html`,\n\t);\n\tlet $ = cheerio.load(firstPageHtml);\n\tconst chapterName = $(\"h1\").text().trim();\n\tlet nextPageId =\n\t\t$(\"div.mlfy_page a:last\")\n\t\t\t.attr(\"href\")\n\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\tfirstPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html'/)?.[2] ||\n\t\t\"\";\n\tlet content = await decrypt(\n\t\tfirstPageHtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t\tcachedCoefficients,\n\t);\n\tcachedCoefficients = content.coefficients;\n\tcachedJsVersion = content.version;\n\twhile (nextPageId?.includes(id)) {\n\t\tconst nextPageHtml = await chapterQueue.fetchChapterPart(\n\t\t\t`https://www.linovelib.com/novel/${novelId}/${nextPageId}.html`,\n\t\t);\n\t\tconst nextContent = await decrypt(\n\t\t\tnextPageHtml,\n\t\t\tfetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tcontent = {\n\t\t\t...content,\n\t\t\tcontent: content.content + nextContent.content,\n\t\t};\n\t\t$ = cheerio.load(nextPageHtml);\n\t\tnextPageId =\n\t\t\t$(\"div.mlfy_page a:last\")\n\t\t\t\t.attr(\"href\")\n\t\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\tnextPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\t\"\";\n\t}\n\t// content = `<h2>${chapterName}</h2>\\n${transformContent(content)}`;\n\tcontent = {\n\t\t...content,\n\t\tcontent: `<h2>${chapterName}</h2>\\n${transformContent(content.content)}`,\n\t};\n\treturn content;\n}\n","import type {\n\tBrowserFetchClient,\n\tRetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Chapter, Novel, NovelStatus, Volume } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { Element } from \"domhandler\";\nimport { novelIdToCoverUrl } from \"./cover\";\nimport type { NovelChapterQueue } from \"./queue\";\n\nexport function extractVolumesArray(catalog: string): Element[] {\n\tconst $ = cheerio.load(catalog);\n\tconst results: Element[] = [];\n\t$(\"#volume-list div.volume\").each((_, elem) => {\n\t\t$(elem).remove(\"div.volume\");\n\t\tresults.push(elem);\n\t});\n\treturn results;\n}\n\nfunction processVolumeName(novelTitle: string, volumeName: string): string {\n\t// Remove novel title from volume name if present\n\tif (volumeName.startsWith(novelTitle)) {\n\t\treturn volumeName.slice(novelTitle.length).trim();\n\t}\n\tif (!Number.isNaN(Number(volumeName))) {\n\t\treturn `第 ${volumeName} 卷`;\n\t}\n\treturn volumeName.trim();\n}\n\ninterface FixTask {\n\tchapter: Chapter; // 引用待修改的章节对象\n\tnextChapterEl: Element; // 依赖的下一个章节 DOM 节点\n}\n\nexport function parseVolumeOrChapterId(url: string): string {\n\tif (url.includes(\"javascript:cid(0)\")) {\n\t\treturn \"TOBEDETERMINED\";\n\t}\n\tconst match = url.match(/\\/novel\\/\\d+\\/(\\d+|vol_\\d+)\\.html/);\n\treturn match ? (match[1] ?? \"\") : \"\";\n}\n\nasync function parseChapterIdFromNextChapter(\n\tnextChapterEl: Element,\n\tchapterQueue: NovelChapterQueue,\n): Promise<string> {\n\tconst nextChapterPath = nextChapterEl.attribs.href ?? \"\";\n\tconst nextChapterContent = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com${nextChapterPath}`,\n\t);\n\tconst $temp = cheerio.load(nextChapterContent);\n\tconst chapterPath =\n\t\t$temp(\"div.mlfy_page a:first\").attr(\"href\") ??\n\t\tnextChapterContent.match(\n\t\t\t/url_previous:'(\\/novel\\/\\d+\\/[\\d_]+\\.html)'/,\n\t\t)?.[1] ??\n\t\t\"\";\n\treturn parseVolumeOrChapterId(chapterPath);\n}\n\nasync function getNovelVolumes(\n\ttitle: string,\n\turl: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Volume[]> {\n\tconst catalogHtml = await fetchClient.text(url, { retry });\n\tconst volumeEls = extractVolumesArray(catalogHtml.data);\n\n\tconst volumes: Volume[] = [];\n\tconst fixTasks: FixTask[] = [];\n\n\t// --- 第一步:同步解析整个 DOM 树,建立完整的目录结构 ---\n\t// 预先将所有的 volumeEl 加载好,方便跨卷时能够安全地索引\n\tconst parsedVolumes = volumeEls.map((el) => {\n\t\tconst $ = cheerio.load(el);\n\t\treturn {\n\t\t\t$,\n\t\t\tvolumeName: processVolumeName(title, $(\"h2\").text()),\n\t\t\tvolumeId: parseVolumeOrChapterId($(\"h2 a\").attr(\"href\") ?? \"\"),\n\t\t\tvolumeCover: $(\"a.volume-cover img\").attr(\"data-original\") ?? \"\",\n\t\t\tchapterEls: $(\"ul.chapter-list li a\").toArray(),\n\t\t};\n\t});\n\n\tfor (let vIndex = 0; vIndex < parsedVolumes.length; vIndex++) {\n\t\tconst vData = parsedVolumes[vIndex] as {\n\t\t\t$: cheerio.CheerioAPI;\n\t\t\tvolumeName: string;\n\t\t\tvolumeId: string;\n\t\t\tvolumeCover: string;\n\t\t\tchapterEls: Element[];\n\t\t};\n\t\tconst chapters: Chapter[] = [];\n\n\t\tfor (let cIndex = 0; cIndex < vData.chapterEls.length; cIndex++) {\n\t\t\tconst chapterEl = vData.chapterEls[cIndex];\n\t\t\tif (!chapterEl) {\n\t\t\t\tcontinue; // 这个章节节点不存在,跳过\n\t\t\t}\n\t\t\tconst $chapter = cheerio.load(chapterEl);\n\n\t\t\tconst chapterName = $chapter.text().trim();\n\t\t\tconst chapterPath = chapterEl.attribs.href ?? \"\";\n\t\t\tconst chapterId = parseVolumeOrChapterId(chapterPath);\n\n\t\t\tconst chapterObj: Chapter = {\n\t\t\t\tid: chapterId,\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\ttitle: chapterName,\n\t\t\t\tvolumeId: vData.volumeId,\n\t\t\t};\n\t\t\tchapters.push(chapterObj);\n\n\t\t\t// 如果需要后续修复,寻找它的下一个章节节点\n\t\t\tif (chapterId === \"TOBEDETERMINED\" && chapterQueue) {\n\t\t\t\tlet nextChapterEl: Element | null = null;\n\n\t\t\t\tif (cIndex < vData.chapterEls.length - 1) {\n\t\t\t\t\t// 情况 A:本卷还有下一章\n\t\t\t\t\tconst potentialNextEl = vData.chapterEls[cIndex + 1];\n\t\t\t\t\tif (potentialNextEl) {\n\t\t\t\t\t\tnextChapterEl = potentialNextEl;\n\t\t\t\t\t}\n\t\t\t\t} else if (vIndex < parsedVolumes.length - 1) {\n\t\t\t\t\t// 情况 B:本卷结束了,去找下一卷的第一章\n\t\t\t\t\tconst nextVolData = parsedVolumes[vIndex + 1];\n\t\t\t\t\tif (nextVolData) {\n\t\t\t\t\t\tif (nextVolData.chapterEls.length > 0) {\n\t\t\t\t\t\t\tconst potentialNextEl = nextVolData.chapterEls[0];\n\t\t\t\t\t\t\tif (potentialNextEl) {\n\t\t\t\t\t\t\t\tnextChapterEl = potentialNextEl;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// 如果找到了合法的下一章,扔进任务清单\n\t\t\t\tif (nextChapterEl) {\n\t\t\t\t\tfixTasks.push({\n\t\t\t\t\t\tchapter: chapterObj, // JS 对象引用,后续直接修改 id\n\t\t\t\t\t\tnextChapterEl,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvolumes.push({\n\t\t\tid: vData.volumeId,\n\t\t\tplatform: \"linovelib\",\n\t\t\ttitle: vData.volumeName,\n\t\t\tcoverUrl: vData.volumeCover,\n\t\t\tchapters: chapters,\n\t\t});\n\t}\n\n\t// --- 第二步:集中并发/队列处理,回填数据 ---\n\tif (fixTasks.length > 0 && chapterQueue) {\n\t\t// 使用 Promise.all 配合你的 p-queue (concurrency=1)\n\t\tawait Promise.all(\n\t\t\tfixTasks.map(async (task) => {\n\t\t\t\t// 此时推入 MQ,由 MQ 内部控制并发率和流控\n\t\t\t\tconst realId = await parseChapterIdFromNextChapter(\n\t\t\t\t\ttask.nextChapterEl,\n\t\t\t\t\tchapterQueue,\n\t\t\t\t);\n\t\t\t\tif (realId) {\n\t\t\t\t\ttask.chapter.id = realId; // 利用引用直接修改 volumes 数组内部的值\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn volumes;\n}\n\nexport async function getNovelInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Novel | undefined> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tconst title = $(\"h1.book-name\").text().trim();\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\tconst summary = (() => {\n\t\tconst $container = $(\".book-dec.Jbook-dec\").clone();\n\t\t$container.find(\".notice\").remove();\n\t\tconst paragraphs: string[] = [];\n\t\t$container\n\t\t\t.find(\"p\")\n\t\t\t.not(\".backupname\")\n\t\t\t.each((_, el) => {\n\t\t\t\tparagraphs.push($(el).text().trim());\n\t\t\t});\n\t\treturn paragraphs.join(\"\\n\");\n\t})();\n\tconst author = $(\"div.au-name a:first\").text().trim();\n\tconst status: NovelStatus = $(\"div.book-label a.state\")\n\t\t.text()\n\t\t.includes(\"完结\")\n\t\t? \"completed\"\n\t\t: \"ongoing\";\n\tconst genres = $(\"div.book-label span\")\n\t\t.children(\"a\")\n\t\t.map((_, el) => $(el).text())\n\t\t.toArray()\n\t\t.join(\",\");\n\tconst novel: Novel = {\n\t\tid,\n\t\tplatform: \"linovelib\",\n\t\ttitle,\n\t\tcoverUrl,\n\t\tsummary,\n\t\tauthor,\n\t\tstatus,\n\t\tgenres: genres.split(\",\").map((g) => g.trim()),\n\t\tvolumes: [], // Volumes and chapters will be fetched separately\n\t};\n\tnovel.volumes = (\n\t\tawait getNovelVolumes(\n\t\t\ttitle,\n\t\t\t`https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`,\n\t\t\tfetchClient,\n\t\t\tretry,\n\t\t\tchapterQueue,\n\t\t)\n\t).map((v) => {\n\t\tv.novelId = novel.id;\n\t\treturn v;\n\t});\n\treturn novel;\n}\n\nexport interface NovelUpdateInfo {\n\tcoverUrl: string;\n\tchapterCount: number;\n}\n\nexport async function getUpdateInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n): Promise<NovelUpdateInfo | null> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tif ($(\"h1.book-name\").length === 0) {\n\t\treturn null;\n\t}\n\tconst catalogUrl = `https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`;\n\tconst catalogHtml = (\n\t\tawait fetchClient.text(catalogUrl, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $catalog = cheerio.load(catalogHtml);\n\tconst chapterCount = $catalog(\n\t\t\"#volume-list div.volume ul.chapter-list li a\",\n\t).length;\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn {\n\t\tcoverUrl,\n\t\tchapterCount,\n\t};\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport { load } from \"cheerio\";\nimport { extractVolumesArray, parseVolumeOrChapterId } from \"./novel\";\n\nexport function novelIdToCoverUrl(novelId: string): string {\n\tconst prefix = novelId.length > 3 ? novelId[0] : \"0\";\n\treturn `https://www.linovelib.com/files/article/image/${prefix}/${novelId}/${novelId}s.jpg`;\n}\n\nexport async function getNovelCoverUrl(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst novelUrl = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = await fetchClient.text(novelUrl);\n\tconst $ = load(html.data);\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn coverUrl;\n}\n\nexport async function getVolumeCoverUrl(\n\tid: string,\n\tnovelId: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst catalogUrl = `https://www.linovelib.com/novel/${novelId}/catalog`;\n\tconst html = await fetchClient.text(catalogUrl);\n\tconst $ = load(html.data);\n\tconst volumes = extractVolumesArray(html.data);\n\tconst volume = volumes.find((v) => {\n\t\tconst volumeId = parseVolumeOrChapterId(\n\t\t\t$(v).find(\"h2 a\").attr(\"href\") ?? \"\",\n\t\t);\n\t\treturn volumeId === id;\n\t});\n\tif (!volume) {\n\t\tthrow new Error(`Volume not found for ID: ${id}`);\n\t}\n\tconst coverUrl =\n\t\t$(volume).find(\"a.volume-cover img\").attr(\"data-original\") || \"\";\n\treturn coverUrl;\n}\n","import {\n\ttype BrowserFetchClient,\n\tCloudflareBlockError,\n\tdefaultRetryPolicy,\n\ttype RetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Novel } from \"@acanthis-dec/core\";\nimport PQueue from \"p-queue\";\nimport type { Logger } from \"winston\";\nimport { getNovelInfo, getUpdateInfo, type NovelUpdateInfo } from \"./novel\";\n\n/**\n * Simple backoff strategy for request rate limiting\n * - Normal delay: 500-1000ms random\n * - Failure delay: 8000ms (8 seconds)\n */\nclass SimpleBackoff {\n\treadonly NORMAL_DELAY_MIN = 500;\n\treadonly NORMAL_DELAY_MAX = 1000;\n\treadonly FAILURE_DELAY = 15000;\n\n\t/**\n\t * Get delay for normal (successful) operation\n\t * @returns Random delay in range [500, 1000]ms. If isMobile is true, returns random delay in range [2000, 5000]ms\n\t */\n\tgetDelayForSuccess(): number {\n\t\treturn (\n\t\t\tthis.NORMAL_DELAY_MIN +\n\t\t\tMath.random() * (this.NORMAL_DELAY_MAX - this.NORMAL_DELAY_MIN)\n\t\t);\n\t}\n}\n\nexport class NovelChapterQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchChapterPart(url: string): Promise<string> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelChapterQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)(?:_(\\d+))?\\.html/);\n\t\t\tif (!match) {\n\t\t\t\tthrow new Error(`Invalid chapter URL: ${url}`);\n\t\t\t}\n\t\t\tconst novelId = match[1];\n\t\t\tconst chapterId = match[2];\n\t\t\tconst partId = match[3] || \"1\";\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 开始获取小说${novelId}章节${chapterId}的第${partId}部分内容`,\n\t\t\t);\n\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst content = (await this.client.text(url, { retry })).data ?? \"\";\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。`,\n\t\t\t);\n\t\t\treturn content;\n\t\t});\n\t}\n}\n\nexport class NovelInfoQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate chapterQueue: NovelChapterQueue;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(\n\t\tclient: BrowserFetchClient,\n\t\tchapterQueue: NovelChapterQueue,\n\t\tlogger?: Logger,\n\t) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.chapterQueue = chapterQueue;\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchNovelInfo(id: string): Promise<Novel> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的信息`);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst novel = await getNovelInfo(\n\t\t\t\tid,\n\t\t\t\tthis.client,\n\t\t\t\tretry,\n\t\t\t\tthis.chapterQueue,\n\t\t\t);\n\t\t\tif (!novel) {\n\t\t\t\tthrow new Error(`无法获取小说信息: ${id}`);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 小说${id} 信息获取成功。`);\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn novel;\n\t\t});\n\t}\n\n\tasync fetchNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 开始获取小说${id}的更新信息(封面和章节数)`,\n\t\t\t);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst updateInfo = await getUpdateInfo(id, this.client, retry);\n\t\t\tif (!updateInfo) {\n\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t`[NovelInfoQueue] 无法获取小说${id}的更新信息,可能是因为小说不存在或已被删除`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 小说${id} 更新信息获取成功。 封面: ${updateInfo.coverUrl}, 章节数: ${updateInfo.chapterCount}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn updateInfo;\n\t\t});\n\t}\n}\n","import type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport type * as cheerio from \"cheerio\";\nimport { extractNovelIdFromUrl } from \"../utils\";\n\nexport function parseSearchHtml($: cheerio.CheerioAPI): NovelSearchResult[] {\n\tconst results: NovelSearchResult[] = [];\n\t$(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst title = $el.find(\"h2\").text().trim();\n\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\tresults.push({\n\t\t\ttitle,\n\t\t\tplatform: \"linovelib\",\n\t\t\tid,\n\t\t\tcoverUrl,\n\t\t});\n\t});\n\treturn results;\n}\n\nexport function parseBookHtml($: cheerio.CheerioAPI): NovelSearchResult {\n\treturn {\n\t\ttitle: $(\"h1.book-name\").text().trim(),\n\t\tplatform: \"linovelib\",\n\t\tid: extractNovelIdFromUrl($(\"meta[name=url]\").attr(\"content\") ?? \"\") || \"\",\n\t\tcoverUrl: $(\"div.book-img img\").attr(\"src\") || \"\",\n\t};\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport { type NovelSearchResult, runTimeout } from \"@acanthis-dec/core\";\nimport { Mutex } from \"async-mutex\";\nimport { load } from \"cheerio\";\nimport { parseBookHtml, parseSearchHtml } from \"./common\";\n\nexport async function refreshSearchTicket(\n\tfetchClient: BrowserFetchClient,\n): Promise<void> {\n\tawait fetchClient.text(\"https://www.linovelib.com/S6/?search_guard=css\", {\n\t\theaders: {\n\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t\"Sec-Fetch-Site\": \"same-origin\",\n\t\t},\n\t});\n\tconst guardJsResp = await fetchClient.text(\n\t\t\"https://www.linovelib.com/S6/?search_guard=js\",\n\t\t{\n\t\t\theaders: {\n\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t\t\"Sec-Fetch-Site\": \"same-origin\",\n\t\t\t},\n\t\t},\n\t);\n\tif (guardJsResp.mimeType !== \"application/javascript\") {\n\t\tthrow new Error(`Unexpected response type: ${guardJsResp.mimeType}`);\n\t}\n\tconst guardJsToken = guardJsResp.data.match(/jieqiSearchJs=([^;\"]+)/)?.[1];\n\tif (!guardJsToken) {\n\t\tthrow new Error(\n\t\t\t\"Failed to extract jieqiSearchJs token from guard JS response\",\n\t\t);\n\t}\n\tawait fetchClient.cookieStore.set(\"jieqiSearchJs\", guardJsToken, {\n\t\tdomain: \"www.linovelib.com\",\n\t\tpath: \"/\",\n\t\tmaxAge: 3600,\n\t\tsameSite: \"Lax\",\n\t\tsecure: true,\n\t\thttpOnly: true,\n\t});\n\tconst request = async () =>\n\t\tfetchClient.text(\n\t\t\t`https://www.linovelib.com/S6/?search_guard=redeem&r=${Date.now()}`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t\t\t\"Sec-Fetch-Site\": \"same-origin\",\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\tawait runTimeout(request, 120);\n\tawait runTimeout(request, 800);\n\tawait runTimeout(request, 2000);\n}\n\nexport class EmptyBodyError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"EmptyBodyError\";\n\t}\n}\n\nexport class SearchTicketManager {\n\tprivate mutex = new Mutex();\n\tprivate readonly ticketCookieKey = \"jieqiSearchTicket\";\n\tprivate readonly domain = \"www.linovelib.com\";\n\tprivate prefetching = false;\n\n\tconstructor(private fetchClient: BrowserFetchClient) {}\n\n\tprivate async hasValidTicket(): Promise<boolean> {\n\t\tconst cookies = await this.fetchClient.cookieStore.getForUrl(\n\t\t\t`https://${this.domain}/`,\n\t\t);\n\t\treturn cookies.some((c) => c.name === this.ticketCookieKey);\n\t}\n\n\tprivate async consumeTicket(): Promise<void> {\n\t\tawait this.fetchClient.cookieStore.delete(\n\t\t\tthis.ticketCookieKey,\n\t\t\tthis.domain,\n\t\t);\n\t}\n\n\t/**\n\t * 唯一入口:确保 ticket 存在 -> 执行业务请求 -> 消费(清空) ticket。\n\t * 整个过程串行、互斥,同一时刻只允许一个调用在跑。\n\t */\n\tasync runExclusive<T>(task: () => Promise<T>): Promise<T> {\n\t\treturn this.mutex.runExclusive(async () => {\n\t\t\tif (!(await this.hasValidTicket())) {\n\t\t\t\tawait refreshSearchTicket(this.fetchClient);\n\t\t\t}\n\n\t\t\twhile (true) {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await task();\n\n\t\t\t\t\t// 请求成功后:旧票作废\n\t\t\t\t\tawait this.consumeTicket();\n\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof EmptyBodyError) {\n\t\t\t\t\t\tawait refreshSearchTicket(this.fetchClient);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tawait this.consumeTicket();\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t/**\n\t * 后台预取:模拟源站\"成功页面里嵌入 refresh 逻辑\"的行为。\n\t * 不在调用方持有的锁内执行,而是自己重新抢锁,\n\t * 这样不会拖慢刚刚那次请求的 return。\n\t */\n\tschedulePrefetch(): void {\n\t\tif (this.prefetching) return; // 已经有一个在跑,不重复触发\n\t\tthis.prefetching = true;\n\n\t\tthis.mutex\n\t\t\t.runExclusive(async () => {\n\t\t\t\t// 双重检查:等到真正拿到锁时,可能已经被别的调用刷新过了\n\t\t\t\tif (await this.hasValidTicket()) return;\n\t\t\t\tawait refreshSearchTicket(this.fetchClient);\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\t// prefetch 失败不影响主流程,只记录,不往外抛\n\t\t\t\t// 下次真正需要 ticket 时 ensureToken 会自然重试\n\t\t\t\tconsole.error(\"[SearchTicketManager] prefetch failed:\", err);\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.prefetching = false;\n\t\t\t});\n\t}\n}\n\nasync function obtainFromNextPage(\n\tpath: string,\n\tfetchClient: BrowserFetchClient,\n\tticketManager: SearchTicketManager,\n): Promise<NovelSearchResult[]> {\n\tconst html = await ticketManager.runExclusive(async () => {\n\t\tconst response = await fetchClient.text(\n\t\t\t`https://www.linovelib.com${path}`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\t\treferer: \"https://www.linovelib.com/S6/\",\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\tif (response.mimeType !== \"text/html\") {\n\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t}\n\t\tif (response.data === \"\") {\n\t\t\tthrow new EmptyBodyError(\"Empty response body when fetching next page\");\n\t\t}\n\t\treturn response.data;\n\t});\n\tconst $ = load(html);\n\tconst results: NovelSearchResult[] = [];\n\tresults.push(...parseSearchHtml($));\n\tif ($(\"a.next\").length > 0) {\n\t\tresults.push(\n\t\t\t...(await obtainFromNextPage(\n\t\t\t\t$(\"a.next\").attr(\"href\") || \"\",\n\t\t\t\tfetchClient,\n\t\t\t\tticketManager,\n\t\t\t)),\n\t\t);\n\t}\n\treturn results;\n}\n\nexport async function searchNovelsV2(\n\tkeyword: string,\n\tfetchClient: BrowserFetchClient,\n\tticketManager: SearchTicketManager,\n): Promise<NovelSearchResult[]> {\n\tconst searchHtml = await ticketManager.runExclusive(async () => {\n\t\tconst tr = await fetchClient.text(\"https://www.linovelib.com/S6/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: new URLSearchParams({\n\t\t\t\tsearchkey: keyword,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t\tif (tr?.mimeType !== \"text/html\") {\n\t\t\tthrow new Error(`Unexpected response type: ${tr?.mimeType}`);\n\t\t}\n\t\tif (tr?.data === \"\") {\n\t\t\tthrow new EmptyBodyError(\n\t\t\t\t\"Empty response body when fetching search results\",\n\t\t\t);\n\t\t}\n\t\treturn tr.data;\n\t});\n\tconst results: NovelSearchResult[] = [];\n\tconst $ = load(searchHtml);\n\tif ($(\"div.book-html-box\").length > 0) {\n\t\treturn [parseBookHtml($)];\n\t}\n\tresults.push(...parseSearchHtml($));\n\tconst pages =\n\t\t$(\"em#pagestats\")\n\t\t\t.text()\n\t\t\t.match(/1\\/(\\d+)/)?.[1] || \"1\";\n\tif (Number(pages) > 1) {\n\t\tresults.push(\n\t\t\t...(await obtainFromNextPage(\n\t\t\t\t$(\"a.next\").attr(\"href\") || \"\",\n\t\t\t\tfetchClient,\n\t\t\t\tticketManager,\n\t\t\t)),\n\t\t);\n\t}\n\tticketManager.schedulePrefetch();\n\treturn results;\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\n\nexport interface LoginConfig {\n\tusername: string;\n\tpassword: string;\n}\n\nexport async function refreshSessionId(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tawait fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php\",\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tconst response = await fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php?do=submit&jumpurl=https%3A%2F%2Fwww.linovelib.com%2F\",\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tusername: loginConfig.username,\n\t\t\tpassword: loginConfig.password,\n\t\t\tusecookie: \"3153600000\",\n\t\t\tsubmit: \"登录\",\n\t\t\taction: \"login\",\n\t\t}),\n\t\tfollowRedirects: false,\n\t});\n\treturn (\n\t\tresponse.cookies.findIndex((cookie) => cookie.name === \"PHPSESSID\") !== -1\n\t);\n}\n\nexport async function hasValidSession(\n\tfetchClient: BrowserFetchClient,\n): Promise<boolean> {\n\tconst response = await fetchClient.text(\"https://www.linovelib.com\");\n\tif (response.data.includes(\"用户中心\")) return true;\n\telse return false;\n}\n\nexport async function ensureValidSession(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tif (!(await hasValidSession(fetchClient))) {\n\t\tconst isValid =\n\t\t\t(await refreshSessionId(fetchClient, loginConfig)) &&\n\t\t\t(await hasValidSession(fetchClient));\n\t\tif (!isValid) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import {\n\ttype BinaryResponse,\n\tBrowserFetchClient,\n\ttype BrowserFetchClientOptions,\n\ttype BrowserProfileName,\n\ttype FlareSolverrOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type {\n\tDescrambleCoefficients,\n\tNovel,\n\tNovelSearchResult,\n} from \"@acanthis-dec/core\";\nimport type { StorageService } from \"@acanthis-dec/storage\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport type { Logger } from \"winston\";\nimport z from \"zod\";\nimport { getChapter } from \"./chapter\";\nimport { descrambleCoefficientsSchema } from \"./coefficients\";\nimport { getVolumeCoverUrl, novelIdToCoverUrl } from \"./cover\";\nimport type { NovelUpdateInfo } from \"./novel\";\nimport { NovelChapterQueue, NovelInfoQueue } from \"./queue\";\nimport { SearchTicketManager, searchNovels } from \"./search\";\nimport { ensureValidSession } from \"./session\";\n\nexport type SessionOptions =\n\t| {\n\t\t\tenabled: false;\n\t }\n\t| {\n\t\t\tenabled: true;\n\t\t\tusername: string;\n\t\t\tpassword: string;\n\t };\n\nexport type ImpersonateOptions =\n\t| {\n\t\t\tenabled: true;\n\t\t\tprofile: BrowserProfileName;\n\t }\n\t| {\n\t\t\tenabled: false;\n\t };\n\nexport type CookieStoreOptions =\n\t| {\n\t\t\ttype: \"memory\" | \"database\";\n\t }\n\t| {\n\t\t\ttype: \"file\";\n\t\t\tpath: string;\n\t };\n\nexport type LinovelibClientOptions = {\n\tsession: SessionOptions;\n\tflareSolverr: FlareSolverrOptions;\n\timpersonate: ImpersonateOptions;\n\tcookies: CookieStoreOptions;\n\tproxy?: string | undefined;\n};\n\nexport class LinovelibClient {\n\tprivate storage?: StorageService | undefined;\n\tprivate fetchClient: BrowserFetchClient;\n\tprivate novelChapterQueue: NovelChapterQueue;\n\tprivate novelInfoQueue: NovelInfoQueue;\n\tprivate searchTicketManager: SearchTicketManager;\n\tprivate options?: LinovelibClientOptions;\n\tprivate logger?: Logger | undefined;\n\tprivate isSessionValid?: boolean = undefined;\n\n\tconstructor(\n\t\toptions?: LinovelibClientOptions,\n\t\tstorage?: StorageService,\n\t\tlogger?: Logger,\n\t) {\n\t\tconst defaultOptions: LinovelibClientOptions = {\n\t\t\tsession: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tflareSolverr: {\n\t\t\t\tenabled: true,\n\t\t\t\thost: \"http://localhost:8191\",\n\t\t\t\ttimeoutMs: 60000,\n\t\t\t\tsessionId: \"acanthis-linovelib-client\",\n\t\t\t},\n\t\t\timpersonate: {\n\t\t\t\tenabled: true,\n\t\t\t\tprofile: \"chrome-latest-linux\",\n\t\t\t},\n\t\t\tcookies: {\n\t\t\t\ttype: \"memory\",\n\t\t\t},\n\t\t};\n\t\tthis.options = deepmerge(\n\t\t\tdefaultOptions,\n\t\t\toptions ?? {},\n\t\t) as LinovelibClientOptions;\n\t\tthis.storage = storage;\n\t\tthis.logger = logger;\n\t\tconst browserFetchOptions: BrowserFetchClientOptions = {};\n\t\tif (this.options?.flareSolverr.enabled) {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: true,\n\t\t\t\thost: this.options.flareSolverr.host,\n\t\t\t\ttimeoutMs: this.options.flareSolverr.timeoutMs ?? 60000,\n\t\t\t\tsessionId:\n\t\t\t\t\tthis.options.flareSolverr.sessionId ?? \"acanthis-linovelib-client\",\n\t\t\t};\n\t\t} else {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\t\tif (this.options?.proxy) {\n\t\t\tbrowserFetchOptions.proxy = this.options.proxy;\n\t\t}\n\t\tif (this.options?.impersonate.enabled) {\n\t\t\tbrowserFetchOptions.profile = this.options.impersonate.profile;\n\t\t}\n\t\tswitch (this.options?.cookies.type) {\n\t\t\tcase \"memory\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tpath: this.options.cookies.path,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"database\":\n\t\t\t\tif (!this.storage) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"StorageService is required for database cookie store\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\tstore: this.storage.getCookieStore(),\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t}\n\t\tthis.fetchClient = new BrowserFetchClient(browserFetchOptions);\n\t\tthis.novelChapterQueue = new NovelChapterQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.novelInfoQueue = new NovelInfoQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.searchTicketManager = new SearchTicketManager(this.fetchClient);\n\t}\n\n\tasync getNovelInfo(id: string): Promise<Novel | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelInfo(id);\n\t}\n\n\tasync getNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelUpdateInfo(id);\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await searchNovels(\n\t\t\tkeyword,\n\t\t\tthis.fetchClient,\n\t\t\tthis.searchTicketManager,\n\t\t);\n\t}\n\n\tasync getNovelCover(\n\t\tid: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await novelIdToCoverUrl(id);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${id}.html`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getVolumeCover(\n\t\tnovelId: string,\n\t\tvolumeId: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await getVolumeCoverUrl(\n\t\t\tvolumeId,\n\t\t\tnovelId,\n\t\t\tthis.fetchClient,\n\t\t);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${novelId}/catalog`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getCover(url: string, referer?: string): Promise<BinaryResponse> {\n\t\treturn await this.fetchClient.binary(url, {\n\t\t\theaders: {\n\t\t\t\tReferer: referer || \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t}\n\n\tasync getChapter(\n\t\tnovelId: string,\n\t\tchapterId: string,\n\t): Promise<string | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst cachedJsVersion = this.storage\n\t\t\t? ((await this.storage.getCache(\"chapterlog_js_version\", z.string())) ??\n\t\t\t\tundefined)\n\t\t\t: undefined;\n\t\tconst cachedCoefficients = this.storage\n\t\t\t? ((await this.storage.getCache<DescrambleCoefficients>(\n\t\t\t\t\t\"coefficients\",\n\t\t\t\t\tdescrambleCoefficientsSchema,\n\t\t\t\t)) ?? undefined)\n\t\t\t: undefined;\n\t\tconst result = await getChapter(\n\t\t\tchapterId,\n\t\t\tnovelId,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.fetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tif (this.storage && result) {\n\t\t\tawait this.storage.setCache(\"chapterlog_js_version\", result.version);\n\t\t\tawait this.storage.setCache(\"coefficients\", result.coefficients);\n\t\t}\n\t\treturn result?.content;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAM,WACJ,eAA6D,WAC9D;AAED,MAAa,+BAA+B,EAAE,OAAO;CACpD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI;CACxB,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI;CAC1B,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI;AAChC,CAAC;AAED,SAAS,kBAAkB,UAA0B;CACpD,OAAO,SACL,MAAM,OAAO,CAAC,CACd,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,QAAQ,SAAS,SAAS,EAAE,CAAC,CAC7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AChB;AACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["z","decodePng","searchNovels"],"sources":["../src/coefficients.ts","../src/utils.ts","../src/chapter.ts","../src/novel.ts","../src/cover.ts","../src/queue.ts","../src/search/common.ts","../src/search/captcha.ts","../src/search/v3.ts","../src/session.ts","../src/client.ts"],"sourcesContent":["import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { DescrambleCoefficients } from \"@acanthis-dec/core\";\nimport { deobfuscate } from \"@acanthis-dec/deobfuscator\";\nimport { parse } from \"@babel/parser\";\nimport traverseModule from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport * as cheerio from \"cheerio\";\nimport { z } from \"zod\";\n\ntype TraverseFunction = typeof traverseModule;\n\nconst traverse =\n\t(traverseModule as unknown as { default?: TraverseFunction }).default ??\n\ttraverseModule;\n\nexport const descrambleCoefficientsSchema = z.object({\n\tmodulus: z.number().int(),\n\tincrement: z.number().int(),\n\tmultiplier: z.number().int(),\n\tseedOffset: z.number().int(),\n\tseedMultiplier: z.number().int(),\n});\n\nfunction getObfuscatedPart(fullCode: string): string {\n\treturn fullCode\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\")\n\t\t.slice(-2)\n\t\t.join(\"\\n\");\n}\n\nexport async function extractCoefficients(\n\tscript: string,\n): Promise<DescrambleCoefficients> {\n\tconst obfuscatedPart = getObfuscatedPart(script);\n\tconst deObfCode = await deobfuscate(obfuscatedPart);\n\tconst ast = parse(deObfCode, { sourceType: \"module\", plugins: [\"jsx\"] });\n\tconst coefficients: Partial<DescrambleCoefficients> = {};\n\ttraverse(ast, {\n\t\tBinaryExpression(path) {\n\t\t\tconst { node } = path;\n\t\t\tif (\n\t\t\t\tnode.operator === \"%\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right) &&\n\t\t\t\tt.isBinaryExpression(node.left.left) &&\n\t\t\t\tnode.left.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.left.right)\n\t\t\t) {\n\t\t\t\tcoefficients.modulus = node.right.value;\n\t\t\t\tconst leftSide = node.left;\n\t\t\t\tif (t.isBinaryExpression(leftSide) && leftSide.operator === \"+\") {\n\t\t\t\t\tif (t.isNumericLiteral(leftSide.right)) {\n\t\t\t\t\t\tcoefficients.increment = leftSide.right.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isBinaryExpression(leftSide.left) &&\n\t\t\t\t\t\tleftSide.left.operator === \"*\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (t.isNumericLiteral(leftSide.left.right)) {\n\t\t\t\t\t\t\tcoefficients.multiplier = leftSide.left.right.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnode.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right)\n\t\t\t) {\n\t\t\t\tconst potentialOffset = node.right.value;\n\t\t\t\tconst potentialMultiplier = node.left.right.value;\n\t\t\t\tconst numberTransformed = node.left.left;\n\t\t\t\tif (\n\t\t\t\t\tt.isCallExpression(numberTransformed) &&\n\t\t\t\t\tt.isIdentifier(numberTransformed.callee) &&\n\t\t\t\t\t(numberTransformed.callee.name === \"Number\" ||\n\t\t\t\t\t\tnumberTransformed.callee.name === \"parseInt\")\n\t\t\t\t) {\n\t\t\t\t\tcoefficients.seedOffset = potentialOffset;\n\t\t\t\t\tcoefficients.seedMultiplier = potentialMultiplier;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\tif (\n\t\tcoefficients.modulus === undefined ||\n\t\tcoefficients.increment === undefined ||\n\t\tcoefficients.multiplier === undefined ||\n\t\tcoefficients.seedOffset === undefined ||\n\t\tcoefficients.seedMultiplier === undefined\n\t) {\n\t\tthrow new Error(\"Failed to extract all coefficients\");\n\t}\n\treturn coefficients as DescrambleCoefficients;\n}\n\nexport function extractChapterLogScriptUrl(html: string): string {\n\tconst $ = cheerio.load(html);\n\tconst chapterLogScriptUrl =\n\t\t$(\n\t\t\t$(\"script\")\n\t\t\t\t.toArray()\n\t\t\t\t.find((el) => {\n\t\t\t\t\tconst scriptContent = $(el).attr(\"src\") || \"\";\n\t\t\t\t\treturn /chapterlog\\.js/.test(scriptContent);\n\t\t\t\t}),\n\t\t).attr(\"src\") || \"\";\n\treturn chapterLogScriptUrl.startsWith(\"http\")\n\t\t? chapterLogScriptUrl\n\t\t: `https://www.linovelib.com${chapterLogScriptUrl}`;\n}\n\nexport interface CoefficientResult {\n\tcoefficients: DescrambleCoefficients;\n\tversion: string;\n}\n\nexport async function getCoefficientsFromPage(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedVersion?: string,\n): Promise<CoefficientResult | undefined> {\n\tconst scriptUrl = extractChapterLogScriptUrl(html);\n\tif (!scriptUrl) {\n\t\tthrow new Error(\"Chapter log script URL not found\");\n\t}\n\tconst version = scriptUrl.match(/chapterlog\\.js\\?(v.*)/)?.[1] || \"\";\n\tif (version === cachedVersion) {\n\t\treturn undefined; // No need to fetch and extract again\n\t}\n\tconst scriptContent = await fetchClient.text(scriptUrl);\n\tif (!scriptContent.mimeType.includes(\"javascript\")) {\n\t\tthrow new Error(\"Fetched content is not JavaScript\");\n\t}\n\tconst coefficients = await extractCoefficients(scriptContent.data);\n\treturn {\n\t\tcoefficients,\n\t\tversion: version,\n\t};\n}\n","export function extractNovelIdFromUrl(url: string): string | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\.html/);\n\treturn match ? match[1] : undefined;\n}\n\nexport interface NovelAndChapterIds {\n\tnovelId: string | undefined;\n\tchapterId: string | undefined;\n}\n\nexport function extractChapterIdFromUrl(\n\turl: string,\n): NovelAndChapterIds | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)\\.html/);\n\tif (match) {\n\t\treturn {\n\t\t\tnovelId: match[1],\n\t\t\tchapterId: match[2],\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function transformChapterName(name: string): string {\n\tconst chapNameTransDict: Record<string, string> = {\n\t\t\"\\u004e\": \"\\u5973\",\n\t};\n\treturn name.replace(/./g, (char) => chapNameTransDict[char] || char);\n}\n\nexport function transformContent(content: string): string {\n\tconst contentTransDict: Record<string, string> = {\n\t\t\"\\u201c\": \"\\u300c\",\n\t\t\"\\u201d\": \"\\u300d\",\n\t\t\"\\u2018\": \"\\u300e\",\n\t\t\"\\u2019\": \"\\u300f\",\n\t\t\"\\ue82c\": \"\\u7684\",\n\t\t\"\\ue852\": \"\\u4e00\",\n\t\t\"\\ue82d\": \"\\u662f\",\n\t\t\"\\ue819\": \"\\u4e86\",\n\t\t\"\\ue856\": \"\\u6211\",\n\t\t\"\\ue857\": \"\\u4e0d\",\n\t\t\"\\ue816\": \"\\u4eba\",\n\t\t\"\\ue83c\": \"\\u5728\",\n\t\t\"\\ue830\": \"\\u4ed6\",\n\t\t\"\\ue82e\": \"\\u6709\",\n\t\t\"\\ue836\": \"\\u8fd9\",\n\t\t\"\\ue859\": \"\\u4e2a\",\n\t\t\"\\ue80a\": \"\\u4e0a\",\n\t\t\"\\ue855\": \"\\u4eec\",\n\t\t\"\\ue842\": \"\\u6765\",\n\t\t\"\\ue858\": \"\\u5230\",\n\t\t\"\\ue80b\": \"\\u65f6\",\n\t\t\"\\ue81f\": \"\\u5927\",\n\t\t\"\\ue84a\": \"\\u5730\",\n\t\t\"\\ue853\": \"\\u4e3a\",\n\t\t\"\\ue81e\": \"\\u5b50\",\n\t\t\"\\ue822\": \"\\u4e2d\",\n\t\t\"\\ue813\": \"\\u4f60\",\n\t\t\"\\ue85b\": \"\\u8bf4\",\n\t\t\"\\ue807\": \"\\u751f\",\n\t\t\"\\ue818\": \"\\u56fd\",\n\t\t\"\\ue810\": \"\\u5e74\",\n\t\t\"\\ue812\": \"\\u7740\",\n\t\t\"\\ue851\": \"\\u5c31\",\n\t\t\"\\ue801\": \"\\u90a3\",\n\t\t\"\\ue80c\": \"\\u548c\",\n\t\t\"\\ue815\": \"\\u8981\",\n\t\t\"\\ue84c\": \"\\u5979\",\n\t\t\"\\ue840\": \"\\u51fa\",\n\t\t\"\\ue848\": \"\\u4e5f\",\n\t\t\"\\ue835\": \"\\u5f97\",\n\t\t\"\\ue800\": \"\\u91cc\",\n\t\t\"\\ue826\": \"\\u540e\",\n\t\t\"\\ue863\": \"\\u81ea\",\n\t\t\"\\ue861\": \"\\u4ee5\",\n\t\t\"\\ue854\": \"\\u4f1a\",\n\t\t\"\\ue827\": \"\\u5bb6\",\n\t\t\"\\ue83b\": \"\\u53ef\",\n\t\t\"\\ue85d\": \"\\u4e0b\",\n\t\t\"\\ue84d\": \"\\u800c\",\n\t\t\"\\ue862\": \"\\u8fc7\",\n\t\t\"\\ue81c\": \"\\u5929\",\n\t\t\"\\ue81d\": \"\\u53bb\",\n\t\t\"\\ue860\": \"\\u80fd\",\n\t\t\"\\ue843\": \"\\u5bf9\",\n\t\t\"\\ue82f\": \"\\u5c0f\",\n\t\t\"\\ue802\": \"\\u591a\",\n\t\t\"\\ue831\": \"\\u7136\",\n\t\t\"\\ue84b\": \"\\u4e8e\",\n\t\t\"\\ue837\": \"\\u5fc3\",\n\t\t\"\\ue829\": \"\\u5b66\",\n\t\t\"\\ue85e\": \"\\u4e48\",\n\t\t\"\\ue83a\": \"\\u4e4b\",\n\t\t\"\\ue832\": \"\\u90fd\",\n\t\t\"\\ue808\": \"\\u597d\",\n\t\t\"\\ue841\": \"\\u770b\",\n\t\t\"\\ue821\": \"\\u8d77\",\n\t\t\"\\ue845\": \"\\u53d1\",\n\t\t\"\\ue803\": \"\\u5f53\",\n\t\t\"\\ue828\": \"\\u6ca1\",\n\t\t\"\\ue81b\": \"\\u6210\",\n\t\t\"\\ue83e\": \"\\u53ea\",\n\t\t\"\\ue820\": \"\\u5982\",\n\t\t\"\\ue84e\": \"\\u4e8b\",\n\t\t\"\\ue85a\": \"\\u628a\",\n\t\t\"\\ue806\": \"\\u8fd8\",\n\t\t\"\\ue83f\": \"\\u7528\",\n\t\t\"\\ue833\": \"\\u7b2c\",\n\t\t\"\\ue811\": \"\\u6837\",\n\t\t\"\\ue804\": \"\\u9053\",\n\t\t\"\\ue814\": \"\\u60f3\",\n\t\t\"\\ue80f\": \"\\u4f5c\",\n\t\t\"\\ue84f\": \"\\u79cd\",\n\t\t\"\\ue80e\": \"\\u5f00\",\n\t\t\"\\ue823\": \"\\u7f8e\",\n\t\t\"\\ue849\": \"\\u4e73\",\n\t\t\"\\ue805\": \"\\u9634\",\n\t\t\"\\ue809\": \"\\u6db2\",\n\t\t\"\\ue81a\": \"\\u830e\",\n\t\t\"\\ue844\": \"\\u6b32\",\n\t\t\"\\ue847\": \"\\u547b\",\n\t\t\"\\ue850\": \"\\u8089\",\n\t\t\"\\ue824\": \"\\u4ea4\",\n\t\t\"\\ue85f\": \"\\u6027\",\n\t\t\"\\ue817\": \"\\u80f8\",\n\t\t\"\\ue85c\": \"\\u79c1\",\n\t\t\"\\ue838\": \"\\u7a74\",\n\t\t\"\\ue82a\": \"\\u6deb\",\n\t\t\"\\ue83d\": \"\\u81c0\",\n\t\t\"\\ue82b\": \"\\u8214\",\n\t\t\"\\ue80d\": \"\\u5c04\",\n\t\t\"\\ue839\": \"\\u8131\",\n\t\t\"\\ue834\": \"\\u88f8\",\n\t\t\"\\ue846\": \"\\u9a9a\",\n\t\t\"\\ue825\": \"\\u5507\",\n\t};\n\treturn content.replace(/./g, (char) => contentTransDict[char] || char);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport {\n\tbuildDescrambleMapping,\n\ttype DescrambleCoefficients,\n} from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { AnyNode, Element } from \"domhandler\";\nimport { getCoefficientsFromPage } from \"./coefficients\";\nimport type { NovelChapterQueue } from \"./queue\";\nimport { transformContent } from \"./utils\";\n\nfunction extractChapterId($: cheerio.CheerioAPI): string {\n\tconst scriptTags = $(\"script\");\n\tlet chapterId = \"\";\n\tscriptTags.each((_, el) => {\n\t\tconst scriptContent = $(el).html();\n\t\tif (scriptContent) {\n\t\t\tconst match = scriptContent.match(/chapterid\\s*:\\s*'(\\d+)'/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tchapterId = match[1];\n\t\t\t\treturn false; // Break the loop\n\t\t\t}\n\t\t}\n\t});\n\treturn chapterId;\n}\n\nexport interface DecryptResult {\n\tcontent: string;\n\tversion: string;\n\tcoefficients: DescrambleCoefficients;\n}\n\nasync function decrypt(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult> {\n\tconst $ = cheerio.load(html);\n\tconst coefficientResult = await getCoefficientsFromPage(\n\t\thtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t);\n\tconst version = coefficientResult?.version || cachedJsVersion;\n\tconst coefficients = coefficientResult?.coefficients || cachedCoefficients;\n\tif (!version) {\n\t\tthrow new Error(\"Failed to determine chapterlog.js version\");\n\t}\n\tif (!coefficients) {\n\t\tthrow new Error(\"Failed to obtain descrambling coefficients\");\n\t}\n\tconst chapterId = extractChapterId($);\n\tconst container = $(\"#TextContent, #acontent\");\n\tif (!container.length) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tversion,\n\t\t\tcoefficients: coefficients,\n\t\t};\n\t}\n\n\tcontainer.find(\"p\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst innerHtml = $el.html();\n\t\tif (innerHtml) {\n\t\t\tconst cleanedHtml = innerHtml.replace(/^\\s+|(?<=>)\\s+/g, \"\");\n\t\t\t$el.html(cleanedHtml);\n\t\t}\n\t});\n\n\tcontainer.find(\"img.imagecontent\").each((_, el) => {\n\t\tconst imgSrc = $(el).attr(\"data-src\") || $(el).attr(\"src\");\n\t\tif (imgSrc) {\n\t\t\t$(el).attr(\"src\", imgSrc).removeAttr(\"data-src\");\n\t\t}\n\t});\n\n\tcontainer.find(\"div.dag\").remove();\n\tcontainer.find(\"script\").remove();\n\n\tconst allChildren = container\n\t\t.contents()\n\t\t.toArray()\n\t\t.filter((node) => !(node.type === \"tag\" && node.tagName === \"div\"));\n\tconst sortableEntries: { element: Element; originalPos: number }[] = [];\n\tallChildren.forEach((node, index) => {\n\t\tif (node.type === \"tag\" && node.tagName === \"p\") {\n\t\t\tconst text = $(node).text().trim();\n\t\t\tif (text.length > 0) {\n\t\t\t\tsortableEntries.push({ element: node, originalPos: index });\n\t\t\t}\n\t\t}\n\t});\n\n\tconst seed =\n\t\tparseInt(chapterId, 10) * coefficients?.seedMultiplier +\n\t\tcoefficients?.seedOffset;\n\n\tconst mapping = buildDescrambleMapping(\n\t\tsortableEntries.length,\n\t\tseed,\n\t\tcoefficients,\n\t\t20,\n\t);\n\n\tconst restoredChildren: (AnyNode | null)[] = [...allChildren];\n\n\tsortableEntries.forEach((entry, i) => {\n\t\tconst targetIndex = mapping[i] ?? i;\n\t\tconst actualSlot = sortableEntries[targetIndex]?.originalPos ?? 0;\n\t\trestoredChildren[actualSlot] = entry.element;\n\t});\n\n\tconst newContainer = $(\"<div></div>\");\n\trestoredChildren.forEach((node) => {\n\t\tif (node && node.type === \"tag\") {\n\t\t\tnewContainer.append(node);\n\t\t\tnewContainer.append(\"\\n\");\n\t\t}\n\t});\n\n\treturn {\n\t\tcontent: newContainer.html() || \"\",\n\t\tversion,\n\t\tcoefficients: coefficients,\n\t};\n}\n\nexport async function getChapter(\n\tid: string,\n\tnovelId: string,\n\tchapterQueue: NovelChapterQueue,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult | undefined> {\n\tconst firstPageHtml = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com/novel/${novelId}/${id}.html`,\n\t);\n\tlet $ = cheerio.load(firstPageHtml);\n\tconst chapterName = $(\"h1\").text().trim();\n\tlet nextPageId =\n\t\t$(\"div.mlfy_page a:last\")\n\t\t\t.attr(\"href\")\n\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\tfirstPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html'/)?.[2] ||\n\t\t\"\";\n\tlet content = await decrypt(\n\t\tfirstPageHtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t\tcachedCoefficients,\n\t);\n\tcachedCoefficients = content.coefficients;\n\tcachedJsVersion = content.version;\n\twhile (nextPageId?.includes(id)) {\n\t\tconst nextPageHtml = await chapterQueue.fetchChapterPart(\n\t\t\t`https://www.linovelib.com/novel/${novelId}/${nextPageId}.html`,\n\t\t);\n\t\tconst nextContent = await decrypt(\n\t\t\tnextPageHtml,\n\t\t\tfetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tcontent = {\n\t\t\t...content,\n\t\t\tcontent: content.content + nextContent.content,\n\t\t};\n\t\t$ = cheerio.load(nextPageHtml);\n\t\tnextPageId =\n\t\t\t$(\"div.mlfy_page a:last\")\n\t\t\t\t.attr(\"href\")\n\t\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\tnextPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\t\"\";\n\t}\n\t// content = `<h2>${chapterName}</h2>\\n${transformContent(content)}`;\n\tcontent = {\n\t\t...content,\n\t\tcontent: `<h2>${chapterName}</h2>\\n${transformContent(content.content)}`,\n\t};\n\treturn content;\n}\n","import type {\n\tBrowserFetchClient,\n\tRetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Chapter, Novel, NovelStatus, Volume } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { Element } from \"domhandler\";\nimport { novelIdToCoverUrl } from \"./cover\";\nimport type { NovelChapterQueue } from \"./queue\";\n\nexport function extractVolumesArray(catalog: string): Element[] {\n\tconst $ = cheerio.load(catalog);\n\tconst results: Element[] = [];\n\t$(\"#volume-list div.volume\").each((_, elem) => {\n\t\t$(elem).remove(\"div.volume\");\n\t\tresults.push(elem);\n\t});\n\treturn results;\n}\n\nfunction processVolumeName(novelTitle: string, volumeName: string): string {\n\t// Remove novel title from volume name if present\n\tif (volumeName.startsWith(novelTitle)) {\n\t\treturn volumeName.slice(novelTitle.length).trim();\n\t}\n\tif (!Number.isNaN(Number(volumeName))) {\n\t\treturn `第 ${volumeName} 卷`;\n\t}\n\treturn volumeName.trim();\n}\n\ninterface FixTask {\n\tchapter: Chapter; // 引用待修改的章节对象\n\tnextChapterEl: Element; // 依赖的下一个章节 DOM 节点\n}\n\nexport function parseVolumeOrChapterId(url: string): string {\n\tif (url.includes(\"javascript:cid(0)\")) {\n\t\treturn \"TOBEDETERMINED\";\n\t}\n\tconst match = url.match(/\\/novel\\/\\d+\\/(\\d+|vol_\\d+)\\.html/);\n\treturn match ? (match[1] ?? \"\") : \"\";\n}\n\nasync function parseChapterIdFromNextChapter(\n\tnextChapterEl: Element,\n\tchapterQueue: NovelChapterQueue,\n): Promise<string> {\n\tconst nextChapterPath = nextChapterEl.attribs.href ?? \"\";\n\tconst nextChapterContent = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com${nextChapterPath}`,\n\t);\n\tconst $temp = cheerio.load(nextChapterContent);\n\tconst chapterPath =\n\t\t$temp(\"div.mlfy_page a:first\").attr(\"href\") ??\n\t\tnextChapterContent.match(\n\t\t\t/url_previous:'(\\/novel\\/\\d+\\/[\\d_]+\\.html)'/,\n\t\t)?.[1] ??\n\t\t\"\";\n\treturn parseVolumeOrChapterId(chapterPath);\n}\n\nasync function getNovelVolumes(\n\ttitle: string,\n\turl: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Volume[]> {\n\tconst catalogHtml = await fetchClient.text(url, { retry });\n\tconst volumeEls = extractVolumesArray(catalogHtml.data);\n\n\tconst volumes: Volume[] = [];\n\tconst fixTasks: FixTask[] = [];\n\n\t// --- 第一步:同步解析整个 DOM 树,建立完整的目录结构 ---\n\t// 预先将所有的 volumeEl 加载好,方便跨卷时能够安全地索引\n\tconst parsedVolumes = volumeEls.map((el) => {\n\t\tconst $ = cheerio.load(el);\n\t\treturn {\n\t\t\t$,\n\t\t\tvolumeName: processVolumeName(title, $(\"h2\").text()),\n\t\t\tvolumeId: parseVolumeOrChapterId($(\"h2 a\").attr(\"href\") ?? \"\"),\n\t\t\tvolumeCover: $(\"a.volume-cover img\").attr(\"data-original\") ?? \"\",\n\t\t\tchapterEls: $(\"ul.chapter-list li a\").toArray(),\n\t\t};\n\t});\n\n\tfor (let vIndex = 0; vIndex < parsedVolumes.length; vIndex++) {\n\t\tconst vData = parsedVolumes[vIndex] as {\n\t\t\t$: cheerio.CheerioAPI;\n\t\t\tvolumeName: string;\n\t\t\tvolumeId: string;\n\t\t\tvolumeCover: string;\n\t\t\tchapterEls: Element[];\n\t\t};\n\t\tconst chapters: Chapter[] = [];\n\n\t\tfor (let cIndex = 0; cIndex < vData.chapterEls.length; cIndex++) {\n\t\t\tconst chapterEl = vData.chapterEls[cIndex];\n\t\t\tif (!chapterEl) {\n\t\t\t\tcontinue; // 这个章节节点不存在,跳过\n\t\t\t}\n\t\t\tconst $chapter = cheerio.load(chapterEl);\n\n\t\t\tconst chapterName = $chapter.text().trim();\n\t\t\tconst chapterPath = chapterEl.attribs.href ?? \"\";\n\t\t\tconst chapterId = parseVolumeOrChapterId(chapterPath);\n\n\t\t\tconst chapterObj: Chapter = {\n\t\t\t\tid: chapterId,\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\ttitle: chapterName,\n\t\t\t\tvolumeId: vData.volumeId,\n\t\t\t};\n\t\t\tchapters.push(chapterObj);\n\n\t\t\t// 如果需要后续修复,寻找它的下一个章节节点\n\t\t\tif (chapterId === \"TOBEDETERMINED\" && chapterQueue) {\n\t\t\t\tlet nextChapterEl: Element | null = null;\n\n\t\t\t\tif (cIndex < vData.chapterEls.length - 1) {\n\t\t\t\t\t// 情况 A:本卷还有下一章\n\t\t\t\t\tconst potentialNextEl = vData.chapterEls[cIndex + 1];\n\t\t\t\t\tif (potentialNextEl) {\n\t\t\t\t\t\tnextChapterEl = potentialNextEl;\n\t\t\t\t\t}\n\t\t\t\t} else if (vIndex < parsedVolumes.length - 1) {\n\t\t\t\t\t// 情况 B:本卷结束了,去找下一卷的第一章\n\t\t\t\t\tconst nextVolData = parsedVolumes[vIndex + 1];\n\t\t\t\t\tif (nextVolData) {\n\t\t\t\t\t\tif (nextVolData.chapterEls.length > 0) {\n\t\t\t\t\t\t\tconst potentialNextEl = nextVolData.chapterEls[0];\n\t\t\t\t\t\t\tif (potentialNextEl) {\n\t\t\t\t\t\t\t\tnextChapterEl = potentialNextEl;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// 如果找到了合法的下一章,扔进任务清单\n\t\t\t\tif (nextChapterEl) {\n\t\t\t\t\tfixTasks.push({\n\t\t\t\t\t\tchapter: chapterObj, // JS 对象引用,后续直接修改 id\n\t\t\t\t\t\tnextChapterEl,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvolumes.push({\n\t\t\tid: vData.volumeId,\n\t\t\tplatform: \"linovelib\",\n\t\t\ttitle: vData.volumeName,\n\t\t\tcoverUrl: vData.volumeCover,\n\t\t\tchapters: chapters,\n\t\t});\n\t}\n\n\t// --- 第二步:集中并发/队列处理,回填数据 ---\n\tif (fixTasks.length > 0 && chapterQueue) {\n\t\t// 使用 Promise.all 配合你的 p-queue (concurrency=1)\n\t\tawait Promise.all(\n\t\t\tfixTasks.map(async (task) => {\n\t\t\t\t// 此时推入 MQ,由 MQ 内部控制并发率和流控\n\t\t\t\tconst realId = await parseChapterIdFromNextChapter(\n\t\t\t\t\ttask.nextChapterEl,\n\t\t\t\t\tchapterQueue,\n\t\t\t\t);\n\t\t\t\tif (realId) {\n\t\t\t\t\ttask.chapter.id = realId; // 利用引用直接修改 volumes 数组内部的值\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn volumes;\n}\n\nexport async function getNovelInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Novel | undefined> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tconst title = $(\"h1.book-name\").text().trim();\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\tconst summary = (() => {\n\t\tconst $container = $(\".book-dec.Jbook-dec\").clone();\n\t\t$container.find(\".notice\").remove();\n\t\tconst paragraphs: string[] = [];\n\t\t$container\n\t\t\t.find(\"p\")\n\t\t\t.not(\".backupname\")\n\t\t\t.each((_, el) => {\n\t\t\t\tparagraphs.push($(el).text().trim());\n\t\t\t});\n\t\treturn paragraphs.join(\"\\n\");\n\t})();\n\tconst author = $(\"div.au-name a:first\").text().trim();\n\tconst status: NovelStatus = $(\"div.book-label a.state\")\n\t\t.text()\n\t\t.includes(\"完结\")\n\t\t? \"completed\"\n\t\t: \"ongoing\";\n\tconst genres = $(\"div.book-label span\")\n\t\t.children(\"a\")\n\t\t.map((_, el) => $(el).text())\n\t\t.toArray()\n\t\t.join(\",\");\n\tconst novel: Novel = {\n\t\tid,\n\t\tplatform: \"linovelib\",\n\t\ttitle,\n\t\tcoverUrl,\n\t\tsummary,\n\t\tauthor,\n\t\tstatus,\n\t\tgenres: genres.split(\",\").map((g) => g.trim()),\n\t\tvolumes: [], // Volumes and chapters will be fetched separately\n\t};\n\tnovel.volumes = (\n\t\tawait getNovelVolumes(\n\t\t\ttitle,\n\t\t\t`https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`,\n\t\t\tfetchClient,\n\t\t\tretry,\n\t\t\tchapterQueue,\n\t\t)\n\t).map((v) => {\n\t\tv.novelId = novel.id;\n\t\treturn v;\n\t});\n\treturn novel;\n}\n\nexport interface NovelUpdateInfo {\n\tcoverUrl: string;\n\tchapterCount: number;\n}\n\nexport async function getUpdateInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n): Promise<NovelUpdateInfo | null> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tif ($(\"h1.book-name\").length === 0) {\n\t\treturn null;\n\t}\n\tconst catalogUrl = `https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`;\n\tconst catalogHtml = (\n\t\tawait fetchClient.text(catalogUrl, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $catalog = cheerio.load(catalogHtml);\n\tconst chapterCount = $catalog(\n\t\t\"#volume-list div.volume ul.chapter-list li a\",\n\t).length;\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn {\n\t\tcoverUrl,\n\t\tchapterCount,\n\t};\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport { load } from \"cheerio\";\nimport { extractVolumesArray, parseVolumeOrChapterId } from \"./novel\";\n\nexport function novelIdToCoverUrl(novelId: string): string {\n\tconst prefix = novelId.length > 3 ? novelId[0] : \"0\";\n\treturn `https://www.linovelib.com/files/article/image/${prefix}/${novelId}/${novelId}s.jpg`;\n}\n\nexport async function getNovelCoverUrl(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst novelUrl = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = await fetchClient.text(novelUrl);\n\tconst $ = load(html.data);\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn coverUrl;\n}\n\nexport async function getVolumeCoverUrl(\n\tid: string,\n\tnovelId: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst catalogUrl = `https://www.linovelib.com/novel/${novelId}/catalog`;\n\tconst html = await fetchClient.text(catalogUrl);\n\tconst $ = load(html.data);\n\tconst volumes = extractVolumesArray(html.data);\n\tconst volume = volumes.find((v) => {\n\t\tconst volumeId = parseVolumeOrChapterId(\n\t\t\t$(v).find(\"h2 a\").attr(\"href\") ?? \"\",\n\t\t);\n\t\treturn volumeId === id;\n\t});\n\tif (!volume) {\n\t\tthrow new Error(`Volume not found for ID: ${id}`);\n\t}\n\tconst coverUrl =\n\t\t$(volume).find(\"a.volume-cover img\").attr(\"data-original\") || \"\";\n\treturn coverUrl;\n}\n","import {\n\ttype BrowserFetchClient,\n\tCloudflareBlockError,\n\tdefaultRetryPolicy,\n\ttype RetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Novel } from \"@acanthis-dec/core\";\nimport PQueue from \"p-queue\";\nimport type { Logger } from \"winston\";\nimport { getNovelInfo, getUpdateInfo, type NovelUpdateInfo } from \"./novel\";\n\n/**\n * Simple backoff strategy for request rate limiting\n * - Normal delay: 500-1000ms random\n * - Failure delay: 8000ms (8 seconds)\n */\nclass SimpleBackoff {\n\treadonly NORMAL_DELAY_MIN = 500;\n\treadonly NORMAL_DELAY_MAX = 1000;\n\treadonly FAILURE_DELAY = 15000;\n\n\t/**\n\t * Get delay for normal (successful) operation\n\t * @returns Random delay in range [500, 1000]ms. If isMobile is true, returns random delay in range [2000, 5000]ms\n\t */\n\tgetDelayForSuccess(): number {\n\t\treturn (\n\t\t\tthis.NORMAL_DELAY_MIN +\n\t\t\tMath.random() * (this.NORMAL_DELAY_MAX - this.NORMAL_DELAY_MIN)\n\t\t);\n\t}\n}\n\nexport class NovelChapterQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.logger = logger;\n\t\tthis.queue.addEventListener(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.addEventListener(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchChapterPart(url: string): Promise<string> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelChapterQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)(?:_(\\d+))?\\.html/);\n\t\t\tif (!match) {\n\t\t\t\tthrow new Error(`Invalid chapter URL: ${url}`);\n\t\t\t}\n\t\t\tconst novelId = match[1];\n\t\t\tconst chapterId = match[2];\n\t\t\tconst partId = match[3] || \"1\";\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 开始获取小说${novelId}章节${chapterId}的第${partId}部分内容`,\n\t\t\t);\n\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst content = (await this.client.text(url, { retry })).data ?? \"\";\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。`,\n\t\t\t);\n\t\t\treturn content;\n\t\t});\n\t}\n}\n\nexport class NovelInfoQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate chapterQueue: NovelChapterQueue;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(\n\t\tclient: BrowserFetchClient,\n\t\tchapterQueue: NovelChapterQueue,\n\t\tlogger?: Logger,\n\t) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.chapterQueue = chapterQueue;\n\t\tthis.logger = logger;\n\t\tthis.queue.addEventListener(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.addEventListener(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchNovelInfo(id: string): Promise<Novel> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的信息`);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst novel = await getNovelInfo(\n\t\t\t\tid,\n\t\t\t\tthis.client,\n\t\t\t\tretry,\n\t\t\t\tthis.chapterQueue,\n\t\t\t);\n\t\t\tif (!novel) {\n\t\t\t\tthrow new Error(`无法获取小说信息: ${id}`);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 小说${id} 信息获取成功。`);\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn novel;\n\t\t});\n\t}\n\n\tasync fetchNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 开始获取小说${id}的更新信息(封面和章节数)`,\n\t\t\t);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst updateInfo = await getUpdateInfo(id, this.client, retry);\n\t\t\tif (!updateInfo) {\n\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t`[NovelInfoQueue] 无法获取小说${id}的更新信息,可能是因为小说不存在或已被删除`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 小说${id} 更新信息获取成功。 封面: ${updateInfo.coverUrl}, 章节数: ${updateInfo.chapterCount}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn updateInfo;\n\t\t});\n\t}\n}\n","import type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport type * as cheerio from \"cheerio\";\nimport { extractNovelIdFromUrl } from \"../utils\";\n\nexport function parseSearchHtml($: cheerio.CheerioAPI): NovelSearchResult[] {\n\tconst results: NovelSearchResult[] = [];\n\t$(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst title = $el.find(\"h2\").text().trim();\n\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\tresults.push({\n\t\t\ttitle,\n\t\t\tplatform: \"linovelib\",\n\t\t\tid,\n\t\t\tcoverUrl,\n\t\t});\n\t});\n\treturn results;\n}\n\nexport function parseBookHtml($: cheerio.CheerioAPI): NovelSearchResult {\n\treturn {\n\t\ttitle: $(\"h1.book-name\").text().trim(),\n\t\tplatform: \"linovelib\",\n\t\tid: extractNovelIdFromUrl($(\"meta[name=url]\").attr(\"content\") ?? \"\") || \"\",\n\t\tcoverUrl: $(\"div.book-img img\").attr(\"src\") || \"\",\n\t};\n}\n","import { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { decode as decodePng } from \"fast-png\";\nimport type { InferenceSession } from \"onnxruntime-node\";\n\nconst MODEL_FILENAME = \"captcha_cropped.onnx\";\nconst TARGET_HEIGHT = 64;\nconst CHARSET = [\n\t\"\",\n\t...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\",\n];\n\nlet sessionPromise: Promise<InferenceSession> | undefined;\n\nfunction moduleDirectory(): string {\n\treturn fileURLToPath(new URL(\".\", import.meta.url));\n}\n\n/**\n * 模型可能出现的几个位置:\n * - 环境变量显式指定(部署时最可靠)\n * - 与当前模块同级(api-server 打包后把模型拷到 dist 目录)\n * - 包内 dist/../assets(npm 发布形态 / linovelib tsdown 产物)\n * - 包内 src/search/../../assets(workspace 内直接执行 TS 源码)\n * - 进程工作目录(Docker 镜像内 /app/captcha_cropped.onnx)\n */\nfunction resolveModelPath(): string {\n\tconst candidates = [\n\t\tprocess.env.LINOVELIB_CAPTCHA_MODEL_PATH,\n\t\tjoin(moduleDirectory(), MODEL_FILENAME),\n\t\tjoin(moduleDirectory(), \"..\", \"assets\", MODEL_FILENAME),\n\t\tjoin(moduleDirectory(), \"..\", \"..\", \"assets\", MODEL_FILENAME),\n\t\tjoin(process.cwd(), MODEL_FILENAME),\n\t].filter((candidate): candidate is string => Boolean(candidate));\n\n\tfor (const candidate of candidates) {\n\t\tif (existsSync(candidate)) return candidate;\n\t}\n\n\tthrow new Error(\n\t\t`无法找到搜索验证码识别模型 ${MODEL_FILENAME},尝试过的路径: ${candidates.join(\", \")}`,\n\t);\n}\n\nasync function getSession(): Promise<InferenceSession> {\n\tif (!sessionPromise) {\n\t\tsessionPromise = (async () => {\n\t\t\tconst ort = await import(\"onnxruntime-node\");\n\t\t\t// 模型输出维度声明为动态,ONNX Runtime 会为 CTC 输出发出无害的 shape 警告,这里静音。\n\t\t\tort.env.logLevel = \"error\";\n\t\t\tconst model = await readFile(resolveModelPath());\n\t\t\treturn await ort.InferenceSession.create(model, {\n\t\t\t\texecutionProviders: [\"cpu\"],\n\t\t\t\tgraphOptimizationLevel: \"all\",\n\t\t\t\tintraOpNumThreads: 1,\n\t\t\t\tinterOpNumThreads: 1,\n\t\t\t});\n\t\t})();\n\t\tsessionPromise.catch(() => {\n\t\t\tsessionPromise = undefined;\n\t\t});\n\t}\n\treturn sessionPromise;\n}\n\ninterface DecodedImage {\n\twidth: number;\n\theight: number;\n\tchannels: number;\n\tdata: Uint8Array;\n}\n\n/**\n * 验证码字符使用高饱和度颜色绘制在浅色噪点背景上。\n * 直接转灰度会让部分颜色的字符与背景对比度不足,因此同时尝试多种通道变换,\n * 让模型对同一张图投票,可以明显降低误识别率。\n */\nfunction channelVariants(image: DecodedImage): Uint8Array[] {\n\tconst { width, height, channels, data } = image;\n\tconst total = width * height;\n\tconst saturation = new Uint8Array(total);\n\tconst maxChannel = new Uint8Array(total);\n\tconst minChannel = new Uint8Array(total);\n\n\tfor (let i = 0; i < total; i++) {\n\t\tconst offset = i * channels;\n\t\tconst r = data[offset] ?? 0;\n\t\tconst g = data[offset + 1] ?? r;\n\t\tconst b = data[offset + 2] ?? g;\n\t\tconst max = Math.max(r, g, b);\n\t\tconst min = Math.min(r, g, b);\n\t\tsaturation[i] = max - min;\n\t\tmaxChannel[i] = max;\n\t\tminChannel[i] = min;\n\t}\n\n\treturn [saturation, maxChannel, minChannel];\n}\n\nfunction resizeBilinear(\n\tsource: Uint8Array,\n\tsourceWidth: number,\n\tsourceHeight: number,\n\ttargetWidth: number,\n\ttargetHeight: number,\n): Uint8Array {\n\tconst output = new Uint8Array(targetWidth * targetHeight);\n\tconst scaleX = sourceWidth / targetWidth;\n\tconst scaleY = sourceHeight / targetHeight;\n\n\tfor (let y = 0; y < targetHeight; y++) {\n\t\tconst sourceY = Math.min(\n\t\t\tsourceHeight - 1,\n\t\t\tMath.max(0, (y + 0.5) * scaleY - 0.5),\n\t\t);\n\t\tconst y0 = Math.floor(sourceY);\n\t\tconst y1 = Math.min(sourceHeight - 1, y0 + 1);\n\t\tconst weightY = sourceY - y0;\n\n\t\tfor (let x = 0; x < targetWidth; x++) {\n\t\t\tconst sourceX = Math.min(\n\t\t\t\tsourceWidth - 1,\n\t\t\t\tMath.max(0, (x + 0.5) * scaleX - 0.5),\n\t\t\t);\n\t\t\tconst x0 = Math.floor(sourceX);\n\t\t\tconst x1 = Math.min(sourceWidth - 1, x0 + 1);\n\t\t\tconst weightX = sourceX - x0;\n\n\t\t\tconst topLeft = source[y0 * sourceWidth + x0] ?? 0;\n\t\t\tconst topRight = source[y0 * sourceWidth + x1] ?? topLeft;\n\t\t\tconst bottomLeft = source[y1 * sourceWidth + x0] ?? topLeft;\n\t\t\tconst bottomRight = source[y1 * sourceWidth + x1] ?? bottomLeft;\n\n\t\t\tconst top = topLeft + (topRight - topLeft) * weightX;\n\t\t\tconst bottom = bottomLeft + (bottomRight - bottomLeft) * weightX;\n\t\t\toutput[y * targetWidth + x] = Math.round(top + (bottom - top) * weightY);\n\t\t}\n\t}\n\n\treturn output;\n}\n\ninterface DecodedText {\n\ttext: string;\n\t/** CTC 每步最大概率的平均值,用于在多个通道变体之间择优。 */\n\tconfidence: number;\n}\n\nfunction decodeCtcOutput(\n\tdata: Float32Array,\n\tdims: readonly number[],\n): DecodedText {\n\tconst steps = dims[0] ?? 0;\n\tconst classes = dims[dims.length - 1] ?? 0;\n\tlet text = \"\";\n\tlet previous = -1;\n\tlet confidenceSum = 0;\n\n\tfor (let step = 0; step < steps; step++) {\n\t\tconst offset = step * classes;\n\t\tlet bestIndex = 0;\n\t\tlet bestValue = Number.NEGATIVE_INFINITY;\n\t\tfor (let index = 0; index < classes; index++) {\n\t\t\tconst value = data[offset + index] ?? Number.NEGATIVE_INFINITY;\n\t\t\tif (value > bestValue) {\n\t\t\t\tbestValue = value;\n\t\t\t\tbestIndex = index;\n\t\t\t}\n\t\t}\n\n\t\t// 对当前时间步做 softmax,取最大概率作为该步置信度。\n\t\tlet expSum = 0;\n\t\tfor (let index = 0; index < classes; index++) {\n\t\t\texpSum += Math.exp((data[offset + index] ?? 0) - bestValue);\n\t\t}\n\t\tconfidenceSum += expSum > 0 ? 1 / expSum : 0;\n\n\t\tif (bestIndex !== previous && bestIndex !== 0) {\n\t\t\ttext += CHARSET[bestIndex] ?? \"\";\n\t\t}\n\t\tprevious = bestIndex;\n\t}\n\n\treturn {\n\t\ttext,\n\t\tconfidence: steps > 0 ? confidenceSum / steps : 0,\n\t};\n}\n\nfunction chooseBest(decoded: DecodedText[]): DecodedText {\n\tconst fourCharacter = decoded.filter((item) => item.text.length === 4);\n\tif (fourCharacter.length === 0) {\n\t\treturn decoded.reduce((best, item) =>\n\t\t\titem.confidence > best.confidence ? item : best,\n\t\t);\n\t}\n\n\tconst votes = new Map<string, { count: number; confidence: number }>();\n\tfor (const item of fourCharacter) {\n\t\tconst current = votes.get(item.text);\n\t\tif (current) {\n\t\t\tcurrent.count += 1;\n\t\t\tcurrent.confidence = Math.max(current.confidence, item.confidence);\n\t\t} else {\n\t\t\tvotes.set(item.text, { count: 1, confidence: item.confidence });\n\t\t}\n\t}\n\n\tlet winner = fourCharacter[0] as DecodedText;\n\tlet winnerCount = -1;\n\tlet winnerConfidence = -1;\n\tfor (const [text, vote] of votes) {\n\t\tif (\n\t\t\tvote.count > winnerCount ||\n\t\t\t(vote.count === winnerCount && vote.confidence > winnerConfidence)\n\t\t) {\n\t\t\twinner = { text, confidence: vote.confidence };\n\t\t\twinnerCount = vote.count;\n\t\t\twinnerConfidence = vote.confidence;\n\t\t}\n\t}\n\treturn winner;\n}\n\n/**\n * 识别 linovelib 搜索验证码(4 位数字/字母图片)。\n * 使用 ddddocr 的 common_old 裁剪模型(MIT),见 assets/THIRD-PARTY-NOTICES.md。\n */\nexport async function solveCaptcha(\n\timage: Buffer | Uint8Array,\n): Promise<string> {\n\tconst decoded = decodePng(image) as unknown as DecodedImage;\n\tconst targetWidth = Math.round(\n\t\t(decoded.width * TARGET_HEIGHT) / decoded.height,\n\t);\n\tconst ort = await import(\"onnxruntime-node\");\n\tconst session = await getSession();\n\tconst inputName = session.inputNames[0];\n\tconst outputName = session.outputNames[0];\n\tif (!inputName || !outputName) {\n\t\tthrow new Error(\"验证码识别模型缺少输入或输出节点\");\n\t}\n\n\tconst decodedTexts: DecodedText[] = [];\n\tfor (const variant of channelVariants(decoded)) {\n\t\tconst resized = resizeBilinear(\n\t\t\tvariant,\n\t\t\tdecoded.width,\n\t\t\tdecoded.height,\n\t\t\ttargetWidth,\n\t\t\tTARGET_HEIGHT,\n\t\t);\n\t\tconst input = new Float32Array(resized.length);\n\t\tfor (let i = 0; i < resized.length; i++) {\n\t\t\tinput[i] = (resized[i] ?? 0) / 255;\n\t\t}\n\n\t\tconst result = await session.run({\n\t\t\t[inputName]: new ort.Tensor(\"float32\", input, [\n\t\t\t\t1,\n\t\t\t\t1,\n\t\t\t\tTARGET_HEIGHT,\n\t\t\t\ttargetWidth,\n\t\t\t]),\n\t\t});\n\t\tconst output = result[outputName];\n\t\tif (!output) {\n\t\t\tthrow new Error(\"验证码识别模型没有返回结果\");\n\t\t}\n\t\tdecodedTexts.push(\n\t\t\tdecodeCtcOutput(\n\t\t\t\toutput.data as Float32Array,\n\t\t\t\toutput.dims as readonly number[],\n\t\t\t),\n\t\t);\n\t}\n\n\tif (decodedTexts.length === 0) {\n\t\tthrow new Error(\"验证码识别失败:没有任何可用结果\");\n\t}\n\treturn chooseBest(decodedTexts).text;\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport { Mutex } from \"async-mutex\";\nimport { load } from \"cheerio\";\nimport { solveCaptcha } from \"./captcha\";\nimport { parseBookHtml, parseSearchHtml } from \"./common\";\n\nconst SEARCH_URL = \"https://www.linovelib.com/S6/\";\nconst ORIGIN = \"https://www.linovelib.com\";\n\n/** 站点要求两次搜索 POST 之间至少间隔 5 秒,这里留一点余量。 */\nconst MIN_SEARCH_INTERVAL_MS = 5200;\nconst MAX_VERIFICATION_ATTEMPTS = 3;\nconst MAX_RATE_LIMIT_ATTEMPTS = 3;\nconst NEXT_PAGE_DELAY_MIN_MS = 300;\nconst NEXT_PAGE_DELAY_MAX_MS = 800;\n\nconst searchRequestHeaders = {\n\torigin: ORIGIN,\n\treferer: `${ORIGIN}/`,\n};\n\nconst searchRefererHeaders = {\n\torigin: ORIGIN,\n\treferer: SEARCH_URL,\n};\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction isVerificationPage(html: string): boolean {\n\treturn (\n\t\thtml.includes('name=\"search_challenge\"') ||\n\t\thtml.includes(\"<title>搜索验证</title>\")\n\t);\n}\n\nfunction isRateLimitedPage(html: string): boolean {\n\treturn html.includes(\"两次搜索的间隔时间不得少于\");\n}\n\nfunction isBookPage(html: string): boolean {\n\treturn html.includes(\"book-html-box\");\n}\n\n/** 搜索验证流程无法自动完成时抛出,便于上层区分站点验证码问题。 */\nexport class SearchVerificationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SearchVerificationError\";\n\t}\n}\n\nexport class SearchRateLimitError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SearchRateLimitError\";\n\t}\n}\n\n/**\n * 新版搜索会话。\n *\n * 站点现状(2026-11):\n * - 未验证客户端 POST/GET 搜索页会返回「搜索验证」图片验证码页;\n * - 提交正确验证码后服务端会下发约 30 分钟有效的验证 cookie,期间搜索免验证;\n * - 两次搜索间隔不得少于 5 秒,否则返回错误页;\n * - 验证过期后任意搜索/翻页请求都会重新出现验证码页。\n *\n * 该类负责串行化搜索请求、维护最小搜索间隔、自动识别并提交验证码,并复用验证态。\n */\nexport class SearchSession {\n\tprivate readonly mutex = new Mutex();\n\tprivate lastSearchAt = 0;\n\n\tconstructor(private readonly fetchClient: BrowserFetchClient) {}\n\n\tasync search(keyword: string): Promise<NovelSearchResult[]> {\n\t\treturn await this.mutex.runExclusive(async () => {\n\t\t\tconst html = await this.requestSearch(keyword);\n\t\t\treturn await this.parseResults(html);\n\t\t});\n\t}\n\n\tprivate async parseResults(html: string): Promise<NovelSearchResult[]> {\n\t\tconst $ = load(html);\n\t\tif (isBookPage(html) && $(\"div.book-html-box\").length > 0) {\n\t\t\treturn [parseBookHtml($)];\n\t\t}\n\n\t\tconst results = parseSearchHtml($);\n\t\tconst totalPages = Number(\n\t\t\t$(\"em#pagestats\")\n\t\t\t\t.text()\n\t\t\t\t.match(/1\\/(\\d+)/)?.[1] ?? \"1\",\n\t\t);\n\t\tconst nextHref = $(\"a.next\").attr(\"href\");\n\t\tif (totalPages > 1 && nextHref) {\n\t\t\tresults.push(...(await this.collectNextPages(nextHref)));\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate async collectNextPages(\n\t\tstartHref: string,\n\t): Promise<NovelSearchResult[]> {\n\t\tconst results: NovelSearchResult[] = [];\n\t\tlet href: string | undefined = startHref;\n\n\t\twhile (href) {\n\t\t\tconst delay =\n\t\t\t\tNEXT_PAGE_DELAY_MIN_MS +\n\t\t\t\tMath.random() * (NEXT_PAGE_DELAY_MAX_MS - NEXT_PAGE_DELAY_MIN_MS);\n\t\t\tawait sleep(delay);\n\n\t\t\tconst html = await this.fetchPage(new URL(href, SEARCH_URL).toString());\n\t\t\tconst $ = load(html);\n\t\t\tresults.push(...parseSearchHtml($));\n\t\t\thref = $(\"a.next\").attr(\"href\") || undefined;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tprivate async fetchPage(url: string): Promise<string> {\n\t\tlet response = await this.fetchClient.text(url, {\n\t\t\theaders: searchRefererHeaders,\n\t\t});\n\t\tif (response.mimeType !== \"text/html\") {\n\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t}\n\t\tif (isVerificationPage(response.data)) {\n\t\t\t// 验证态过期:先完成验证,再重新获取目标页(验证响应固定是关键词第一页)。\n\t\t\tawait this.verifySearch(response.data);\n\t\t\tresponse = await this.fetchClient.text(url, {\n\t\t\t\theaders: searchRefererHeaders,\n\t\t\t});\n\t\t\tif (response.mimeType !== \"text/html\") {\n\t\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t\t}\n\t\t\tif (isVerificationPage(response.data)) {\n\t\t\t\tthrow new SearchVerificationError(\"搜索验证后翻页仍被要求验证\");\n\t\t\t}\n\t\t}\n\t\tif (response.data === \"\") {\n\t\t\tthrow new Error(\"Empty response body when fetching search page\");\n\t\t}\n\t\treturn response.data;\n\t}\n\n\tprivate async requestSearch(keyword: string): Promise<string> {\n\t\tfor (let attempt = 0; attempt < MAX_RATE_LIMIT_ATTEMPTS; attempt++) {\n\t\t\tawait this.waitForSearchSlot();\n\t\t\tconst response = await this.fetchClient.text(SEARCH_URL, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tsearchkey: keyword,\n\t\t\t\t}),\n\t\t\t\theaders: searchRequestHeaders,\n\t\t\t});\n\t\t\tthis.lastSearchAt = Date.now();\n\n\t\t\tif (response.mimeType !== \"text/html\") {\n\t\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t\t}\n\t\t\tif (response.data === \"\") {\n\t\t\t\tthrow new Error(\"Empty response body when fetching search results\");\n\t\t\t}\n\t\t\tif (isRateLimitedPage(response.data)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (isVerificationPage(response.data)) {\n\t\t\t\treturn await this.verifySearch(response.data);\n\t\t\t}\n\t\t\treturn response.data;\n\t\t}\n\n\t\tthrow new SearchRateLimitError(\n\t\t\t`搜索请求被站点限流,已重试 ${MAX_RATE_LIMIT_ATTEMPTS} 次`,\n\t\t);\n\t}\n\n\tprivate async verifySearch(verificationHtml: string): Promise<string> {\n\t\tlet currentHtml = verificationHtml;\n\n\t\tfor (let attempt = 0; attempt < MAX_VERIFICATION_ATTEMPTS; attempt++) {\n\t\t\tconst $ = load(currentHtml);\n\t\t\tconst challenge = $(\"input[name=search_challenge]\").attr(\"value\");\n\t\t\tconst searchkey = $(\"input[name=searchkey]\").attr(\"value\");\n\t\t\tconst searchtype = $(\"input[name=searchtype]\").attr(\"value\") ?? \"all\";\n\t\t\tconst imageSrc = $(\"#search-captcha\").attr(\"src\");\n\n\t\t\tif (!challenge || !imageSrc || !searchkey) {\n\t\t\t\tthrow new SearchVerificationError(\"无法解析搜索验证码页面\");\n\t\t\t}\n\n\t\t\tconst image = await this.fetchClient.binary(\n\t\t\t\tnew URL(imageSrc, SEARCH_URL).toString(),\n\t\t\t\t{ headers: searchRefererHeaders },\n\t\t\t);\n\t\t\tif (!image.mimeType.startsWith(\"image/\")) {\n\t\t\t\tthrow new SearchVerificationError(\n\t\t\t\t\t`验证码图片响应类型异常: ${image.mimeType}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet code: string;\n\t\t\ttry {\n\t\t\t\tcode = await solveCaptcha(image.data);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new SearchVerificationError(\n\t\t\t\t\t`验证码识别失败: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.waitForSearchSlot();\n\t\t\tconst response = await this.fetchClient.text(SEARCH_URL, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tsearchkey,\n\t\t\t\t\tsearchtype,\n\t\t\t\t\tsearch_challenge: challenge,\n\t\t\t\t\tsearch_code: code,\n\t\t\t\t}),\n\t\t\t\theaders: searchRefererHeaders,\n\t\t\t});\n\t\t\tthis.lastSearchAt = Date.now();\n\n\t\t\tif (response.mimeType !== \"text/html\") {\n\t\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t\t}\n\n\t\t\tif (!isVerificationPage(response.data)) {\n\t\t\t\treturn response.data;\n\t\t\t}\n\t\t\t// 验证码错误或过期,页面会带上一张新的验证码,换一张重试。\n\t\t\tcurrentHtml = response.data;\n\t\t}\n\n\t\tthrow new SearchVerificationError(\n\t\t\t`搜索验证码连续识别失败(已尝试 ${MAX_VERIFICATION_ATTEMPTS} 次)`,\n\t\t);\n\t}\n\n\tprivate async waitForSearchSlot(): Promise<void> {\n\t\tconst elapsed = Date.now() - this.lastSearchAt;\n\t\tif (elapsed < MIN_SEARCH_INTERVAL_MS) {\n\t\t\tawait sleep(MIN_SEARCH_INTERVAL_MS - elapsed);\n\t\t}\n\t}\n}\n\nexport async function searchNovelsV3(\n\tkeyword: string,\n\t_fetchClient: BrowserFetchClient,\n\tsession: SearchSession,\n): Promise<NovelSearchResult[]> {\n\treturn await session.search(keyword);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\n\nexport interface LoginConfig {\n\tusername: string;\n\tpassword: string;\n}\n\nexport async function refreshSessionId(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tawait fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php\",\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tconst response = await fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php?do=submit&jumpurl=https%3A%2F%2Fwww.linovelib.com%2F\",\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tusername: loginConfig.username,\n\t\t\tpassword: loginConfig.password,\n\t\t\tusecookie: \"3153600000\",\n\t\t\tsubmit: \"登录\",\n\t\t\taction: \"login\",\n\t\t}),\n\t\tfollowRedirects: false,\n\t});\n\treturn (\n\t\tresponse.cookies.findIndex((cookie) => cookie.name === \"PHPSESSID\") !== -1\n\t);\n}\n\nexport async function hasValidSession(\n\tfetchClient: BrowserFetchClient,\n): Promise<boolean> {\n\tconst response = await fetchClient.text(\"https://www.linovelib.com\");\n\tif (response.data.includes(\"用户中心\")) return true;\n\telse return false;\n}\n\nexport async function ensureValidSession(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tif (!(await hasValidSession(fetchClient))) {\n\t\tconst isValid =\n\t\t\t(await refreshSessionId(fetchClient, loginConfig)) &&\n\t\t\t(await hasValidSession(fetchClient));\n\t\tif (!isValid) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import {\n\ttype BinaryResponse,\n\tBrowserFetchClient,\n\ttype BrowserFetchClientOptions,\n\ttype BrowserProfileName,\n\ttype FlareSolverrOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type {\n\tDescrambleCoefficients,\n\tNovel,\n\tNovelSearchResult,\n} from \"@acanthis-dec/core\";\nimport type { StorageService } from \"@acanthis-dec/storage\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport type { Logger } from \"winston\";\nimport z from \"zod\";\nimport { getChapter } from \"./chapter\";\nimport { descrambleCoefficientsSchema } from \"./coefficients\";\nimport { getVolumeCoverUrl, novelIdToCoverUrl } from \"./cover\";\nimport type { NovelUpdateInfo } from \"./novel\";\nimport { NovelChapterQueue, NovelInfoQueue } from \"./queue\";\nimport { SearchSession, searchNovels } from \"./search\";\nimport { ensureValidSession } from \"./session\";\n\nexport type SessionOptions =\n\t| {\n\t\t\tenabled: false;\n\t }\n\t| {\n\t\t\tenabled: true;\n\t\t\tusername: string;\n\t\t\tpassword: string;\n\t };\n\nexport type ImpersonateOptions =\n\t| {\n\t\t\tenabled: true;\n\t\t\tprofile: BrowserProfileName;\n\t }\n\t| {\n\t\t\tenabled: false;\n\t };\n\nexport type CookieStoreOptions =\n\t| {\n\t\t\ttype: \"memory\" | \"database\";\n\t }\n\t| {\n\t\t\ttype: \"file\";\n\t\t\tpath: string;\n\t };\n\nexport type LinovelibClientOptions = {\n\tsession: SessionOptions;\n\tflareSolverr: FlareSolverrOptions;\n\timpersonate: ImpersonateOptions;\n\tcookies: CookieStoreOptions;\n\tproxy?: string | undefined;\n};\n\nexport class LinovelibClient {\n\tprivate storage?: StorageService | undefined;\n\tprivate fetchClient: BrowserFetchClient;\n\tprivate novelChapterQueue: NovelChapterQueue;\n\tprivate novelInfoQueue: NovelInfoQueue;\n\tprivate searchSession: SearchSession;\n\tprivate options?: LinovelibClientOptions;\n\tprivate logger?: Logger | undefined;\n\tprivate isSessionValid?: boolean = undefined;\n\n\tconstructor(\n\t\toptions?: LinovelibClientOptions,\n\t\tstorage?: StorageService,\n\t\tlogger?: Logger,\n\t) {\n\t\tconst defaultOptions: LinovelibClientOptions = {\n\t\t\tsession: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tflareSolverr: {\n\t\t\t\tenabled: true,\n\t\t\t\thost: \"http://localhost:8191\",\n\t\t\t\ttimeoutMs: 60000,\n\t\t\t\tsessionId: \"acanthis-linovelib-client\",\n\t\t\t},\n\t\t\timpersonate: {\n\t\t\t\tenabled: true,\n\t\t\t\tprofile: \"chrome-latest-linux\",\n\t\t\t},\n\t\t\tcookies: {\n\t\t\t\ttype: \"memory\",\n\t\t\t},\n\t\t};\n\t\tthis.options = deepmerge(\n\t\t\tdefaultOptions,\n\t\t\toptions ?? {},\n\t\t) as LinovelibClientOptions;\n\t\tthis.storage = storage;\n\t\tthis.logger = logger;\n\t\tconst browserFetchOptions: BrowserFetchClientOptions = {};\n\t\tif (this.options?.flareSolverr.enabled) {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: true,\n\t\t\t\thost: this.options.flareSolverr.host,\n\t\t\t\ttimeoutMs: this.options.flareSolverr.timeoutMs ?? 60000,\n\t\t\t\tsessionId:\n\t\t\t\t\tthis.options.flareSolverr.sessionId ?? \"acanthis-linovelib-client\",\n\t\t\t};\n\t\t} else {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\t\tif (this.options?.proxy) {\n\t\t\tbrowserFetchOptions.proxy = this.options.proxy;\n\t\t}\n\t\tif (this.options?.impersonate.enabled) {\n\t\t\tbrowserFetchOptions.profile = this.options.impersonate.profile;\n\t\t}\n\t\tswitch (this.options?.cookies.type) {\n\t\t\tcase \"memory\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tpath: this.options.cookies.path,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"database\":\n\t\t\t\tif (!this.storage) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"StorageService is required for database cookie store\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\tstore: this.storage.getCookieStore(),\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t}\n\t\tthis.fetchClient = new BrowserFetchClient(browserFetchOptions);\n\t\tthis.novelChapterQueue = new NovelChapterQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.novelInfoQueue = new NovelInfoQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.searchSession = new SearchSession(this.fetchClient);\n\t}\n\n\tasync getNovelInfo(id: string): Promise<Novel | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelInfo(id);\n\t}\n\n\tasync getNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelUpdateInfo(id);\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await searchNovels(keyword, this.fetchClient, this.searchSession);\n\t}\n\n\tasync getNovelCover(\n\t\tid: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await novelIdToCoverUrl(id);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${id}.html`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getVolumeCover(\n\t\tnovelId: string,\n\t\tvolumeId: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await getVolumeCoverUrl(\n\t\t\tvolumeId,\n\t\t\tnovelId,\n\t\t\tthis.fetchClient,\n\t\t);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${novelId}/catalog`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getCover(url: string, referer?: string): Promise<BinaryResponse> {\n\t\treturn await this.fetchClient.binary(url, {\n\t\t\theaders: {\n\t\t\t\tReferer: referer || \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t}\n\n\tasync getChapter(\n\t\tnovelId: string,\n\t\tchapterId: string,\n\t): Promise<string | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst cachedJsVersion = this.storage\n\t\t\t? ((await this.storage.getCache(\"chapterlog_js_version\", z.string())) ??\n\t\t\t\tundefined)\n\t\t\t: undefined;\n\t\tconst cachedCoefficients = this.storage\n\t\t\t? ((await this.storage.getCache<DescrambleCoefficients>(\n\t\t\t\t\t\"coefficients\",\n\t\t\t\t\tdescrambleCoefficientsSchema,\n\t\t\t\t)) ?? undefined)\n\t\t\t: undefined;\n\t\tconst result = await getChapter(\n\t\t\tchapterId,\n\t\t\tnovelId,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.fetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tif (this.storage && result) {\n\t\t\tawait this.storage.setCache(\"chapterlog_js_version\", result.version);\n\t\t\tawait this.storage.setCache(\"coefficients\", result.coefficients);\n\t\t}\n\t\treturn result?.content;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAWA,MAAM,WACJ,eAA6D,WAC9D;AAED,MAAa,+BAA+BA,IAAE,OAAO;CACpD,SAASA,IAAE,OAAO,CAAC,CAAC,IAAI;CACxB,WAAWA,IAAE,OAAO,CAAC,CAAC,IAAI;CAC1B,YAAYA,IAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,YAAYA,IAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,gBAAgBA,IAAE,OAAO,CAAC,CAAC,IAAI;AAChC,CAAC;AAED,SAAS,kBAAkB,UAA0B;CACpD,OAAO,SACL,MAAM,OAAO,CAAC,CACd,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,QAAQ,SAAS,SAAS,EAAE,CAAC,CAC7B,MAAM,EAAE,CAAC,CACT,KAAK,IAAI;AACZ;AAEA,eAAsB,oBACrB,QACkC;CAClC,MAAM,iBAAiB,kBAAkB,MAAM;CAC/C,MAAM,YAAY,MAAM,YAAY,cAAc;CAClD,MAAM,MAAM,MAAM,WAAW;EAAE,YAAY;EAAU,SAAS,CAAC,KAAK;CAAE,CAAC;CACvE,MAAM,eAAgD,CAAC;CACvD,SAAS,KAAK,EACb,iBA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AQ;EAChC,CAAC;EAEF,MAAM,WAAW,MAAM,kBACtB,UACA,SACA,KAAK,WACN;EAKA,OAAO;GAAE,MAAM,MAJS,KAAK,SAC5B,UACA,mCAAmC,QAAQ,SAC5C;GAC0B,KAAK;EAAS;CACzC;CAEA,MAAM,SAAS,KAAa,SAA2C;EACtE,OAAO,MAAM,KAAK,YAAY,OAAO,KAAK,EACzC,SAAS,EACR,SAAS,WAAW,6BACrB,EACD,CAAC;CACF;CAEA,MAAM,WACL,SACA,WAC8B;EAC9B,IAAI,KAAK,SAAS,QAAQ,WAAW,CAAC,KAAK,gBAC1C,KAAK,iBAAiB,MAAM,mBAAmB,KAAK,aAAa;GAChE,UAAU,KAAK,QAAQ,QAAQ;GAC/B,UAAU,KAAK,QAAQ,QAAQ;EAChC,CAAC;EAEF,MAAM,kBAAkB,KAAK,UACxB,MAAM,KAAK,QAAQ,SAAS,yBAAyB,EAAE,OAAO,CAAC,KAClE,KAAA,IACC,KAAA;EACH,MAAM,qBAAqB,KAAK,UAC3B,MAAM,KAAK,QAAQ,SACrB,gBACA,4BACD,KAAM,KAAA,IACL,KAAA;EACH,MAAM,SAAS,MAAM,WACpB,WACA,SACA,KAAK,mBACL,KAAK,aACL,iBACA,kBACD;EACA,IAAI,KAAK,WAAW,QAAQ;GAC3B,MAAM,KAAK,QAAQ,SAAS,yBAAyB,OAAO,OAAO;GACnE,MAAM,KAAK,QAAQ,SAAS,gBAAgB,OAAO,YAAY;EAChE;EACA,OAAO,QAAQ;CAChB;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acanthis-dec/linovelib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "An Acanthis adapter for Linovelib site.",
|
|
5
5
|
"author": "ConstasJ <constasj@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
+
"assets",
|
|
16
17
|
"package.json",
|
|
17
18
|
"README.md",
|
|
18
19
|
"README.zh-CN.md"
|
|
@@ -26,29 +27,31 @@
|
|
|
26
27
|
"url": "https://github.com/ConstasJ/Acanthis/issues"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
30
|
+
"@acanthis-dec/browser-fetch": "1.1.2",
|
|
31
|
+
"@acanthis-dec/core": "1.1.0",
|
|
32
|
+
"@acanthis-dec/deobfuscator": "1.0.2",
|
|
33
|
+
"@acanthis-dec/storage": "1.0.8",
|
|
34
|
+
"@babel/parser": "^8.1.2",
|
|
35
|
+
"@babel/traverse": "^8.1.2",
|
|
36
|
+
"@babel/types": "^8.1.2",
|
|
32
37
|
"async-mutex": "^0.5.0",
|
|
33
38
|
"cheerio": "^1.2.0",
|
|
34
|
-
"deepmerge-ts": "^
|
|
35
|
-
"
|
|
39
|
+
"deepmerge-ts": "^8.0.2",
|
|
40
|
+
"fast-png": "^8.0.0",
|
|
41
|
+
"onnxruntime-node": "^1.31.1",
|
|
42
|
+
"p-queue": "^10.0.0",
|
|
36
43
|
"winston": "^3.19.0",
|
|
37
|
-
"zod": "^4.
|
|
38
|
-
"@acanthis-dec/browser-fetch": "1.1.1",
|
|
39
|
-
"@acanthis-dec/core": "1.1.0",
|
|
40
|
-
"@acanthis-dec/deobfuscator": "1.0.2",
|
|
41
|
-
"@acanthis-dec/storage": "1.0.7"
|
|
44
|
+
"zod": "^4.6.7"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
47
|
+
"@acanthis-dec/config-tsdown": "1.0.0",
|
|
48
|
+
"@acanthis-dec/config-typescript": "1.0.0",
|
|
44
49
|
"@types/babel__traverse": "^7.28.0",
|
|
45
|
-
"@types/node": "
|
|
50
|
+
"@types/node": "26.6.6",
|
|
46
51
|
"domhandler": "^6.0.1",
|
|
47
|
-
"tsdown": "0.
|
|
48
|
-
"tsx": "4.
|
|
49
|
-
"typescript": "
|
|
50
|
-
"@acanthis-dec/config-tsdown": "1.0.0",
|
|
51
|
-
"@acanthis-dec/config-typescript": "1.0.0"
|
|
52
|
+
"tsdown": "0.23.7",
|
|
53
|
+
"tsx": "4.23.15",
|
|
54
|
+
"typescript": "7.0.2"
|
|
52
55
|
},
|
|
53
56
|
"scripts": {
|
|
54
57
|
"build": "tsdown",
|