@cloud411716/fancy-webnovel 4.5.0 → 4.6.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/package.json
CHANGED
|
@@ -18,7 +18,6 @@ import { registerCommandWithTasks } from '#task-list';
|
|
|
18
18
|
import { readJsonFile, resolveWorkspace } from '#workspace';
|
|
19
19
|
import { connectMaterial, ensureMaterialDatabase } from '#material-db';
|
|
20
20
|
import { deployMaterialTools } from '../fancy-material/tool-deploy.js';
|
|
21
|
-
import { MATERIAL_KINDS } from '../fancy-material/kinds.js';
|
|
22
21
|
import { makeWaitForTurn } from '../fancy-story-builder/writing-driver.js';
|
|
23
22
|
import { deployDouyinTools } from './deploy.js';
|
|
24
23
|
import {
|
|
@@ -173,6 +172,32 @@ async function runWithLogin(ctx, invocation, session, root, toolPath, args, outD
|
|
|
173
172
|
return { ok: false, error: '连续 ' + LOGIN_RETRIES + ' 次检测到登录/验证,已停止' };
|
|
174
173
|
}
|
|
175
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Recognize the explicit "content is unrelated to webnovel writing" marker.
|
|
177
|
+
* The marker is a single JSON object `{ "skip": true, "reason": "..." }`.
|
|
178
|
+
* It is not a material record and must not be sent to validate/import.
|
|
179
|
+
*/
|
|
180
|
+
export function readSkipMarker(file) {
|
|
181
|
+
let text;
|
|
182
|
+
try {
|
|
183
|
+
text = fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, '').trim();
|
|
184
|
+
} catch {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
if (!text) return null;
|
|
188
|
+
const cleaned = text
|
|
189
|
+
.replace(/^```(?:json)?\s*/i, '')
|
|
190
|
+
.replace(/\s*```$/, '')
|
|
191
|
+
.trim();
|
|
192
|
+
const first = cleaned.split(/\r?\n/).find((line) => line.trim());
|
|
193
|
+
if (!first) return null;
|
|
194
|
+
let record;
|
|
195
|
+
try { record = JSON.parse(first.trim()); } catch { return null; }
|
|
196
|
+
if (!record || typeof record !== 'object' || Array.isArray(record)) return null;
|
|
197
|
+
if (record.skip !== true && String(record.skip).toLowerCase() !== 'true') return null;
|
|
198
|
+
return { reason: String(record.reason || '与网文创作无关').trim() };
|
|
199
|
+
}
|
|
200
|
+
|
|
176
201
|
function normalizeOtherFile(file) {
|
|
177
202
|
const text = fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, '');
|
|
178
203
|
const out = [];
|
|
@@ -271,7 +296,6 @@ async function analyzeNote(ctx, invocation, session, {
|
|
|
271
296
|
screenshots,
|
|
272
297
|
targetFile: target,
|
|
273
298
|
workspace: root,
|
|
274
|
-
materialKinds: MATERIAL_KINDS,
|
|
275
299
|
queryScript: materialTools.queryScript,
|
|
276
300
|
validateScript: materialTools.validateScript,
|
|
277
301
|
});
|
|
@@ -314,6 +338,17 @@ async function analyzeNote(ctx, invocation, session, {
|
|
|
314
338
|
continue;
|
|
315
339
|
}
|
|
316
340
|
|
|
341
|
+
const skip = readSkipMarker(target);
|
|
342
|
+
if (skip) {
|
|
343
|
+
return {
|
|
344
|
+
ok: true,
|
|
345
|
+
skipped: true,
|
|
346
|
+
reason: skip.reason,
|
|
347
|
+
inserted: 0,
|
|
348
|
+
skipped: 0,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
317
352
|
try {
|
|
318
353
|
normalizeOtherFile(target);
|
|
319
354
|
} catch (err) {
|
|
@@ -371,6 +406,7 @@ async function runCrawl(ctx, invocation, session, taskList) {
|
|
|
371
406
|
let foundNotes = 0;
|
|
372
407
|
let skippedNotes = 0;
|
|
373
408
|
let processedNotes = 0;
|
|
409
|
+
let skippedIrrelevant = 0;
|
|
374
410
|
let inserted = 0;
|
|
375
411
|
let skippedMaterials = 0;
|
|
376
412
|
let aborted = false;
|
|
@@ -450,17 +486,32 @@ async function runCrawl(ctx, invocation, session, taskList) {
|
|
|
450
486
|
if (analyzed.fatal) break outer;
|
|
451
487
|
continue;
|
|
452
488
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
489
|
+
if (analyzed.skipped) {
|
|
490
|
+
skippedIrrelevant += 1;
|
|
491
|
+
markCrawled(root, noteId, {
|
|
492
|
+
account_url: account.url,
|
|
493
|
+
url: note.url || card.href,
|
|
494
|
+
title: note.title || card.text || '',
|
|
495
|
+
screenshots: note.screenshots.map((shot) => shot.file),
|
|
496
|
+
dir: noteDir,
|
|
497
|
+
inserted: 0,
|
|
498
|
+
skipped: 0,
|
|
499
|
+
skip: true,
|
|
500
|
+
reason: analyzed.reason || '与网文创作无关',
|
|
501
|
+
});
|
|
502
|
+
} else {
|
|
503
|
+
inserted += analyzed.inserted;
|
|
504
|
+
skippedMaterials += analyzed.skipped;
|
|
505
|
+
markCrawled(root, noteId, {
|
|
506
|
+
account_url: account.url,
|
|
507
|
+
url: note.url || card.href,
|
|
508
|
+
title: note.title || card.text || '',
|
|
509
|
+
screenshots: note.screenshots.map((shot) => shot.file),
|
|
510
|
+
dir: noteDir,
|
|
511
|
+
inserted: analyzed.inserted,
|
|
512
|
+
skipped: analyzed.skipped,
|
|
513
|
+
});
|
|
514
|
+
}
|
|
464
515
|
crawled[noteId] = true;
|
|
465
516
|
if (NOTE_DELAY_MIN_MS < NOTE_DELAY_MAX_MS) {
|
|
466
517
|
const delay = NOTE_DELAY_MIN_MS + Math.floor(Math.random() * (NOTE_DELAY_MAX_MS - NOTE_DELAY_MIN_MS));
|
|
@@ -476,6 +527,7 @@ async function runCrawl(ctx, invocation, session, taskList) {
|
|
|
476
527
|
foundNotes,
|
|
477
528
|
skippedNotes,
|
|
478
529
|
processedNotes,
|
|
530
|
+
skippedIrrelevant,
|
|
479
531
|
inserted,
|
|
480
532
|
skippedMaterials,
|
|
481
533
|
failures,
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
- 账号主页:{{ACCOUNT_URL}}
|
|
6
6
|
- 作品地址:{{NOTE_URL}}
|
|
7
7
|
- 作品标题:{{NOTE_TITLE}}
|
|
8
|
-
- 作品描述:{{NOTE_DESCRIPTION}}
|
|
9
|
-
- 页面正文摘录:{{NOTE_BODY}}
|
|
10
|
-
- 截图目录:`{{NOTE_DIR}}`
|
|
11
8
|
|
|
12
9
|
## 截图
|
|
13
10
|
|
|
@@ -15,18 +12,7 @@
|
|
|
15
12
|
|
|
16
13
|
## 任务
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- 设定、等级体系、世界观规则;
|
|
21
|
-
- 能力、代价、限制、反制;
|
|
22
|
-
- 物品、材料、功能、视觉特征;
|
|
23
|
-
- 地名、势力、组织、身份;
|
|
24
|
-
- 普通怪物、神话生物、神祇、上古凶兽;
|
|
25
|
-
- 人物外形、气质、性格、习惯、说话风格、出身;
|
|
26
|
-
- 场景、天气、感官、描写词;
|
|
27
|
-
- 脑洞、冲突种子、反转、套路。
|
|
28
|
-
|
|
29
|
-
不要复述整篇文案,不要把原图里的整段文字原样抄进来。把内容抽象成一条条可以独立取用的素材。
|
|
15
|
+
分析截图中的内容,如果内容与小说网文创作的设定,素材,写作等无关的话则不进行分析;根据作品信息中的作品标题和截图中内容的排版布局(图片可能使用不同的排版布局对同类别内容进行归类)决定kind,tags,genres三个字段并在note字段中补充一句
|
|
30
16
|
|
|
31
17
|
## 输出文件
|
|
32
18
|
|
|
@@ -45,28 +31,18 @@ id / kind / name / tags / genres / note / source
|
|
|
45
31
|
```
|
|
46
32
|
|
|
47
33
|
- `source` 固定写 `other`。
|
|
48
|
-
- `kind`
|
|
34
|
+
- `kind` 由你根据作品标题和截图内容决定;不受内置列表限制。
|
|
49
35
|
- `tags` 3–8 个短标签。
|
|
50
36
|
- `genres` 1–5 个题材;如果素材同时适配多个题材/标签,把它们都写进去;拿不准就写 `["通用"]`。
|
|
51
37
|
- `note` 可写一句补充,没有就写空字符串。
|
|
52
38
|
- `id` 用小写字母、数字、下划线,格式建议:`<kind>_dy_<作品ID>_<序号>`,全局唯一。
|
|
53
39
|
|
|
54
|
-
|
|
40
|
+
如果判断内容与网文创作无关:不要写任何素材行,只把下面的对象写进同一个文件,然后结束本轮(skip 标记不需要运行校验脚本):
|
|
55
41
|
|
|
56
|
-
```
|
|
57
|
-
{
|
|
42
|
+
```json
|
|
43
|
+
{"skip": true, "reason": "与网文创作无关:<一句话原因>"}
|
|
58
44
|
```
|
|
59
45
|
|
|
60
|
-
## 质量要求
|
|
61
|
-
|
|
62
|
-
- 具体优先:一条素材必须能在 30 秒内变成一个具体画面、动作、规则或人物关系。
|
|
63
|
-
- 拒绝空泛词:不要“火红、耀眼、神秘、强大、古老、传说、绝世”。
|
|
64
|
-
- 命名必须有具体锚点:数字、地名、材质、动作、职业、年代、禁忌、功能或反差。
|
|
65
|
-
- 拒绝“复原眼、章眼、读心手、旧仓单、神秘剑、黑色长刀”这类废名。
|
|
66
|
-
- 一条只写一个细节;机制、代价、限制、反制分开成条。
|
|
67
|
-
- 不要为了凑数复制、换皮或降低质量;宁可不写,也不要写废名。
|
|
68
|
-
- 通常一篇作品提取 5–40 条,按截图实际信息量决定。
|
|
69
|
-
|
|
70
46
|
生成前可以查询已有素材,避免同名:
|
|
71
47
|
|
|
72
48
|
```bash
|
|
@@ -26,14 +26,20 @@ async function collectCards(page) {
|
|
|
26
26
|
const batch = await page.evaluate(() => {
|
|
27
27
|
const rows = [];
|
|
28
28
|
for (const a of document.querySelectorAll('a[href*="/note/"], a[href*="/video/"]')) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// 只收「作品列表」里的卡片:必须是 li > a,并且卡片里有封面图。
|
|
30
|
+
// 账号页底部还有 footer 推荐/友情链接,它们也是 <a href="/note/...">,
|
|
31
|
+
// 但没有 li/img —— 之前会把「这裸考成绩…」这种页脚推荐当成作品。
|
|
32
|
+
const li = a.closest('li');
|
|
33
|
+
if (!li) continue;
|
|
34
|
+
if (a.closest('footer, nav, [role="navigation"]')) continue;
|
|
35
|
+
const img = li.querySelector('img');
|
|
36
|
+
if (!img) continue;
|
|
31
37
|
rows.push({
|
|
32
38
|
href: a.href,
|
|
33
39
|
kind: a.href.includes('/note/') ? 'note' : 'video',
|
|
34
|
-
text: li
|
|
35
|
-
alt: img
|
|
36
|
-
cover: img
|
|
40
|
+
text: li.innerText ? li.innerText.trim().slice(0, 300) : '',
|
|
41
|
+
alt: img.alt ? img.alt : '',
|
|
42
|
+
cover: img.src ? img.src : '',
|
|
37
43
|
});
|
|
38
44
|
}
|
|
39
45
|
return rows;
|
|
@@ -41,6 +47,9 @@ async function collectCards(page) {
|
|
|
41
47
|
const before = cards.size;
|
|
42
48
|
for (const card of batch) {
|
|
43
49
|
const href = normalize(card.href);
|
|
50
|
+
// 第二层保险:页脚/相关推荐的裸链没有封面或 alt,直接丢弃。
|
|
51
|
+
if (!card.alt && !card.cover) continue;
|
|
52
|
+
if (/[?&]source=Baiduspider/i.test(href)) continue;
|
|
44
53
|
if (!cards.has(href)) cards.set(href, { ...card, href });
|
|
45
54
|
}
|
|
46
55
|
log('[scan] round ' + round + ': ' + cards.size + ' cards');
|
|
@@ -21,6 +21,7 @@ export function helpText() {
|
|
|
21
21
|
说明:
|
|
22
22
|
- 只采集 /note/ 图文作品,跳过视频。
|
|
23
23
|
- 每篇作品会下载轮播原图并转成 JPG(不是滚动中的页面截图),然后交给 LLM 提取素材。
|
|
24
|
+
- 如果图文内容与网文创作无关,LLM 会写入 skip 标记,该作品记为已处理并跳过。
|
|
24
25
|
- 素材按 material JSONL 格式写入数据库,source 固定为 other。
|
|
25
26
|
- 已成功入库的作品记录在 <工作区>/.fancy/douyin/crawled.json,后续跳过。
|
|
26
27
|
- 登录态保存在 <工作区>/.fancy/douyin/chrome-profile/,并镜像到 login-state.json。
|
|
@@ -61,7 +62,6 @@ export function analysisPrompt({
|
|
|
61
62
|
screenshots,
|
|
62
63
|
targetFile,
|
|
63
64
|
workspace,
|
|
64
|
-
materialKinds,
|
|
65
65
|
queryScript,
|
|
66
66
|
validateScript,
|
|
67
67
|
}) {
|
|
@@ -73,12 +73,8 @@ export function analysisPrompt({
|
|
|
73
73
|
ACCOUNT_URL: read(accountUrl),
|
|
74
74
|
NOTE_URL: read(note.url),
|
|
75
75
|
NOTE_TITLE: read(note.title, '(无标题)'),
|
|
76
|
-
NOTE_DESCRIPTION: read(note.description, '(无描述)'),
|
|
77
|
-
NOTE_BODY: read(note.body, '(无正文摘录)').slice(0, 3000),
|
|
78
|
-
NOTE_DIR: read(note.dir),
|
|
79
76
|
SCREENSHOT_LIST: list || '(没有截图)',
|
|
80
77
|
TARGET_FILE: targetFile,
|
|
81
|
-
MATERIAL_KINDS: (materialKinds || []).join(', '),
|
|
82
78
|
QUERY_SCRIPT: queryScript,
|
|
83
79
|
VALIDATE_SCRIPT: validateScript,
|
|
84
80
|
WORKSPACE: workspace,
|
|
@@ -96,6 +92,7 @@ export function summaryText({
|
|
|
96
92
|
foundNotes,
|
|
97
93
|
skippedNotes,
|
|
98
94
|
processedNotes,
|
|
95
|
+
skippedIrrelevant = 0,
|
|
99
96
|
inserted,
|
|
100
97
|
skippedMaterials,
|
|
101
98
|
failures,
|
|
@@ -111,6 +108,7 @@ export function summaryText({
|
|
|
111
108
|
'发现图文:' + foundNotes + ' 篇',
|
|
112
109
|
'已处理过并跳过:' + skippedNotes + ' 篇',
|
|
113
110
|
'本次处理:' + processedNotes + ' 篇',
|
|
111
|
+
'无关跳过:' + skippedIrrelevant + ' 篇',
|
|
114
112
|
'新增素材:' + inserted + ' 条(重复跳过 ' + skippedMaterials + ' 条)',
|
|
115
113
|
];
|
|
116
114
|
if (failures.length) {
|