yz-yuki-plugin 2.0.5-7 → 2.0.5-9
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.
|
@@ -6,7 +6,7 @@ class BiliApi {
|
|
|
6
6
|
biliUpFollowFans: `https://api.bilibili.com/x/relation/stat`,
|
|
7
7
|
//通过uid获取up详情 parama = { mid: uid, jsonp: jsonp }
|
|
8
8
|
biliSpaceUserInfo: `https://api.bilibili.com/x/space/acc/info`,
|
|
9
|
-
//parama = { mid: uid,
|
|
9
|
+
//parama = { mid: uid, token: '',platform: 'web', web_location: 1550101, w_webid, w_rid, wts }
|
|
10
10
|
biliSpaceUserInfoWbi: `https://api.bilibili.com/x/space/wbi/acc/info`,
|
|
11
11
|
//通过关键词${upKeyword}搜索up主 parama = { keyword: 'upKeyword', page: 1, search_type: 'bili_user', order: 'totalrank', pagesize: 5 }
|
|
12
12
|
biliSearchUp: `https://api.bilibili.com/x/web-interface/search/type`,
|
|
@@ -18,12 +18,13 @@ class BiliApi {
|
|
|
18
18
|
biliLiveUserInfo: 'https://api.live.bilibili.com/live_user/v1/Master/info',
|
|
19
19
|
biliOpusDetail: 'https://api.bilibili.com/x/polymer/web-dynamic/v1/opus/detail'
|
|
20
20
|
};
|
|
21
|
+
static BILIBILI_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36';
|
|
21
22
|
/**header */
|
|
22
23
|
static BILIBILI_HEADERS = {
|
|
23
24
|
'Accept': '*/*',
|
|
24
|
-
'Accept-Language': 'zh-CN,
|
|
25
|
-
'
|
|
26
|
-
'
|
|
25
|
+
'Accept-Language': 'zh-CN,en-US;q=0.5',
|
|
26
|
+
'Connection': 'keep-alive',
|
|
27
|
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
27
28
|
'Cookie': '',
|
|
28
29
|
'pragma': 'no-cache',
|
|
29
30
|
'Cache-control': 'max-age=0',
|
|
@@ -35,15 +36,15 @@ class BiliApi {
|
|
|
35
36
|
'Sec-Fetch-Mode': 'cors',
|
|
36
37
|
'Sec-Fetch-Site': 'same-site',
|
|
37
38
|
'Sec-Fetch-User': '?0',
|
|
39
|
+
'Priority': 'u=4',
|
|
38
40
|
'TE': 'trailers',
|
|
39
|
-
'
|
|
40
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0'
|
|
41
|
+
'User-Agent': this.BILIBILI_USER_AGENT
|
|
41
42
|
};
|
|
42
43
|
/**Login header */
|
|
43
44
|
static BIlIBILI_LOGIN_HEADERS = {
|
|
44
45
|
'Accept': '*/*',
|
|
45
|
-
'Accept-Language': 'zh-CN,
|
|
46
|
-
'Accept-Encoding': 'gzip, deflate, br',
|
|
46
|
+
'Accept-Language': 'zh-CN,en-US;q=0.5',
|
|
47
|
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
47
48
|
'DNT': '1',
|
|
48
49
|
'Sec-GPC': '1',
|
|
49
50
|
'Upgrade-Insecure-Requests': '1',
|
|
@@ -56,8 +57,8 @@ class BiliApi {
|
|
|
56
57
|
/**FullArticle header */
|
|
57
58
|
static BILIBILI_ARTICLE_HEADERS = {
|
|
58
59
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8',
|
|
59
|
-
'Accept-Language': 'zh-CN,
|
|
60
|
-
'Accept-Encoding': 'gzip, deflate, br',
|
|
60
|
+
'Accept-Language': 'zh-CN,en-US;q=0.5',
|
|
61
|
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
61
62
|
'Content-type': 'text/html; charset=utf-8',
|
|
62
63
|
'Cookie': '',
|
|
63
64
|
'pragma': 'no-cache',
|
|
@@ -71,7 +72,21 @@ class BiliApi {
|
|
|
71
72
|
'Sec-Fetch-User': '?1',
|
|
72
73
|
'TE': 'trailers',
|
|
73
74
|
'Upgrade-Insecure-Requests': '1',
|
|
74
|
-
'User-Agent':
|
|
75
|
+
'User-Agent': this.BILIBILI_USER_AGENT
|
|
76
|
+
};
|
|
77
|
+
static BILIBILI_DYNAMIC_SPACE_HEADERS = {
|
|
78
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
79
|
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
80
|
+
'Accept-Language': 'zh-CN,en-US;q=0.5',
|
|
81
|
+
'Connection': 'keep-alive',
|
|
82
|
+
'Priority': 'u=0, i',
|
|
83
|
+
'Sec-Fetch-Dest': 'document',
|
|
84
|
+
'Sec-Fetch-Mode': 'navigate',
|
|
85
|
+
'Sec-Fetch-Site': 'none',
|
|
86
|
+
'Sec-Fetch-User': '?1',
|
|
87
|
+
'Sec-GPC': '1',
|
|
88
|
+
'Upgrade-Insecure-Requests': '1',
|
|
89
|
+
'User-Agent': this.BILIBILI_USER_AGENT
|
|
75
90
|
};
|
|
76
91
|
}
|
|
77
92
|
|
|
@@ -5,10 +5,12 @@ async function getDmImg() {
|
|
|
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
9
|
return {
|
|
9
10
|
dm_img_list: dm_img_list,
|
|
10
11
|
dm_img_str: dm_img_str,
|
|
11
|
-
dm_cover_img_str: dm_cover_img_str
|
|
12
|
+
dm_cover_img_str: dm_cover_img_str,
|
|
13
|
+
dm_img_inter: dm_img_inter
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
|
|
@@ -4,6 +4,7 @@ import { BiliApi } from './bilibili.api.js';
|
|
|
4
4
|
import { readSyncCookie, cookieWithBiliTicket, readSavedCookieItems, readSavedCookieOtherItems } from './bilibili.models.js';
|
|
5
5
|
import { getWbiSign } from './bilibili.wbi.js';
|
|
6
6
|
import { getDmImg } from './bilibili.dm.img.js';
|
|
7
|
+
import { getWebId } from './bilibili.w_webid.js';
|
|
7
8
|
|
|
8
9
|
class BiliGetWebData {
|
|
9
10
|
constructor(e) { }
|
|
@@ -18,7 +19,7 @@ class BiliGetWebData {
|
|
|
18
19
|
'host_mid': uid,
|
|
19
20
|
'timezone_offset': -480,
|
|
20
21
|
'platform': 'web',
|
|
21
|
-
'features': 'itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote',
|
|
22
|
+
'features': 'itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote,decorationCard,forwardListHidden,ugcDelete,onlyfansQaCard',
|
|
22
23
|
'web_location': '333.999',
|
|
23
24
|
...dmImg,
|
|
24
25
|
'x-bili-device-req-json': { platform: 'web', device: 'pc' },
|
|
@@ -37,8 +38,8 @@ class BiliGetWebData {
|
|
|
37
38
|
headers: lodash.merge(BiliApi.BILIBILI_HEADERS, {
|
|
38
39
|
Cookie: `${cookie}`,
|
|
39
40
|
Host: `api.bilibili.com`,
|
|
40
|
-
Origin: 'https://
|
|
41
|
-
Referer: `https://
|
|
41
|
+
Origin: 'https://space.bilibili.com',
|
|
42
|
+
Referer: `https://space.bilibili.com/${uid}/dynamic`
|
|
42
43
|
})
|
|
43
44
|
});
|
|
44
45
|
return res;
|
|
@@ -48,14 +49,20 @@ class BiliGetWebData {
|
|
|
48
49
|
const url = BiliApi.BILIBIL_API.biliSpaceUserInfoWbi;
|
|
49
50
|
let { cookie } = await readSyncCookie();
|
|
50
51
|
cookie = await cookieWithBiliTicket(cookie);
|
|
52
|
+
const dmImg = await getDmImg();
|
|
51
53
|
const data = {
|
|
52
54
|
mid: uid,
|
|
53
|
-
|
|
55
|
+
token: '',
|
|
56
|
+
platform: 'web',
|
|
57
|
+
web_location: 1550101,
|
|
58
|
+
...dmImg
|
|
54
59
|
};
|
|
55
60
|
let signCookie = (await readSavedCookieItems(cookie, ['SESSDATA'], false)) || (await readSavedCookieOtherItems(cookie, ['SESSDATA']));
|
|
61
|
+
const w_webid = await getWebId(uid);
|
|
56
62
|
const { w_rid, time_stamp } = await getWbiSign(data, BiliApi.BILIBILI_HEADERS, signCookie);
|
|
57
63
|
const params = {
|
|
58
64
|
...data,
|
|
65
|
+
w_webid: w_webid,
|
|
59
66
|
w_rid: w_rid,
|
|
60
67
|
wts: time_stamp
|
|
61
68
|
};
|
|
@@ -65,8 +72,8 @@ class BiliGetWebData {
|
|
|
65
72
|
headers: lodash.merge(BiliApi.BILIBILI_HEADERS, {
|
|
66
73
|
Cookie: `${cookie}`,
|
|
67
74
|
Host: `api.bilibili.com`,
|
|
68
|
-
Origin: 'https://
|
|
69
|
-
Referer: `https://
|
|
75
|
+
Origin: 'https://space.bilibili.com',
|
|
76
|
+
Referer: `https://space.bilibili.com/${uid}/dynamic`
|
|
70
77
|
})
|
|
71
78
|
});
|
|
72
79
|
return res;
|
|
@@ -22,7 +22,7 @@ class BiliTask {
|
|
|
22
22
|
const resjson = await resp.data;
|
|
23
23
|
if (!resjson || resjson.code !== 0 || resjson.code === -352) {
|
|
24
24
|
await postGateway(cookie);
|
|
25
|
-
if (count <
|
|
25
|
+
if (count < 2) {
|
|
26
26
|
await this.randomDelay(2000, 8000); // 随机延时2-8秒
|
|
27
27
|
await this.hendleEventDynamicData(uid, count + 1);
|
|
28
28
|
logger.error(`获取 ${uid} 动态,Gateway count:${String(count)}`);
|
|
@@ -78,17 +78,17 @@ class BiliTask {
|
|
|
78
78
|
dynamicList[subInfoOfup.uid] = dynamicData;
|
|
79
79
|
}
|
|
80
80
|
else if (resp.code === -352) {
|
|
81
|
-
logger.error(`获取 ${subInfoOfup.uid} 动态失败,resCode:-352
|
|
82
|
-
|
|
81
|
+
logger.error(`获取 ${subInfoOfup.uid} 动态失败,resCode:-352,请待下次任务自动重试`);
|
|
82
|
+
return;
|
|
83
83
|
}
|
|
84
84
|
else if (resp.code !== 0) {
|
|
85
|
-
logger.error(`获取 ${subInfoOfup.uid} 动态失败,resCode:${resp.code}
|
|
86
|
-
|
|
85
|
+
logger.error(`获取 ${subInfoOfup.uid} 动态失败,resCode:${resp.code},请待下次任务自动重试`);
|
|
86
|
+
return;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
90
|
logger.error(`获取 ${subInfoOfup.uid} 动态失败,无响应数据,请待下次任务自动重试`);
|
|
91
|
-
|
|
91
|
+
return;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
const chatIds = Array.from(new Set([...Object((chatTypeMap.get(subInfoOfup.uid) && chatTypeMap.get(subInfoOfup.uid).chatIds) || []), chatId]));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import lodash from 'lodash';
|
|
3
|
+
import { Redis } from 'yunzaijs';
|
|
4
|
+
import { BiliApi } from './bilibili.api.js';
|
|
5
|
+
import { readSyncCookie, cookieWithBiliTicket } from './bilibili.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
|
+
if (w_webid) {
|
|
11
|
+
return w_webid;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const url = `https://space.bilibili.com/${uid ? uid : 401742377}/dynamic`;
|
|
15
|
+
let { cookie } = await readSyncCookie();
|
|
16
|
+
cookie = await cookieWithBiliTicket(cookie);
|
|
17
|
+
const res = await axios.get(url, {
|
|
18
|
+
timeout: 8000,
|
|
19
|
+
headers: lodash.merge(BiliApi.BILIBILI_DYNAMIC_SPACE_HEADERS, {
|
|
20
|
+
Cookie: `${cookie}`,
|
|
21
|
+
Host: `space.bilibili.com`
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
const htmlContent = await res.data;
|
|
25
|
+
const htmlContentRegex = /="__RENDER_DATA__"\s*type="application\/json">(.*?)<\/script>/;
|
|
26
|
+
const __RENDER_DATA__ = htmlContent.match(htmlContentRegex);
|
|
27
|
+
if (__RENDER_DATA__ && __RENDER_DATA__[1]) {
|
|
28
|
+
const decoded__RENDER_DATA__JsonString = decodeURIComponent(__RENDER_DATA__[1]);
|
|
29
|
+
const accessIdRegex = /"access_id":"(.*?)"/;
|
|
30
|
+
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 });
|
|
33
|
+
return access_id[1];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.error('Failed to get access_id from __RENDER_DATA__');
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { getWebId };
|