@ikenxuan/amagi 2.1.3 → 2.1.4
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.
|
@@ -35,7 +35,7 @@ export default class BilibiliData {
|
|
|
35
35
|
else {
|
|
36
36
|
const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI.视频详细信息({ id_type: 'bvid', id: data.bvid }) });
|
|
37
37
|
const PARAM = await wbi_sign(BiLiBiLiAPI.评论区明细({ type: 1, oid: INFODATA.data.aid }), this.headers.Cookie);
|
|
38
|
-
COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI.评论区明细({
|
|
38
|
+
COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI.评论区明细({ commentstype: 1, oid: INFODATA.data.aid, number: data.number }) + PARAM, headers: this.headers });
|
|
39
39
|
}
|
|
40
40
|
return COMMENTSDATA;
|
|
41
41
|
}
|
|
@@ -8,27 +8,39 @@ export default async function GetDouyinID(url) {
|
|
|
8
8
|
const longLink = await new Networks({ url }).getLongLink();
|
|
9
9
|
let result = {};
|
|
10
10
|
switch (true) {
|
|
11
|
-
case /
|
|
11
|
+
case /share\/slides\/(\d+)/.test(longLink): {
|
|
12
|
+
const newres = await new Networks({ url }).getLocation();
|
|
13
|
+
const match = newres.match(/share\/slides\/(\d+)/);
|
|
14
|
+
result = {
|
|
15
|
+
type: "\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */,
|
|
16
|
+
aweme_id: match ? match[1] : '',
|
|
17
|
+
};
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
case /video\/(\d+)/.test(longLink): {
|
|
12
21
|
const videoMatch = longLink.match(/video\/(\d+)/);
|
|
13
22
|
result = {
|
|
14
|
-
type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType
|
|
23
|
+
type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.单个视频作品数据 */,
|
|
15
24
|
aweme_id: videoMatch ? videoMatch[1] : ''
|
|
16
25
|
};
|
|
17
26
|
break;
|
|
18
|
-
|
|
27
|
+
}
|
|
28
|
+
case /note\/(\d+)/.test(longLink): {
|
|
19
29
|
const noteMatch = longLink.match(/note\/(\d+)/);
|
|
20
30
|
result = {
|
|
21
|
-
type: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" /* DouyinDataType
|
|
31
|
+
type: "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.图集作品数据 */,
|
|
22
32
|
aweme_id: noteMatch ? noteMatch[1] : ''
|
|
23
33
|
};
|
|
24
34
|
break;
|
|
25
|
-
|
|
35
|
+
}
|
|
36
|
+
case /user\/(\S+?)\?/.test(longLink): {
|
|
26
37
|
const userMatch = longLink.match(/user\/(\S+?)\?/);
|
|
27
38
|
result = {
|
|
28
|
-
type: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" /* DouyinDataType
|
|
39
|
+
type: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" /* DouyinDataType.用户主页视频列表数据 */,
|
|
29
40
|
sec_uid: userMatch ? userMatch[1] : ''
|
|
30
41
|
};
|
|
31
42
|
break;
|
|
43
|
+
}
|
|
32
44
|
default:
|
|
33
45
|
break;
|
|
34
46
|
}
|
|
@@ -10,9 +10,9 @@ export default async function DouyinResult(config = { cookie: '' }, options = {}
|
|
|
10
10
|
case "\u5B98\u65B9emoji\u6570\u636E" /* DouyinDataType.官方emoji数据 */:
|
|
11
11
|
case "\u52A8\u6001\u8868\u60C5\u6570\u636E" /* DouyinDataType.动态表情数据 */:
|
|
12
12
|
case "\u97F3\u4E50\u6570\u636E" /* DouyinDataType.音乐数据 */:
|
|
13
|
-
case "\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */:
|
|
14
13
|
result = await new DouyinData(config.type, config.cookie).GetData(options);
|
|
15
14
|
break;
|
|
15
|
+
case "\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */:
|
|
16
16
|
case "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.单个视频作品数据 */:
|
|
17
17
|
case "\u56FE\u96C6\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.图集作品数据 */:
|
|
18
18
|
case "\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.评论数据 */: {
|
|
@@ -21,8 +21,7 @@ export default async function DouyinResult(config = { cookie: '' }, options = {}
|
|
|
21
21
|
result = await new DouyinData(config.type, config.cookie).GetData({ aweme_id: options.aweme_id, number: options.number });
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
const
|
|
25
|
-
const iddata = await GetDouyinID(String(defurl));
|
|
24
|
+
const iddata = await GetDouyinID(String(options.url));
|
|
26
25
|
result = await new DouyinData(config.type, config.cookie).GetData(iddata);
|
|
27
26
|
}
|
|
28
27
|
break;
|
package/lib/model/networks.js
CHANGED
|
@@ -24,7 +24,8 @@ export default class Networks {
|
|
|
24
24
|
// 创建axios实例
|
|
25
25
|
this.axiosInstance = axios.create({
|
|
26
26
|
timeout: this.timeout,
|
|
27
|
-
headers: this.headers
|
|
27
|
+
headers: this.headers,
|
|
28
|
+
maxRedirects: 5
|
|
28
29
|
})
|
|
29
30
|
}
|
|
30
31
|
get config () {
|
|
@@ -58,8 +59,11 @@ export default class Networks {
|
|
|
58
59
|
/** 最终地址(跟随重定向) */
|
|
59
60
|
async getLongLink () {
|
|
60
61
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
62
|
+
const response = await this.axiosInstance({
|
|
63
|
+
method: 'GET',
|
|
64
|
+
url: this.url
|
|
65
|
+
})
|
|
66
|
+
return response.request.res.responseUrl // axios中获取最终的请求URL
|
|
63
67
|
}
|
|
64
68
|
catch (error) {
|
|
65
69
|
if (error instanceof AxiosError) {
|
|
@@ -116,7 +120,7 @@ export default class Networks {
|
|
|
116
120
|
async getHeadersAndData () {
|
|
117
121
|
try {
|
|
118
122
|
// 发起网络请求获取响应对象
|
|
119
|
-
const result = await this.axiosInstance
|
|
123
|
+
const result = await this.axiosInstance(this.config)
|
|
120
124
|
// 初始化响应头和响应数据
|
|
121
125
|
let headers = {}
|
|
122
126
|
const fetchHeaders = result.headers
|
package/lib/server/client.js
CHANGED
|
@@ -122,7 +122,7 @@ export class client {
|
|
|
122
122
|
client.get('/api/bilibili/login', async (request, reply) => {
|
|
123
123
|
reply.type('application/json').send(await BilibiliResult({
|
|
124
124
|
type: "\u767B\u5F55\u57FA\u672C\u4FE1\u606F" /* BilibiliDataType.登录基本信息 */,
|
|
125
|
-
cookie: request.
|
|
125
|
+
cookie: request.headers.cookie
|
|
126
126
|
}, {}))
|
|
127
127
|
})
|
|
128
128
|
client.get('/api/bilibili/work', async (request, reply) => {
|
|
@@ -135,7 +135,7 @@ export class client {
|
|
|
135
135
|
reply.type('application/json').send(await BilibiliResult({
|
|
136
136
|
type: "\u5355\u4E2A\u89C6\u9891\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.单个视频下载信息数据 */,
|
|
137
137
|
cookie: this.bilibili
|
|
138
|
-
}, {
|
|
138
|
+
}, { avid: request.query.avid, cid: request.query.cid }))
|
|
139
139
|
})
|
|
140
140
|
client.get('/api/bilibili/comment', async (request, reply) => {
|
|
141
141
|
reply.type('application/json').send(await BilibiliResult({
|