yz-yuki-plugin 2.0.6-7 → 2.0.6-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.
@@ -7,7 +7,8 @@ import { readSyncCookie, cookieWithBiliTicket } from './bilibili.main.models.js'
7
7
  async function getWebId(uid) {
8
8
  const w_webid_key = 'Yz:yuki:bili:w_webid';
9
9
  const w_webid = await Redis.get(w_webid_key);
10
- if (w_webid) {
10
+ const keyTTL = await Redis.ttl(w_webid_key);
11
+ if (w_webid && keyTTL < 259200) {
11
12
  return String(w_webid);
12
13
  }
13
14
  else {
@@ -28,8 +29,10 @@ async function getWebId(uid) {
28
29
  const decoded__RENDER_DATA__JsonString = decodeURIComponent(__RENDER_DATA__[1]);
29
30
  const accessIdRegex = /"access_id":"(.*?)"/;
30
31
  const access_id = decoded__RENDER_DATA__JsonString.match(accessIdRegex);
31
- if (access_id && access_id[1]) {
32
- await Redis.set(w_webid_key, access_id[1], { EX: 43197 * 1000 });
32
+ const ExpirationTimeRegex = /document.getElementById\("__RENDER_DATA__"\).*?setTimeout\(function\(\)\s*{window.location.reload\(true\);},\s*(\d+)\s*\*\s*(\d+)\);<\/script>/;
33
+ const ExpirationTime = htmlContent.match(ExpirationTimeRegex);
34
+ if (access_id && access_id[1] && ExpirationTime && ExpirationTime[1]) {
35
+ await Redis.set(w_webid_key, access_id[1], { EX: Number(ExpirationTime[1]) });
33
36
  return String(access_id[1]);
34
37
  }
35
38
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.6-7",
3
+ "version": "2.0.6-8",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",
@@ -107,6 +107,6 @@
107
107
  "registry": "https://registry.npmjs.org"
108
108
  },
109
109
  "engines": {
110
- "node": ">=16.14.0"
110
+ "node": ">=20"
111
111
  }
112
112
  }