yz-yuki-plugin 2.0.5-8 → 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.
@@ -1,77 +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, jsonp: jsonp }
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
- /**header */
22
- static BILIBILI_HEADERS = {
23
- 'Accept': '*/*',
24
- 'Accept-Language': 'zh-CN,en-US;q=0.5',
25
- 'Accept-Encoding': 'gzip, deflate, br, zstd',
26
- 'Cookie': '',
27
- 'pragma': 'no-cache',
28
- 'Cache-control': 'max-age=0',
29
- 'DNT': '1',
30
- 'Sec-GPC': '1',
31
- 'sec-ch-ua-platform': '',
32
- 'sec-ch-ua-mobile': '?0',
33
- 'Sec-Fetch-Dest': 'empty',
34
- 'Sec-Fetch-Mode': 'cors',
35
- 'Sec-Fetch-Site': 'same-site',
36
- 'Sec-Fetch-User': '?0',
37
- 'Priority': 'u=4',
38
- 'TE': 'trailers',
39
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0'
40
- };
41
- /**Login header */
42
- static BIlIBILI_LOGIN_HEADERS = {
43
- 'Accept': '*/*',
44
- 'Accept-Language': 'zh-CN,en-US;q=0.5',
45
- 'Accept-Encoding': 'gzip, deflate, br, zstd',
46
- 'DNT': '1',
47
- 'Sec-GPC': '1',
48
- 'Upgrade-Insecure-Requests': '1',
49
- 'Sec-Fetch-Dest': 'document',
50
- 'Sec-Fetch-Mode': 'navigate',
51
- 'Sec-Fetch-Site': 'none',
52
- 'Sec-Fetch-User': '?1',
53
- 'TE': 'trailers'
54
- };
55
- /**FullArticle header */
56
- static BILIBILI_ARTICLE_HEADERS = {
57
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8',
58
- 'Accept-Language': 'zh-CN,en-US;q=0.5',
59
- 'Accept-Encoding': 'gzip, deflate, br, zstd',
60
- 'Content-type': 'text/html; charset=utf-8',
61
- 'Cookie': '',
62
- 'pragma': 'no-cache',
63
- 'Cache-control': 'no-cache',
64
- 'DNT': '1',
65
- 'Sec-GPC': '1',
66
- 'sec-ch-ua-mobile': '?0',
67
- 'Sec-Fetch-Dest': 'document',
68
- 'Sec-Fetch-Mode': 'navigate',
69
- 'Sec-Fetch-Site': 'same-site',
70
- 'Sec-Fetch-User': '?1',
71
- 'TE': 'trailers',
72
- 'Upgrade-Insecure-Requests': '1',
73
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0'
74
- };
75
- }
76
-
77
- 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 };