@ikenxuan/amagi 2.1.2 → 2.1.3
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/lib/business/bilibili/API.js +1 -1
- package/lib/business/bilibili/getdata.js +37 -7
- package/lib/business/bilibili/result.js +12 -2
- package/lib/business/douyin/API.js +1 -1
- package/lib/business/douyin/getdata.js +5 -2
- package/lib/business/douyin/result.js +1 -1
- package/lib/model/networks.d.ts +4 -0
- package/lib/model/networks.js +17 -0
- package/lib/server/client.js +24 -0
- package/lib/types/BilibiliAPIParams.d.ts +2 -0
- package/lib/types/DataType.d.ts +5 -1
- package/lib/types/OptionsType.d.ts +25 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ class BiLiBiLiAPI {
|
|
|
10
10
|
}
|
|
11
11
|
/** type参数详见https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码 */
|
|
12
12
|
评论区明细(data) {
|
|
13
|
-
return `https://api.bilibili.com/x/v2/reply?sort=1&ps=${data.number || 20}&type=${data.
|
|
13
|
+
return `https://api.bilibili.com/x/v2/reply?sort=1&ps=${data.number || 20}&type=${data.commentstype}&oid=${data.oid}`;
|
|
14
14
|
}
|
|
15
15
|
表情列表() {
|
|
16
16
|
return 'https://api.bilibili.com/x/emote/user/panel/web?business=reply&web_location=0.0';
|
|
@@ -16,18 +16,27 @@ export default class BilibiliData {
|
|
|
16
16
|
switch (this.type) {
|
|
17
17
|
case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* BilibiliDataType.单个视频作品数据 */: {
|
|
18
18
|
const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI.视频详细信息({ id_type: 'bvid', id: data.id }) });
|
|
19
|
-
|
|
19
|
+
return INFODATA;
|
|
20
|
+
}
|
|
21
|
+
case "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.单个视频下载信息数据 */: {
|
|
22
|
+
const BASEURL = BiLiBiLiAPI.视频流信息({ avid: data.avid, cid: data.cid });
|
|
20
23
|
const SIGN = await qtparam(BASEURL, this.headers.Cookie);
|
|
21
24
|
const DATA = await this.GlobalGetData({
|
|
22
|
-
url: BiLiBiLiAPI.视频流信息({ avid:
|
|
25
|
+
url: BiLiBiLiAPI.视频流信息({ avid: data.avid, cid: data.cid }) + SIGN.QUERY,
|
|
23
26
|
headers: this.headers
|
|
24
27
|
});
|
|
25
|
-
return
|
|
28
|
+
return DATA;
|
|
26
29
|
}
|
|
27
30
|
case "\u8BC4\u8BBA\u6570\u636E" /* BilibiliDataType.评论数据 */: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
let COMMENTSDATA;
|
|
32
|
+
if (!data.bvid) {
|
|
33
|
+
COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI.评论区明细({ commentstype: Number(data.commentstype), oid: data.oid, number: data.number }), headers: this.headers });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI.视频详细信息({ id_type: 'bvid', id: data.bvid }) });
|
|
37
|
+
const PARAM = await wbi_sign(BiLiBiLiAPI.评论区明细({ type: 1, oid: INFODATA.data.aid }), this.headers.Cookie);
|
|
38
|
+
COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI.评论区明细({ type: 1, oid: INFODATA.data.aid, number: data.number }) + PARAM, headers: this.headers });
|
|
39
|
+
}
|
|
31
40
|
return COMMENTSDATA;
|
|
32
41
|
}
|
|
33
42
|
case "emoji\u6570\u636E" /* BilibiliDataType.emoji数据 */:
|
|
@@ -51,7 +60,7 @@ export default class BilibiliData {
|
|
|
51
60
|
case "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.番剧下载信息数据 */:
|
|
52
61
|
return await this.GlobalGetData({ url: BiLiBiLiAPI.番剧视频流信息({ cid: data.cid, ep_id: data.ep_id }) });
|
|
53
62
|
case "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E" /* BilibiliDataType.用户主页动态列表数据 */:
|
|
54
|
-
|
|
63
|
+
delete this.headers.Referer;
|
|
55
64
|
result = await this.GlobalGetData({
|
|
56
65
|
url: BiLiBiLiAPI.用户空间动态({ host_mid: data.host_mid }),
|
|
57
66
|
headers: this.headers
|
|
@@ -94,6 +103,27 @@ export default class BilibiliData {
|
|
|
94
103
|
});
|
|
95
104
|
return result;
|
|
96
105
|
}
|
|
106
|
+
case "\u7533\u8BF7\u4E8C\u7EF4\u7801" /* BilibiliDataType.申请二维码 */: {
|
|
107
|
+
result = await this.GlobalGetData({
|
|
108
|
+
url: BiLiBiLiAPI.申请二维码(),
|
|
109
|
+
headers: this.headers
|
|
110
|
+
});
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
case "\u4E8C\u7EF4\u7801\u72B6\u6001" /* BilibiliDataType.二维码状态 */: {
|
|
114
|
+
result = await new Networks({
|
|
115
|
+
url: BiLiBiLiAPI.二维码状态({ qrcode_key: data.qrcode_key }),
|
|
116
|
+
headers: this.headers
|
|
117
|
+
}).getHeadersAndData();
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" /* BilibiliDataType.登录基本信息 */: {
|
|
121
|
+
result = await this.GlobalGetData({
|
|
122
|
+
url: BiLiBiLiAPI.登录基本信息(),
|
|
123
|
+
headers: this.headers
|
|
124
|
+
});
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
97
127
|
default:
|
|
98
128
|
return null;
|
|
99
129
|
}
|
|
@@ -17,12 +17,22 @@ export default async function BilibiliResult(config = { cookie: '' }, options) {
|
|
|
17
17
|
case "\u52A8\u6001\u5361\u7247\u6570\u636E" /* BilibiliDataType.动态卡片数据 */:
|
|
18
18
|
case "\u76F4\u64AD\u95F4\u4FE1\u606F" /* BilibiliDataType.直播间信息 */:
|
|
19
19
|
case "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" /* BilibiliDataType.直播间初始化信息 */:
|
|
20
|
+
case "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.单个视频下载信息数据 */:
|
|
21
|
+
case "\u4E8C\u7EF4\u7801\u72B6\u6001" /* BilibiliDataType.二维码状态 */:
|
|
22
|
+
case "\u7533\u8BF7\u4E8C\u7EF4\u7801" /* BilibiliDataType.申请二维码 */:
|
|
23
|
+
case "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" /* BilibiliDataType.登录基本信息 */:
|
|
20
24
|
data = await new BilibiliData(config.type, config.cookie).GetData(options);
|
|
21
25
|
break;
|
|
22
26
|
case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* BilibiliDataType.单个视频作品数据 */:
|
|
23
27
|
case "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.番剧基本信息数据 */: {
|
|
24
|
-
const
|
|
25
|
-
|
|
28
|
+
const hasid = options.id || null;
|
|
29
|
+
if (hasid) {
|
|
30
|
+
data = await new BilibiliData(config.type, config.cookie).GetData({ id: options.id });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const iddata = await GetBilibiliID(options.url);
|
|
34
|
+
data = await new BilibiliData(config.type, config.cookie).GetData(iddata);
|
|
35
|
+
}
|
|
26
36
|
break;
|
|
27
37
|
}
|
|
28
38
|
default:
|
|
@@ -5,7 +5,7 @@ class DouyinAPI {
|
|
|
5
5
|
return `https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data.aweme_id}&update_version_code=170400&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=150&webid=7351848354471872041&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
|
|
6
6
|
}
|
|
7
7
|
评论(data) {
|
|
8
|
-
return `https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data.aweme_id}&cursor=0&count=${data.number}&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
|
|
8
|
+
return `https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data.aweme_id}&cursor=0&count=${data.number || 50}&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
|
|
9
9
|
}
|
|
10
10
|
二级评论(data) {
|
|
11
11
|
return `https://www.douyin.com/aweme/v1/web/comment/list/reply/?device_platform=webapp&aid=6383&channel=channel_pc_web&item_id=${data.aweme_id}&comment_id=${data.comment_id}&cut_version=1&cursor=0&count=10&item_type=0&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=0&webid=7326516708850599434&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
|
|
@@ -28,7 +28,7 @@ export default class DouyinData {
|
|
|
28
28
|
return VideoData;
|
|
29
29
|
}
|
|
30
30
|
case "\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.评论数据 */: {
|
|
31
|
-
this.URL = DouyinAPI.评论({ aweme_id: data.aweme_id });
|
|
31
|
+
this.URL = DouyinAPI.评论({ aweme_id: data.aweme_id, number: data.number });
|
|
32
32
|
const CommentsData = await this.GlobalGetData({
|
|
33
33
|
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
34
34
|
headers: this.headers
|
|
@@ -115,7 +115,10 @@ export default class DouyinData {
|
|
|
115
115
|
this.URL = DouyinAPI.动图({ aweme_id: data.aweme_id });
|
|
116
116
|
const LiveImages = await this.GlobalGetData({
|
|
117
117
|
url: `${this.URL}&a_bogus=${Sign.AB(this.URL)}`,
|
|
118
|
-
headers:
|
|
118
|
+
headers: {
|
|
119
|
+
...this.headers,
|
|
120
|
+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/126.0.0.0'
|
|
121
|
+
}
|
|
119
122
|
});
|
|
120
123
|
return LiveImages;
|
|
121
124
|
}
|
|
@@ -18,7 +18,7 @@ export default async function DouyinResult(config = { cookie: '' }, options = {}
|
|
|
18
18
|
case "\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.评论数据 */: {
|
|
19
19
|
const hasaweme_id = options.aweme_id || null;
|
|
20
20
|
if (hasaweme_id) {
|
|
21
|
-
result = await new DouyinData(config.type, config.cookie).GetData({ aweme_id: options.aweme_id });
|
|
21
|
+
result = await new DouyinData(config.type, config.cookie).GetData({ aweme_id: options.aweme_id, number: options.number });
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
const defurl = options.url?.toString().match(/(http|https):\/\/.*\.(douyin|iesdouyin)\.com\/[^ ]+/g);
|
package/lib/model/networks.d.ts
CHANGED
package/lib/model/networks.js
CHANGED
|
@@ -113,4 +113,21 @@ export default class Networks {
|
|
|
113
113
|
return false
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
async getHeadersAndData () {
|
|
117
|
+
try {
|
|
118
|
+
// 发起网络请求获取响应对象
|
|
119
|
+
const result = await this.axiosInstance.get(this.config)
|
|
120
|
+
// 初始化响应头和响应数据
|
|
121
|
+
let headers = {}
|
|
122
|
+
const fetchHeaders = result.headers
|
|
123
|
+
for (const [ key, value ] of Object.entries(fetchHeaders)) {
|
|
124
|
+
headers[key] = value
|
|
125
|
+
}
|
|
126
|
+
return { headers, data: result.data }
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.error('获取响应头和数据失败:', error)
|
|
130
|
+
return { headers: null, data: null }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
116
133
|
}
|
package/lib/server/client.js
CHANGED
|
@@ -107,12 +107,36 @@ export class client {
|
|
|
107
107
|
cookie: this.douyin
|
|
108
108
|
}, { url: request.query.url }))
|
|
109
109
|
})
|
|
110
|
+
client.get('/api/bilibili/generateqrcode', async (request, reply) => {
|
|
111
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
112
|
+
type: "\u7533\u8BF7\u4E8C\u7EF4\u7801" /* BilibiliDataType.申请二维码 */,
|
|
113
|
+
cookie: ''
|
|
114
|
+
}, {}))
|
|
115
|
+
})
|
|
116
|
+
client.get('/api/bilibili/qrcodepoll', async (request, reply) => {
|
|
117
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
118
|
+
type: "\u4E8C\u7EF4\u7801\u72B6\u6001" /* BilibiliDataType.二维码状态 */,
|
|
119
|
+
cookie: ''
|
|
120
|
+
}, { qrcode_key: request.query.qrcode_key }))
|
|
121
|
+
})
|
|
122
|
+
client.get('/api/bilibili/login', async (request, reply) => {
|
|
123
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
124
|
+
type: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" /* BilibiliDataType.登录基本信息 */,
|
|
125
|
+
cookie: request.query.cookie
|
|
126
|
+
}, {}))
|
|
127
|
+
})
|
|
110
128
|
client.get('/api/bilibili/work', async (request, reply) => {
|
|
111
129
|
reply.type('application/json').send(await BilibiliResult({
|
|
112
130
|
type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* BilibiliDataType.单个视频作品数据 */,
|
|
113
131
|
cookie: this.bilibili
|
|
114
132
|
}, { url: request.query.url }))
|
|
115
133
|
})
|
|
134
|
+
client.get('/api/bilibili/downloadwork', async (request, reply) => {
|
|
135
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
136
|
+
type: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.单个视频下载信息数据 */,
|
|
137
|
+
cookie: this.bilibili
|
|
138
|
+
}, { url: request.query.url }))
|
|
139
|
+
})
|
|
116
140
|
client.get('/api/bilibili/comment', async (request, reply) => {
|
|
117
141
|
reply.type('application/json').send(await BilibiliResult({
|
|
118
142
|
type: "\u8BC4\u8BBA\u6570\u636E" /* BilibiliDataType.评论数据 */,
|
|
@@ -13,6 +13,8 @@ type VideoStreamParams = {
|
|
|
13
13
|
type CommentParams = {
|
|
14
14
|
/** 评论区类型,type参数详见https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码 */
|
|
15
15
|
type?: number | string;
|
|
16
|
+
/** 评论区类型,type参数详见https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码 */
|
|
17
|
+
commentstype?: number | string;
|
|
16
18
|
/** 稿件ID,也就是AVID */
|
|
17
19
|
oid?: number | string;
|
|
18
20
|
/** 获取的评论数量,默认最高20 */
|
package/lib/types/DataType.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare const enum DouyinDataType {
|
|
|
20
20
|
*/
|
|
21
21
|
export declare const enum BilibiliDataType {
|
|
22
22
|
单个视频作品数据 = "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E",
|
|
23
|
+
单个视频下载信息数据 = "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E",
|
|
23
24
|
评论数据 = "\u8BC4\u8BBA\u6570\u636E",
|
|
24
25
|
用户主页数据 = "\u7528\u6237\u4E3B\u9875\u6570\u636E",
|
|
25
26
|
用户主页动态列表数据 = "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E",
|
|
@@ -29,5 +30,8 @@ export declare const enum BilibiliDataType {
|
|
|
29
30
|
动态详情数据 = "\u52A8\u6001\u8BE6\u60C5\u6570\u636E",
|
|
30
31
|
动态卡片数据 = "\u52A8\u6001\u5361\u7247\u6570\u636E",
|
|
31
32
|
直播间信息 = "\u76F4\u64AD\u95F4\u4FE1\u606F",
|
|
32
|
-
直播间初始化信息 = "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F"
|
|
33
|
+
直播间初始化信息 = "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F",
|
|
34
|
+
登录基本信息 = "\u767B\u5F55\u57FA\u672C\u4FE1\u606F",
|
|
35
|
+
申请二维码 = "\u7533\u8BF7\u4E8C\u7EF4\u7801",
|
|
36
|
+
二维码状态 = "\u4E8C\u7EF4\u7801\u72B6\u6001"
|
|
33
37
|
}
|
|
@@ -26,6 +26,10 @@ export type DouyinOptionsType = {
|
|
|
26
26
|
* 音乐ID
|
|
27
27
|
*/
|
|
28
28
|
music_id?: string;
|
|
29
|
+
/**
|
|
30
|
+
* 评论数量,单位条
|
|
31
|
+
*/
|
|
32
|
+
number?: number;
|
|
29
33
|
};
|
|
30
34
|
/**
|
|
31
35
|
* 接口公共查询参数
|
|
@@ -50,7 +54,7 @@ export type BilibiliOptionsType = {
|
|
|
50
54
|
/**
|
|
51
55
|
* 用户ID
|
|
52
56
|
*/
|
|
53
|
-
host_mid?: string;
|
|
57
|
+
host_mid?: string | number;
|
|
54
58
|
/**
|
|
55
59
|
* 动态ID
|
|
56
60
|
*/
|
|
@@ -67,4 +71,24 @@ export type BilibiliOptionsType = {
|
|
|
67
71
|
* 直播间ID
|
|
68
72
|
*/
|
|
69
73
|
room_id?: string;
|
|
74
|
+
/**
|
|
75
|
+
* 评论数量,单位条
|
|
76
|
+
*/
|
|
77
|
+
number?: number;
|
|
78
|
+
/**
|
|
79
|
+
* 用户 Cookie
|
|
80
|
+
*/
|
|
81
|
+
cookie?: string;
|
|
82
|
+
/**
|
|
83
|
+
* 二维码key
|
|
84
|
+
*/
|
|
85
|
+
qrcode_key?: string;
|
|
86
|
+
/**
|
|
87
|
+
* 评论区类型代码
|
|
88
|
+
*/
|
|
89
|
+
commentstype?: number;
|
|
90
|
+
/**
|
|
91
|
+
* 评论区查询专属参数
|
|
92
|
+
*/
|
|
93
|
+
oid?: number;
|
|
70
94
|
};
|