@cloud411716/fancy-webnovel 0.3.6 → 0.3.8
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
|
@@ -78,8 +78,8 @@ export async function apply(ctx) {
|
|
|
78
78
|
|
|
79
79
|
// ---------- 串行采集 ----------
|
|
80
80
|
let allFiles = [];
|
|
81
|
-
let failed = 0;
|
|
82
81
|
let lastReceipt = null;
|
|
82
|
+
const failedRanks = []; // 收集失败项:{ rank, err }
|
|
83
83
|
|
|
84
84
|
for (const rank of unique) {
|
|
85
85
|
const stop = startActivity(session);
|
|
@@ -108,16 +108,14 @@ export async function apply(ctx) {
|
|
|
108
108
|
);
|
|
109
109
|
return { kind: 'success', text: '' };
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
failed++;
|
|
111
|
+
failedRanks.push({ rank, err: rawErr });
|
|
113
112
|
continue;
|
|
114
113
|
}
|
|
115
114
|
|
|
116
115
|
// 解析采集结果
|
|
117
116
|
let receipt;
|
|
118
117
|
try { receipt = JSON.parse(r.output); } catch (_) {
|
|
119
|
-
|
|
120
|
-
failed++;
|
|
118
|
+
failedRanks.push({ rank, err: 'JSON 解析失败' });
|
|
121
119
|
continue;
|
|
122
120
|
}
|
|
123
121
|
lastReceipt = receipt;
|
|
@@ -143,6 +141,15 @@ export async function apply(ctx) {
|
|
|
143
141
|
llmFollowup(invocation, prompt);
|
|
144
142
|
}
|
|
145
143
|
|
|
144
|
+
// 统一展示所有失败项
|
|
145
|
+
if (failedRanks.length > 0) {
|
|
146
|
+
const lines = failedRanks.map(({ rank, err }) => {
|
|
147
|
+
const label = `${rank.channel}/${rank.type}`;
|
|
148
|
+
return `• ${label}:${err}`;
|
|
149
|
+
});
|
|
150
|
+
notify(session, `⚠️ 以下榜单采集失败(共 ${failedRanks.length} 项):\n${lines.join('\n')}`);
|
|
151
|
+
}
|
|
152
|
+
|
|
146
153
|
return { kind: 'success', text: '' };
|
|
147
154
|
},
|
|
148
155
|
});
|
|
@@ -149,10 +149,17 @@ function spawnScraper(script, extraArgs, outDir) {
|
|
|
149
149
|
let out = '';
|
|
150
150
|
p.stdout.on('data', d => { out += d.toString(); });
|
|
151
151
|
p.on('close', (code) => {
|
|
152
|
-
|
|
152
|
+
const outTrimmed = out.trim();
|
|
153
|
+
// scraper 内部吞掉了很多错误(返回 null 但 exit 0),通过 stdout 里的失败标识判断
|
|
154
|
+
const softFail = outTrimmed.includes('已跳过') ||
|
|
155
|
+
outTrimmed.includes('采集失败') ||
|
|
156
|
+
outTrimmed.includes('✗') ||
|
|
157
|
+
outTrimmed.includes('failed');
|
|
158
|
+
if (code === 0 && !softFail && outTrimmed) {
|
|
153
159
|
resolve({ ok: true, output: out });
|
|
154
160
|
} else {
|
|
155
|
-
|
|
161
|
+
// 把 stdout 末 500 字符当错误摘要
|
|
162
|
+
resolve({ ok: false, output: out, error: outTrimmed.slice(-500) || `exit ${code}` });
|
|
156
163
|
}
|
|
157
164
|
});
|
|
158
165
|
p.on('error', e => resolve({ ok: false, output: '', error: e.message }));
|