smart-image-scraper-mcp 2.11.1 → 2.11.2

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": "smart-image-scraper-mcp",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "description": "全网智能图片抓取 MCP 服务器 - 支持 Bing/Google 图片搜索、验证和下载",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -44,11 +44,11 @@ export class LinkValidator {
44
44
  }
45
45
 
46
46
  const controller = new AbortController();
47
- const timeoutId = setTimeout(() => controller.abort(), 3000); // 超时 3
47
+ const timeoutId = setTimeout(() => controller.abort(), 2000); // 超时 2
48
48
 
49
49
  try {
50
50
  const response = await httpClient.head(url, {
51
- timeout: 2500, // 超时 2.5
51
+ timeout: 1800, // 超时 1.8
52
52
  maxRedirects: 1, // 最多 1 次重定向
53
53
  signal: controller.signal,
54
54
  });
@@ -64,21 +64,12 @@ export class LinkValidator {
64
64
  return { url, valid: true, quality };
65
65
  }
66
66
 
67
- // 某些服务器不支持 HEAD,返回 405/403 时尝试 GET 降级
68
- if (response.status === 405 || response.status === 403) {
69
- return await this._validateWithGet(url, fetchQuality);
70
- }
71
-
72
67
  return { url, valid: false, error: `status=${response.status}` };
73
68
  } catch (error) {
74
69
  clearTimeout(timeoutId);
75
70
  if (!controller.signal.aborted) {
76
71
  controller.abort();
77
72
  }
78
- // 网络错误时也尝试 GET 降级(某些 CDN 完全拒绝 HEAD)
79
- if (error.response && (error.response.status === 405 || error.response.status === 403)) {
80
- return await this._validateWithGet(url, fetchQuality);
81
- }
82
73
  return { url, valid: false, error: 'timeout' };
83
74
  }
84
75
  }
@@ -165,8 +165,10 @@ export class Orchestrator {
165
165
  qualityModeLabel = '快速模式(跳过验证)';
166
166
  logger.info(`[FAST] "${keyword}" - ${resultUrls.length} URLs`);
167
167
  } else {
168
- // balanced 或 high 模式:验证链接
169
- const { valid } = await this.linkValidator.validateMany(rawUrls, {
168
+ // balanced 或 high 模式:验证链接(限制验证数量避免超时)
169
+ const maxValidate = Math.min(rawUrls.length, count * 2 + 5);
170
+ const urlsToValidate = rawUrls.slice(0, maxValidate);
171
+ const { valid } = await this.linkValidator.validateMany(urlsToValidate, {
170
172
  fetchQuality: prioritizeQuality,
171
173
  sortByQuality: prioritizeQuality,
172
174
  minFileSize: minFileSize,
@@ -290,8 +292,9 @@ export class Orchestrator {
290
292
  // 检查是否已中止
291
293
  if (signal?.aborted) throw new Error('操作已取消');
292
294
 
293
- // 根据 quality 模式处理
294
- let urlsToDownload = rawUrls.slice(0, searchCount);
295
+ // 根据 quality 模式处理(限制验证数量避免超时)
296
+ const maxValidate = Math.min(rawUrls.length, count * 2 + 5);
297
+ let urlsToDownload = rawUrls.slice(0, maxValidate);
295
298
  if (prioritizeQuality) {
296
299
  const sortByQuality = qualityMode === 'high';
297
300
  logger.info(`Validating ${urlsToDownload.length} URLs (quality=${qualityMode})...`);