yz-yuki-plugin 2.0.9-1 → 2.0.9-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.
@@ -34,7 +34,8 @@ class WeiboWebDataFetcher {
34
34
  'Host': 'm.weibo.cn',
35
35
  'X-XSRF-TOKEN': `${X_XSRF_TOKEN}`,
36
36
  'Referer': `https://m.weibo.cn/u/${uid}`
37
- })
37
+ }),
38
+ responseType: 'json'
38
39
  });
39
40
  // (3) 获取请求完成后的 Cookie 状态
40
41
  const updatedCookies = await new Promise((resolve, reject) => {
@@ -83,7 +84,8 @@ class WeiboWebDataFetcher {
83
84
  headers: lodash.merge(WeiboApi.WEIBO_HEADERS, {
84
85
  'X-XSRF-TOKEN': `${X_XSRF_TOKEN}`,
85
86
  'Referer': 'https://m.weibo.cn/search?'
86
- })
87
+ }),
88
+ responseType: 'json'
87
89
  });
88
90
  // (3) 获取请求完成后的 Cookie 状态
89
91
  const updatedCookies = await new Promise((resolve, reject) => {
@@ -135,7 +137,8 @@ class WeiboWebDataFetcher {
135
137
  'Host': 'm.weibo.cn',
136
138
  'X-XSRF-TOKEN': `${X_XSRF_TOKEN}`,
137
139
  'referer': `https://m.weibo.cn/u/${uid}`
138
- })
140
+ }),
141
+ responseType: 'json'
139
142
  });
140
143
  const { ok, data, msg } = response?.data;
141
144
  if (!ok && msg !== '这里还没有内容') {
@@ -162,7 +165,7 @@ class WeiboWebDataFetcher {
162
165
  await WeiboCookieManager.saveCookiesToRedis(jar); // 更新同步到 Redis
163
166
  }
164
167
  }
165
- return data.cards.filter(WeiboQuery.filterCardTypeCustom);
168
+ return data?.cards.filter(WeiboQuery.filterCardTypeCustom);
166
169
  }
167
170
  catch (error) {
168
171
  logger?.mark('微博推送:Error fetching sub list:', error);
@@ -519,15 +519,15 @@ class WeiboRiskCookie {
519
519
  // 计算 TTL(秒)
520
520
  let ttl = 0;
521
521
  const ttlInMs = cookie.TTL ? cookie.TTL() : 0; // TTL 返回毫秒,可能不存在
522
- if (ttlInMs > 0) {
522
+ if (ttlInMs && ttlInMs > 0 && isFinite(ttlInMs)) {
523
523
  ttl = Math.floor(ttlInMs / 1000);
524
524
  }
525
- else if (ttlInMs === 0) {
525
+ else if (ttlInMs === 0 || !isFinite(ttlInMs)) {
526
526
  // 已过期,跳过
527
527
  continue;
528
528
  }
529
529
  else {
530
- ttl = -1; // 永不过期
530
+ ttl = -1;
531
531
  }
532
532
  // 构造元数据
533
533
  const meta = JSON.stringify({
@@ -537,13 +537,13 @@ class WeiboRiskCookie {
537
537
  });
538
538
  // 写入 Redis(使用 TTL 时一并写 meta)
539
539
  try {
540
- if (ttl && ttl > 0) {
540
+ if ((ttl && ttl > 0) || ttl === -1) {
541
541
  await Redis.set(redisKey, cookie.value, { EX: ttl });
542
542
  await Redis.set(`${redisKey}:meta`, meta, { EX: ttl });
543
543
  }
544
544
  else {
545
- await Redis.set(redisKey, cookie.value);
546
- await Redis.set(`${redisKey}:meta`, meta);
545
+ await Redis.set(redisKey, cookie.value, { EX: -1 });
546
+ await Redis.set(`${redisKey}:meta`, meta, { EX: -1 });
547
547
  }
548
548
  }
549
549
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.9-1",
3
+ "version": "2.0.9-2",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",