tt-help-cli-ycl 1.4.130 → 1.4.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-help-cli-ycl",
3
- "version": "1.4.130",
3
+ "version": "1.4.131",
4
4
  "description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli/attach.js CHANGED
@@ -389,7 +389,12 @@ export async function handleAttach(options) {
389
389
  MAX_CDN_COOLDOWN_SEC,
390
390
  );
391
391
  const shouldSwitch = consecutiveCdnBlocks <= MAX_CDN_SWITCH_ATTEMPTS;
392
- if (shouldSwitch) {
392
+ if (!scraper) {
393
+ // webserver 模式:限流发生在远端 webserver 出口,本地切节点无效,仅冷却等待
394
+ attachLog(
395
+ ` [Attach] CDN限流比例 ${(cdnRatio * 100).toFixed(0)}% (${cdnBlockedCount}/${tasks.length}),webserver 模式不切节点,冷却 ${coolDownSeconds} 秒...`,
396
+ );
397
+ } else if (shouldSwitch) {
393
398
  // 用现有 IPC 接口通知 daemon 从候选集切下一个健康节点(换 IP 绕过 CDN 限流)
394
399
  try {
395
400
  writeCommand({
@@ -429,18 +429,25 @@ export async function handlePrecheck(options) {
429
429
  const cdnRatio =
430
430
  candidates.length > 0 ? cdnBlockedCount / candidates.length : 0;
431
431
  if (cdnRatio > 0.3) {
432
- // 用现有 IPC 接口通知 daemon 从候选集切下一个健康节点(换 IP 绕过 CDN 限流)
433
- try {
434
- writeCommand({
435
- action: "failover",
436
- reason: `precheck CDN限流 (${(cdnRatio * 100).toFixed(0)}%)`,
437
- });
438
- } catch {}
439
432
  // 切换节点后新 IP 生效需短暂等待,冷却可缩短(替代纯硬等 120s)
440
433
  const coolDownSeconds = cdnRatio > 0.8 ? 90 : 60;
441
- precheckLog(
442
- ` [Precheck] CDN限流比例 ${(cdnRatio * 100).toFixed(0)}% (${cdnBlockedCount}/${candidates.length}),已通知 daemon 切换节点,冷却 ${coolDownSeconds} 秒...`,
443
- );
434
+ if (scraper) {
435
+ // 本地模式:用现有 IPC 接口通知 daemon 从候选集切下一个健康节点(换 IP 绕过 CDN 限流)
436
+ try {
437
+ writeCommand({
438
+ action: "failover",
439
+ reason: `precheck CDN限流 (${(cdnRatio * 100).toFixed(0)}%)`,
440
+ });
441
+ } catch {}
442
+ precheckLog(
443
+ ` [Precheck] CDN限流比例 ${(cdnRatio * 100).toFixed(0)}% (${cdnBlockedCount}/${candidates.length}),已通知 daemon 切换节点,冷却 ${coolDownSeconds} 秒...`,
444
+ );
445
+ } else {
446
+ // webserver 模式:限流发生在远端 webserver 出口,本地切节点无效,仅冷却等待
447
+ precheckLog(
448
+ ` [Precheck] CDN限流比例 ${(cdnRatio * 100).toFixed(0)}% (${cdnBlockedCount}/${candidates.length}),webserver 模式不切节点,冷却 ${coolDownSeconds} 秒...`,
449
+ );
450
+ }
444
451
  await new Promise((r) => setTimeout(r, coolDownSeconds * 1000));
445
452
  if (scraper) {
446
453
  await recycleScraper(
@@ -103,6 +103,15 @@ function isCollectorCommand(cmdDef) {
103
103
  return COLLECTOR_KEYWORDS.some((k) => s.includes(k));
104
104
  }
105
105
 
106
+ /**
107
+ * 检测命令是否运行在 webserver 模式(不启动本地浏览器,抓取由远端集中完成)。
108
+ * 该模式下限流/网络错误发生在远端 webserver 出口,本地切换节点无法解决,
109
+ * 因此错误触发切换统计应排除此类进程。
110
+ */
111
+ function isWebserverMode(cmdDef) {
112
+ return /--webserver(?=\s|=|$)/.test(cmdDef?.command || "");
113
+ }
114
+
106
115
  /** 自动发现 daemon.js 路径 */
107
116
  function findDaemonPath() {
108
117
  // 1. 内部打包路径优先(npm publish 后 src/clash/daemon.js,升级即最新)
@@ -388,6 +397,8 @@ export class WatchdogAgent {
388
397
  let failoverTriggered = false; // 本轮是否已触发全局切换
389
398
  for (const { cmdId, cmdDef, newErrors } of scanned) {
390
399
  if (!isCollectorCommand(cmdDef)) continue;
400
+ // webserver 模式:错误发生在远端出口,本地切节点无法解决,不计入错误触发统计
401
+ if (isWebserverMode(cmdDef)) continue;
391
402
  let st = this._errorStates.get(cmdId) || {
392
403
  consecutive: 0,
393
404
  firstErrorAt: 0,