yz-yuki-plugin 2.0.5-9 → 2.0.6-0
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/CHANGELOG.md +6 -0
- package/defaultConfig/bilibili/config.yaml +6 -0
- package/lib/apps/bilibili.js +17 -14
- package/lib/index.js +1 -1
- package/lib/models/bilibili/bilibili.main.api.js +402 -0
- package/lib/models/bilibili/{bilibili.get.web.data.js → bilibili.main.get.web.data.js} +8 -7
- package/lib/models/bilibili/{bilibili.models.js → bilibili.main.models.js} +64 -238
- package/lib/models/bilibili/{bilibili.query.js → bilibili.main.query.js} +24 -23
- package/lib/models/bilibili/{bilibili.task.js → bilibili.main.task.js} +14 -7
- package/lib/models/bilibili/bilibili.risk.buid.fp.js +282 -0
- package/lib/models/bilibili/{bilibili.dm.img.js → bilibili.risk.dm.img.js} +2 -2
- package/lib/models/bilibili/{bilibili.ticket.js → bilibili.risk.ticket.js} +1 -1
- package/lib/models/bilibili/{bilibili.w_webid.js → bilibili.risk.w_webid.js} +4 -4
- package/lib/models/bilibili/bilibili.risk.wbi.js +102 -0
- package/lib/models/weibo/weibo.query.js +17 -19
- package/lib/models/weibo/weibo.task.js +12 -5
- package/package.json +12 -11
- package/lib/models/bilibili/bilibili.api.js +0 -93
- package/lib/models/bilibili/bilibili.buid.fp.js +0 -77
- package/lib/models/bilibili/bilibili.wbi.js +0 -61
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
class BiliApi {
|
|
2
|
-
static BILIBIL_API = {
|
|
3
|
-
//获取动态资源列表 wbi/无wbi parama = { host_mid: uid, timezone_offset: -480, platform: 'web', features: 'itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote', web_location: "333.999", ...getDmImg(), "x-bili-device-req-json": { "platform": "web", "device": "pc" }, "x-bili-web-req-json": { "spm_id": "333.999" }, w_rid, wts }
|
|
4
|
-
biliDynamicInfoList: `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space`,
|
|
5
|
-
//获取关注数与粉丝数 parama = { vmid: uid }
|
|
6
|
-
biliUpFollowFans: `https://api.bilibili.com/x/relation/stat`,
|
|
7
|
-
//通过uid获取up详情 parama = { mid: uid, jsonp: jsonp }
|
|
8
|
-
biliSpaceUserInfo: `https://api.bilibili.com/x/space/acc/info`,
|
|
9
|
-
//parama = { mid: uid, token: '',platform: 'web', web_location: 1550101, w_webid, w_rid, wts }
|
|
10
|
-
biliSpaceUserInfoWbi: `https://api.bilibili.com/x/space/wbi/acc/info`,
|
|
11
|
-
//通过关键词${upKeyword}搜索up主 parama = { keyword: 'upKeyword', page: 1, search_type: 'bili_user', order: 'totalrank', pagesize: 5 }
|
|
12
|
-
biliSearchUp: `https://api.bilibili.com/x/web-interface/search/type`,
|
|
13
|
-
//通过关键词${upKeyword}搜索up主 parama = { keyword: 'upKeyword', page: 1, search_type: 'bili_user', order: 'totalrank' },需要wbi签名
|
|
14
|
-
biliSearchUpWbi: `https://api.bilibili.com/x/web-interface/wbi/search/type`,
|
|
15
|
-
biliLiveStatus: 'https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids',
|
|
16
|
-
biliCard: 'https://api.bilibili.com/x/web-interface/card',
|
|
17
|
-
biliStat: 'https://api.bilibili.com/x/relation/stat',
|
|
18
|
-
biliLiveUserInfo: 'https://api.live.bilibili.com/live_user/v1/Master/info',
|
|
19
|
-
biliOpusDetail: 'https://api.bilibili.com/x/polymer/web-dynamic/v1/opus/detail'
|
|
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';
|
|
22
|
-
/**header */
|
|
23
|
-
static BILIBILI_HEADERS = {
|
|
24
|
-
'Accept': '*/*',
|
|
25
|
-
'Accept-Language': 'zh-CN,en-US;q=0.5',
|
|
26
|
-
'Connection': 'keep-alive',
|
|
27
|
-
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
28
|
-
'Cookie': '',
|
|
29
|
-
'pragma': 'no-cache',
|
|
30
|
-
'Cache-control': 'max-age=0',
|
|
31
|
-
'DNT': '1',
|
|
32
|
-
'Sec-GPC': '1',
|
|
33
|
-
'sec-ch-ua-platform': '',
|
|
34
|
-
'sec-ch-ua-mobile': '?0',
|
|
35
|
-
'Sec-Fetch-Dest': 'empty',
|
|
36
|
-
'Sec-Fetch-Mode': 'cors',
|
|
37
|
-
'Sec-Fetch-Site': 'same-site',
|
|
38
|
-
'Sec-Fetch-User': '?0',
|
|
39
|
-
'Priority': 'u=4',
|
|
40
|
-
'TE': 'trailers',
|
|
41
|
-
'User-Agent': this.BILIBILI_USER_AGENT
|
|
42
|
-
};
|
|
43
|
-
/**Login header */
|
|
44
|
-
static BIlIBILI_LOGIN_HEADERS = {
|
|
45
|
-
'Accept': '*/*',
|
|
46
|
-
'Accept-Language': 'zh-CN,en-US;q=0.5',
|
|
47
|
-
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
48
|
-
'DNT': '1',
|
|
49
|
-
'Sec-GPC': '1',
|
|
50
|
-
'Upgrade-Insecure-Requests': '1',
|
|
51
|
-
'Sec-Fetch-Dest': 'document',
|
|
52
|
-
'Sec-Fetch-Mode': 'navigate',
|
|
53
|
-
'Sec-Fetch-Site': 'none',
|
|
54
|
-
'Sec-Fetch-User': '?1',
|
|
55
|
-
'TE': 'trailers'
|
|
56
|
-
};
|
|
57
|
-
/**FullArticle header */
|
|
58
|
-
static BILIBILI_ARTICLE_HEADERS = {
|
|
59
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8',
|
|
60
|
-
'Accept-Language': 'zh-CN,en-US;q=0.5',
|
|
61
|
-
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
62
|
-
'Content-type': 'text/html; charset=utf-8',
|
|
63
|
-
'Cookie': '',
|
|
64
|
-
'pragma': 'no-cache',
|
|
65
|
-
'Cache-control': 'no-cache',
|
|
66
|
-
'DNT': '1',
|
|
67
|
-
'Sec-GPC': '1',
|
|
68
|
-
'sec-ch-ua-mobile': '?0',
|
|
69
|
-
'Sec-Fetch-Dest': 'document',
|
|
70
|
-
'Sec-Fetch-Mode': 'navigate',
|
|
71
|
-
'Sec-Fetch-Site': 'same-site',
|
|
72
|
-
'Sec-Fetch-User': '?1',
|
|
73
|
-
'TE': 'trailers',
|
|
74
|
-
'Upgrade-Insecure-Requests': '1',
|
|
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
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export { BiliApi };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
class Murmur3 {
|
|
2
|
-
static MOD = 1n << 64n;
|
|
3
|
-
static C1 = 0x87c37b91114253d5n;
|
|
4
|
-
static C2 = 0x4cf5ad432745937fn;
|
|
5
|
-
static C3 = 0x52dce729n;
|
|
6
|
-
static C4 = 0x38495ab5n;
|
|
7
|
-
static R1 = 27n;
|
|
8
|
-
static R2 = 31n;
|
|
9
|
-
static R3 = 33n;
|
|
10
|
-
static M = 5n;
|
|
11
|
-
static hash(source, seed) {
|
|
12
|
-
let h1 = BigInt(seed);
|
|
13
|
-
let h2 = BigInt(seed);
|
|
14
|
-
let processed = 0;
|
|
15
|
-
for (let i = 0; i < source.length; i += 16) {
|
|
16
|
-
const chunk = source.slice(i, i + 16);
|
|
17
|
-
processed += chunk.length;
|
|
18
|
-
if (chunk.length === 16) {
|
|
19
|
-
const k1 = BigInt(chunk.slice(0, 8).reduce((acc, val, idx) => acc | (BigInt(val) << BigInt(8 * idx)), 0n));
|
|
20
|
-
const k2 = BigInt(chunk.slice(8).reduce((acc, val, idx) => acc | (BigInt(val) << BigInt(8 * idx)), 0n));
|
|
21
|
-
h1 ^= (Murmur3.rotateLeft((k1 * Murmur3.C1) % Murmur3.MOD, Murmur3.R2) * Murmur3.C2) % Murmur3.MOD;
|
|
22
|
-
h1 = ((Murmur3.rotateLeft(h1, Murmur3.R1) + h2) * Murmur3.M + Murmur3.C3) % Murmur3.MOD;
|
|
23
|
-
h2 ^= (Murmur3.rotateLeft((k2 * Murmur3.C2) % Murmur3.MOD, Murmur3.R3) * Murmur3.C1) % Murmur3.MOD;
|
|
24
|
-
h2 = ((Murmur3.rotateLeft(h2, Murmur3.R2) + h1) * Murmur3.M + Murmur3.C4) % Murmur3.MOD;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
let k1 = 0n;
|
|
28
|
-
let k2 = 0n;
|
|
29
|
-
for (let j = 0; j < chunk.length; j++) {
|
|
30
|
-
const byteVal = BigInt(chunk[j]);
|
|
31
|
-
if (j < 8) {
|
|
32
|
-
k1 |= byteVal << BigInt(8 * j);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
k2 |= byteVal << BigInt(8 * (j - 8));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
k1 = (Murmur3.rotateLeft((k1 * Murmur3.C1) % Murmur3.MOD, Murmur3.R2) * Murmur3.C2) % Murmur3.MOD;
|
|
39
|
-
h1 ^= k1;
|
|
40
|
-
h2 ^= (Murmur3.rotateLeft((k2 * Murmur3.C2) % Murmur3.MOD, Murmur3.R3) * Murmur3.C1) % Murmur3.MOD;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
h1 ^= BigInt(processed);
|
|
44
|
-
h2 ^= BigInt(processed);
|
|
45
|
-
h1 = (h1 + h2) % Murmur3.MOD;
|
|
46
|
-
h2 = (h2 + h1) % Murmur3.MOD;
|
|
47
|
-
h1 = Murmur3.fmix64(h1);
|
|
48
|
-
h2 = Murmur3.fmix64(h2);
|
|
49
|
-
h1 = (h1 + h2) % Murmur3.MOD;
|
|
50
|
-
h2 = (h2 + h1) % Murmur3.MOD;
|
|
51
|
-
return (h2 << BigInt(64)) | h1;
|
|
52
|
-
}
|
|
53
|
-
static rotateLeft(x, k) {
|
|
54
|
-
const index = Number(k);
|
|
55
|
-
const binStr = x.toString(2).padStart(64, '0');
|
|
56
|
-
return BigInt(`0b${binStr.slice(index)}${binStr.slice(0, index)}`);
|
|
57
|
-
}
|
|
58
|
-
static fmix64(k) {
|
|
59
|
-
const C1 = 0xff51afd7ed558ccdn;
|
|
60
|
-
const C2 = 0xc4ceb9fe1a85ec53n;
|
|
61
|
-
const R = 33;
|
|
62
|
-
let tmp = k;
|
|
63
|
-
tmp ^= tmp >> BigInt(R);
|
|
64
|
-
tmp = (tmp * C1) % Murmur3.MOD;
|
|
65
|
-
tmp ^= tmp >> BigInt(R);
|
|
66
|
-
tmp = (tmp * C2) % Murmur3.MOD;
|
|
67
|
-
tmp ^= tmp >> BigInt(R);
|
|
68
|
-
return tmp;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function gen_buvid_fp(uuid, seed) {
|
|
72
|
-
const source = new TextEncoder().encode(uuid);
|
|
73
|
-
const m = Murmur3.hash(source, seed);
|
|
74
|
-
return `${(m & (Murmur3.MOD - 1n)).toString(16)}${(m >> 64n).toString(16)}`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export { gen_buvid_fp };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import md5 from 'md5';
|
|
2
|
-
import fetch from 'node-fetch';
|
|
3
|
-
|
|
4
|
-
const mixinKeyEncTab = [
|
|
5
|
-
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26,
|
|
6
|
-
17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52
|
|
7
|
-
];
|
|
8
|
-
// 对 imgKey 和 subKey 进行字符顺序打乱编码
|
|
9
|
-
const getMixinKey = (orig) => mixinKeyEncTab
|
|
10
|
-
.map(n => orig[n])
|
|
11
|
-
.join('')
|
|
12
|
-
.slice(0, 32);
|
|
13
|
-
// 为请求参数进行 wbi 签名
|
|
14
|
-
function encWbi(params, img_key, sub_key) {
|
|
15
|
-
const mixin_key = getMixinKey(img_key + sub_key), curr_time = Math.round(Date.now() / 1000), chr_filter = /[!'()*]/g;
|
|
16
|
-
Object.assign(params, { wts: curr_time }); // 添加 wts 字段
|
|
17
|
-
// 按照 key 重排参数
|
|
18
|
-
const query = Object.keys(params)
|
|
19
|
-
.sort()
|
|
20
|
-
.map(key => {
|
|
21
|
-
// 过滤 value 中的 "!'()*" 字符
|
|
22
|
-
const value = params[key].toString().replace(chr_filter, '');
|
|
23
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
24
|
-
})
|
|
25
|
-
.join('&');
|
|
26
|
-
const wbi_sign = md5(query + mixin_key); // 计算 w_rid
|
|
27
|
-
//return query + "&w_rid=" + wbi_sign;
|
|
28
|
-
return {
|
|
29
|
-
query: query,
|
|
30
|
-
w_rid: wbi_sign,
|
|
31
|
-
time_stamp: curr_time
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
// 获取最新的 img_key 和 sub_key
|
|
35
|
-
async function getWbiKeys(headers, cookie) {
|
|
36
|
-
const res = await fetch('https://api.bilibili.com/x/web-interface/nav', {
|
|
37
|
-
headers: {
|
|
38
|
-
// SESSDATA 字段
|
|
39
|
-
'Cookie': cookie,
|
|
40
|
-
'User-Agent': headers['User-Agent'],
|
|
41
|
-
'Referer': 'https://www.bilibili.com/' //对于直接浏览器调用可能不适用
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const { data: { wbi_img: { img_url, sub_url } } } = (await res.json());
|
|
45
|
-
return {
|
|
46
|
-
img_key: img_url.slice(img_url.lastIndexOf('/') + 1, img_url.lastIndexOf('.')),
|
|
47
|
-
sub_key: sub_url.slice(sub_url.lastIndexOf('/') + 1, sub_url.lastIndexOf('.'))
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/misc/sign/wbi.md#javascript
|
|
52
|
-
* 对实际请求参数进行 wbi 签名, 生成 wbi 签名
|
|
53
|
-
* @param {object} params 除了 wbi 签名外的全部请求参数,例如 api get请求的查询参数 { uid: 12345678, jsonp: jsonp}
|
|
54
|
-
* @param {object} headers 必需要 referer 和 UA 两个请求头
|
|
55
|
-
*/
|
|
56
|
-
async function getWbiSign(params, headers, cookie) {
|
|
57
|
-
const { img_key, sub_key } = await getWbiKeys(headers, cookie);
|
|
58
|
-
return encWbi(params, img_key, sub_key);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { getWbiSign };
|