yz-yuki-plugin 2.0.7-5 → 2.0.7-6

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.
@@ -4,7 +4,6 @@ import BiliApi from './bilibili.main.api.js';
4
4
  import { readSyncCookie, cookieWithBiliTicket, readSavedCookieItems, readSavedCookieOtherItems } from './bilibili.main.models.js';
5
5
  import { getWbiSign } from './bilibili.risk.wbi.js';
6
6
  import { getDmImg } from './bilibili.risk.dm.img.js';
7
- import { getWebId } from './bilibili.risk.w_webid.js';
8
7
 
9
8
  class BilibiliWebDataFetcher {
10
9
  e;
@@ -52,20 +51,17 @@ class BilibiliWebDataFetcher {
52
51
  let { cookie } = await readSyncCookie();
53
52
  cookie = await cookieWithBiliTicket(cookie);
54
53
  const dmImg = await getDmImg();
55
- const w_webid = await getWebId(uid);
56
54
  const data = {
57
55
  mid: uid,
58
56
  token: '',
59
57
  platform: 'web',
60
58
  web_location: 1550101,
61
- ...dmImg,
62
- w_webid: w_webid
59
+ ...dmImg
63
60
  };
64
61
  let signCookie = (await readSavedCookieItems(cookie, ['SESSDATA'], false)) || (await readSavedCookieOtherItems(cookie, ['SESSDATA']));
65
62
  const { w_rid, time_stamp } = await getWbiSign(data, BiliApi.BILIBILI_HEADERS, signCookie);
66
63
  const params = {
67
64
  ...data,
68
- w_webid: w_webid,
69
65
  w_rid: w_rid,
70
66
  wts: time_stamp
71
67
  };
@@ -1,16 +1,16 @@
1
1
  /**获取dm参数 */
2
2
  async function getDmImg() {
3
- const dm_img_list = [];
3
+ const dm_img_list = `[]`;
4
4
  //Buffer.from("WebGL 1", 'utf-8').toString("base64") //webgl version的值 WebGL 1 的base64 编码
5
5
  const dm_img_str = 'V2ViR0wgMS';
6
6
  //webgl unmasked renderer的值拼接webgl unmasked vendor的值的base64编码
7
7
  const dm_cover_img_str = 'QU5HTEUgKEludGVsLCBJbnRlbChSKSBIRCBHcmFwaGljcyBEaXJlY3QzRDExIHZzXzVfMCBwc181XzApLCBvciBzaW1pbGFyR29vZ2xlIEluYy4gKEludGVsKQ';
8
- const dm_img_inter = { ds: [], wh: [0, 0, 0], of: [0, 0, 0] };
8
+ const dm_img_inter = `{ds:[],wh:[0,0,0],of:[0,0,0]}`;
9
9
  return {
10
- dm_img_list: String(dm_img_list).replace(/\s+/g, ''),
10
+ dm_img_list: dm_img_list,
11
11
  dm_img_str: dm_img_str,
12
12
  dm_cover_img_str: dm_cover_img_str,
13
- dm_img_inter: String(dm_img_inter).replace(/\s+/g, '')
13
+ dm_img_inter: dm_img_inter
14
14
  };
15
15
  }
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.7-5",
3
+ "version": "2.0.7-6",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",
@@ -1,46 +0,0 @@
1
- import axios from 'axios';
2
- import lodash from 'lodash';
3
- import { Redis } from 'yunzaijs';
4
- import BiliApi from './bilibili.main.api.js';
5
- import { readSyncCookie, cookieWithBiliTicket } from './bilibili.main.models.js';
6
-
7
- async function getWebId(uid) {
8
- const w_webid_key = 'Yz:yuki:bili:w_webid';
9
- const w_webid = await Redis.get(w_webid_key);
10
- const keyTTL = await Redis.ttl(w_webid_key);
11
- if (w_webid && keyTTL < 259200) {
12
- return String(w_webid);
13
- }
14
- else {
15
- const url = `https://space.bilibili.com/${uid ? uid : 401742377}/dynamic`;
16
- let { cookie } = await readSyncCookie();
17
- cookie = await cookieWithBiliTicket(cookie);
18
- const res = await axios.get(url, {
19
- timeout: 8000,
20
- headers: lodash.merge(BiliApi.BILIBILI_DYNAMIC_SPACE_HEADERS, {
21
- Cookie: `${cookie}`,
22
- Host: `space.bilibili.com`
23
- })
24
- });
25
- const htmlContent = await res.data;
26
- const htmlContentRegex = /="__RENDER_DATA__"\s*type="application\/json">(.*?)<\/script>/;
27
- const __RENDER_DATA__ = htmlContent.match(htmlContentRegex);
28
- if (__RENDER_DATA__ && __RENDER_DATA__[1]) {
29
- const decoded__RENDER_DATA__JsonString = decodeURIComponent(__RENDER_DATA__[1]);
30
- const accessIdRegex = /"access_id":"(.*?)"/;
31
- const access_id = decoded__RENDER_DATA__JsonString.match(accessIdRegex);
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]) });
36
- return String(access_id[1]);
37
- }
38
- else {
39
- console.error('Failed to get access_id from __RENDER_DATA__');
40
- return null;
41
- }
42
- }
43
- }
44
- }
45
-
46
- export { getWebId };