@ikenxuan/amagi 2.0.0 → 2.1.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/README.md +9 -8
- package/lib/business/bilibili/getdata.d.ts +2 -2
- package/lib/business/bilibili/getdata.js +1 -1
- package/lib/business/bilibili/result.d.ts +12 -5
- package/lib/business/bilibili/result.js +33 -40
- package/lib/business/douyin/getdata.d.ts +2 -2
- package/lib/business/douyin/getdata.js +24 -13
- package/lib/business/douyin/result.d.ts +6 -5
- package/lib/business/douyin/result.js +29 -42
- package/lib/business/douyin/sign/a_bogus.js +8 -8
- package/lib/business/index.d.ts +2 -2
- package/lib/business/index.js +2 -2
- package/lib/index.d.ts +17 -0
- package/lib/index.js +23 -0
- package/lib/model/dir.d.ts +3 -3
- package/lib/model/dir.js +6 -6
- package/lib/model/index.d.ts +3 -3
- package/lib/model/index.js +3 -3
- package/lib/model/networks.d.ts +13 -21
- package/lib/model/networks.js +54 -139
- package/lib/server/client.d.ts +22 -13
- package/lib/server/client.js +138 -80
- package/lib/server/index.d.ts +2 -2
- package/lib/server/index.js +2 -2
- package/lib/server/listen.d.ts +2 -2
- package/lib/server/listen.js +4 -4
- package/lib/types/BilibiliAPIParams.d.ts +1 -1
- package/lib/types/BilibiliAPIParams.js +1 -1
- package/lib/types/ConfigType.js +1 -1
- package/lib/types/DataType.js +1 -1
- package/lib/types/DouyinAPIParams.d.ts +1 -1
- package/lib/types/DouyinAPIParams.js +1 -1
- package/lib/types/GetDataResponseType.js +1 -1
- package/lib/types/NetworksConfigType.js +1 -1
- package/lib/types/OptionsType.js +1 -1
- package/lib/types/Request.d.ts +2 -2
- package/lib/types/Request.js +1 -1
- package/lib/types/index.d.ts +9 -9
- package/lib/types/index.js +1 -1
- package/package.json +1 -1
package/lib/model/networks.js
CHANGED
|
@@ -1,68 +1,70 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
1
|
+
import axios, { AxiosError } from 'axios'
|
|
2
2
|
export default class Networks {
|
|
3
|
-
url
|
|
4
|
-
method
|
|
5
|
-
headers
|
|
6
|
-
type
|
|
7
|
-
body
|
|
8
|
-
axiosInstance
|
|
9
|
-
isGetResult
|
|
10
|
-
timeout
|
|
11
|
-
timer
|
|
12
|
-
data
|
|
3
|
+
url
|
|
4
|
+
method
|
|
5
|
+
headers
|
|
6
|
+
type
|
|
7
|
+
body
|
|
8
|
+
axiosInstance
|
|
9
|
+
isGetResult
|
|
10
|
+
timeout
|
|
11
|
+
timer
|
|
12
|
+
data
|
|
13
13
|
constructor (data) {
|
|
14
|
-
this.headers = data.headers || {}
|
|
15
|
-
this.url = data.url || ''
|
|
16
|
-
this.type = data.type || 'json'
|
|
17
|
-
this.method = data.method || 'GET'
|
|
18
|
-
this.body = data.body || null
|
|
19
|
-
this.data = {}
|
|
20
|
-
this.timeout = data.timeout || 5000
|
|
21
|
-
this.isGetResult = false
|
|
22
|
-
this.timer = undefined
|
|
14
|
+
this.headers = data.headers || {}
|
|
15
|
+
this.url = data.url || ''
|
|
16
|
+
this.type = data.type || 'json'
|
|
17
|
+
this.method = data.method || 'GET'
|
|
18
|
+
this.body = data.body || null
|
|
19
|
+
this.data = {}
|
|
20
|
+
this.timeout = data.timeout || 5000
|
|
21
|
+
this.isGetResult = false
|
|
22
|
+
this.timer = undefined
|
|
23
23
|
// 创建axios实例
|
|
24
24
|
this.axiosInstance = axios.create({
|
|
25
25
|
timeout: this.timeout,
|
|
26
26
|
headers: this.headers
|
|
27
|
-
})
|
|
27
|
+
})
|
|
28
28
|
}
|
|
29
29
|
get config () {
|
|
30
30
|
let config = {
|
|
31
31
|
url: this.url,
|
|
32
32
|
method: this.method,
|
|
33
33
|
headers: this.headers
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
if (this.method === 'POST' && this.body) {
|
|
36
|
-
config.data = this.body
|
|
36
|
+
config.data = this.body
|
|
37
37
|
}
|
|
38
|
-
return config
|
|
38
|
+
return config
|
|
39
39
|
}
|
|
40
40
|
async getfetch () {
|
|
41
41
|
try {
|
|
42
|
-
const result = await this.returnResult()
|
|
42
|
+
const result = await this.returnResult()
|
|
43
43
|
if (result.status === 504) {
|
|
44
|
-
return result
|
|
44
|
+
return result
|
|
45
45
|
}
|
|
46
|
-
this.isGetResult = true
|
|
47
|
-
return result
|
|
46
|
+
this.isGetResult = true
|
|
47
|
+
return result
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
|
50
|
-
console.info(error)
|
|
51
|
-
return false
|
|
50
|
+
console.info(error)
|
|
51
|
+
return false
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
async returnResult () {
|
|
55
|
-
return await this.axiosInstance(this.config)
|
|
55
|
+
return await this.axiosInstance(this.config)
|
|
56
56
|
}
|
|
57
57
|
/** 最终地址(跟随重定向) */
|
|
58
58
|
async getLongLink () {
|
|
59
59
|
try {
|
|
60
|
-
const result = await this.returnResult()
|
|
61
|
-
return result.request.res.responseUrl
|
|
60
|
+
const result = await this.returnResult()
|
|
61
|
+
return result.request.res.responseUrl // axios中获取最终的请求URL
|
|
62
62
|
}
|
|
63
63
|
catch (error) {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (error instanceof AxiosError) {
|
|
65
|
+
throw new Error(error.stack)
|
|
66
|
+
}
|
|
67
|
+
return ''
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
/** 获取首个302 */
|
|
@@ -73,128 +75,41 @@ export default class Networks {
|
|
|
73
75
|
url: this.url,
|
|
74
76
|
maxRedirects: 0, // 禁止跟随重定向
|
|
75
77
|
validateStatus: (status) => status >= 300 && status < 400 // 仅处理3xx响应
|
|
76
|
-
})
|
|
77
|
-
return response.headers['location']
|
|
78
|
+
})
|
|
79
|
+
return response.headers['location']
|
|
78
80
|
}
|
|
79
81
|
catch (error) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
if (error instanceof AxiosError) {
|
|
83
|
+
throw new Error(error.stack)
|
|
84
|
+
}
|
|
85
|
+
return ''
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
/** 获取数据并处理数据的格式化,默认json */
|
|
85
89
|
async getData (new_fetch = '') {
|
|
86
90
|
try {
|
|
87
91
|
if (!new_fetch) {
|
|
88
|
-
const result = await this.returnResult()
|
|
92
|
+
const result = await this.returnResult()
|
|
89
93
|
if (result.status === 504) {
|
|
90
|
-
return result
|
|
94
|
+
return result
|
|
91
95
|
}
|
|
92
96
|
if (result.status === 429) {
|
|
93
|
-
console.warn('HTTP 响应状态码: 429')
|
|
94
|
-
throw new Error('ratelimit triggered, 触发 https://www.douyin.com/ 的速率限制!!!')
|
|
95
|
-
}
|
|
96
|
-
this.axiosInstance = result;
|
|
97
|
-
this.isGetResult = true;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
this.axiosInstance = new_fetch;
|
|
101
|
-
}
|
|
102
|
-
switch (this.type) {
|
|
103
|
-
case 'json':
|
|
104
|
-
await this.Tojson();
|
|
105
|
-
break;
|
|
106
|
-
case 'text':
|
|
107
|
-
await this.ToText();
|
|
108
|
-
break;
|
|
109
|
-
case 'arrayBuffer':
|
|
110
|
-
await this.ToArrayBuffer();
|
|
111
|
-
break;
|
|
112
|
-
case 'blob':
|
|
113
|
-
await this.ToBlob();
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
}
|
|
117
|
-
return this.axiosInstance;
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
console.error(error);
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** 获取响应头 */
|
|
125
|
-
async getHeaders () {
|
|
126
|
-
try {
|
|
127
|
-
this.axiosInstance = await this.returnResult();
|
|
128
|
-
if (this.axiosInstance) {
|
|
129
|
-
if (this.axiosInstance.headers) {
|
|
130
|
-
return this.axiosInstance.headers;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
console.error('未获取到响应头');
|
|
134
|
-
return null;
|
|
97
|
+
console.warn('HTTP 响应状态码: 429')
|
|
98
|
+
throw new Error('ratelimit triggered, 触发 https://www.douyin.com/ 的速率限制!!!')
|
|
135
99
|
}
|
|
100
|
+
this.axiosInstance = result
|
|
101
|
+
this.isGetResult = true
|
|
136
102
|
}
|
|
137
103
|
else {
|
|
138
|
-
|
|
139
|
-
return null;
|
|
104
|
+
this.axiosInstance = new_fetch
|
|
140
105
|
}
|
|
106
|
+
return this.axiosInstance.data
|
|
141
107
|
}
|
|
142
108
|
catch (error) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/** 一次性获取响应头和响应体 */
|
|
148
|
-
async getHeadersAndData () {
|
|
149
|
-
try {
|
|
150
|
-
this.axiosInstance = await this.returnResult();
|
|
151
|
-
let headers = null;
|
|
152
|
-
let data = null;
|
|
153
|
-
if (this.axiosInstance) {
|
|
154
|
-
headers = this.axiosInstance.headers;
|
|
155
|
-
switch (this.type) {
|
|
156
|
-
case 'json':
|
|
157
|
-
data = this.axiosInstance.data;
|
|
158
|
-
break;
|
|
159
|
-
case 'text':
|
|
160
|
-
data = this.axiosInstance.data;
|
|
161
|
-
break;
|
|
162
|
-
case 'arrayBuffer':
|
|
163
|
-
data = await this.ToArrayBuffer();
|
|
164
|
-
break;
|
|
165
|
-
case 'blob':
|
|
166
|
-
data = await this.ToBlob();
|
|
167
|
-
break;
|
|
168
|
-
default:
|
|
169
|
-
}
|
|
109
|
+
if (error instanceof AxiosError) {
|
|
110
|
+
throw new Error(error.stack)
|
|
170
111
|
}
|
|
171
|
-
|
|
172
|
-
console.error('未获取到响应对象');
|
|
173
|
-
}
|
|
174
|
-
return { headers, data };
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
console.error('获取响应头和数据失败:', error);
|
|
178
|
-
return { headers: null, data: null };
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
async Tojson () {
|
|
182
|
-
if (this.axiosInstance.headers['content-type'].includes('json')) {
|
|
183
|
-
this.axiosInstance = this.axiosInstance.data;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
this.axiosInstance = this.axiosInstance.data;
|
|
187
|
-
this.type = 'text';
|
|
112
|
+
return false
|
|
188
113
|
}
|
|
189
114
|
}
|
|
190
|
-
async ToText () {
|
|
191
|
-
this.axiosInstance = this.axiosInstance.data;
|
|
192
|
-
}
|
|
193
|
-
async ToArrayBuffer () {
|
|
194
|
-
this.axiosInstance = this.axiosInstance.data;
|
|
195
|
-
}
|
|
196
|
-
async ToBlob () {
|
|
197
|
-
// axios 没有直接支持blob, 需要使用arraybuffer然后转换
|
|
198
|
-
this.axiosInstance = new Blob([new Uint8Array(this.axiosInstance.data)]);
|
|
199
|
-
}
|
|
200
115
|
}
|
package/lib/server/client.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BilibiliDataType, DouyinDataType } from '../types/index.js';
|
|
4
|
-
import { FastifyInstance } from 'fastify';
|
|
1
|
+
import { BilibiliDataType, DouyinDataType } from '../types/index.js'
|
|
2
|
+
import { FastifyInstance } from 'fastify'
|
|
5
3
|
interface initClientParams {
|
|
6
4
|
/** 抖音ck */
|
|
7
5
|
douyin: string;
|
|
@@ -11,20 +9,26 @@ interface initClientParams {
|
|
|
11
9
|
interface amagiInstance {
|
|
12
10
|
/** Fastify 实例 */
|
|
13
11
|
Instance: FastifyInstance;
|
|
14
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* amagi.GetDouyinData 已废弃,请直接导入 GetDouyinData 方法使用
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
15
16
|
GetDouyinData: (data: {
|
|
16
17
|
type: keyof typeof DouyinDataType;
|
|
17
|
-
}) =>
|
|
18
|
-
/**
|
|
18
|
+
}) => Error | any;
|
|
19
|
+
/**
|
|
20
|
+
* amagi.GetBilibiliData 已废弃!请直接导入 GetBilibiliData 方法使用
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
19
23
|
GetBilibiliData: (data: {
|
|
20
24
|
type: keyof typeof BilibiliDataType;
|
|
21
|
-
}) =>
|
|
25
|
+
}) => Error | any;
|
|
22
26
|
}
|
|
23
27
|
export declare class client {
|
|
24
28
|
/** douyin cookies */
|
|
25
|
-
douyin: string
|
|
29
|
+
douyin: string
|
|
26
30
|
/** bilibili cookes */
|
|
27
|
-
bilibili: string
|
|
31
|
+
bilibili: string
|
|
28
32
|
/**
|
|
29
33
|
*
|
|
30
34
|
* @param cookies 包含抖音和B站cookie的参数对象
|
|
@@ -38,9 +42,14 @@ export declare class client {
|
|
|
38
42
|
initServer(log?: boolean): Promise<amagiInstance>;
|
|
39
43
|
GetDouyinData: (data: {
|
|
40
44
|
type: keyof typeof DouyinDataType;
|
|
41
|
-
}) =>
|
|
45
|
+
}) => Error | any
|
|
42
46
|
GetBilibiliData: (data: {
|
|
43
47
|
type: keyof typeof BilibiliDataType;
|
|
44
|
-
}) =>
|
|
48
|
+
}) => {
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated
|
|
51
|
+
*/
|
|
52
|
+
result: () => Promise<never>;
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
|
-
export {}
|
|
55
|
+
export {}
|
package/lib/server/client.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BilibiliResult } from '../business/bilibili/index.js'
|
|
2
|
-
import { DouyinResult } from '../business/douyin/index.js'
|
|
3
|
-
import Fastify from 'fastify'
|
|
1
|
+
import { BilibiliResult } from '../business/bilibili/index.js'
|
|
2
|
+
import { DouyinResult } from '../business/douyin/index.js'
|
|
3
|
+
import Fastify from 'fastify'
|
|
4
4
|
export class client {
|
|
5
5
|
/** douyin cookies */
|
|
6
|
-
douyin
|
|
6
|
+
douyin
|
|
7
7
|
/** bilibili cookes */
|
|
8
|
-
bilibili
|
|
8
|
+
bilibili
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
11
|
* @param cookies 包含抖音和B站cookie的参数对象
|
|
12
12
|
*/
|
|
13
13
|
constructor (cookies) {
|
|
14
14
|
/** 抖音ck */
|
|
15
|
-
this.douyin = cookies.douyin
|
|
15
|
+
this.douyin = cookies.douyin
|
|
16
16
|
/** B站ck */
|
|
17
|
-
this.bilibili = cookies.bilibili
|
|
17
|
+
this.bilibili = cookies.bilibili
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* 初始化 fastify 实例
|
|
@@ -34,108 +34,166 @@ export class client {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
})
|
|
37
|
+
})
|
|
38
38
|
client.get('/', async (_request, reply) => {
|
|
39
|
-
reply.redirect('https://amagi.apifox.cn', 301)
|
|
40
|
-
})
|
|
39
|
+
reply.redirect('https://amagi.apifox.cn', 301)
|
|
40
|
+
})
|
|
41
41
|
client.get('/docs', async (_request, reply) => {
|
|
42
|
-
reply.redirect('https://amagi.apifox.cn', 301)
|
|
43
|
-
})
|
|
42
|
+
reply.redirect('https://amagi.apifox.cn', 301)
|
|
43
|
+
})
|
|
44
44
|
client.get('/api/douyin/aweme', async (request, reply) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
reply.type('application/json').send(await DouyinResult({
|
|
46
|
+
type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.单个视频作品数据 */,
|
|
47
|
+
cookie: this.douyin
|
|
48
|
+
}, { url: request.query.url }))
|
|
49
|
+
})
|
|
48
50
|
client.get('/api/douyin/comments', async (request, reply) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
reply.type('application/json').send(await DouyinResult({
|
|
52
|
+
type: "\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.评论数据 */,
|
|
53
|
+
cookie: this.douyin
|
|
54
|
+
}, { url: request.query.url }))
|
|
55
|
+
})
|
|
52
56
|
client.get('/api/douyin/comments/reply', async (request, reply) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
reply.type('application/json').send(await DouyinResult({
|
|
58
|
+
type: "\u4E8C\u7EA7\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.二级评论数据 */,
|
|
59
|
+
cookie: this.douyin
|
|
60
|
+
}, { aweme_id: request.query.aweme_id, comment_id: request.query.comment_id }))
|
|
61
|
+
})
|
|
56
62
|
client.get('/api/douyin/userinfo', async (request, reply) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
reply.type('application/json').send(await DouyinResult({
|
|
64
|
+
type: "\u7528\u6237\u4E3B\u9875\u6570\u636E" /* DouyinDataType.用户主页数据 */,
|
|
65
|
+
cookie: this.douyin
|
|
66
|
+
}, { sec_uid: request.query.sec_uid }))
|
|
67
|
+
})
|
|
60
68
|
client.get('/api/douyin/uservideoslist', async (request, reply) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
reply.type('application/json').send(await DouyinResult({
|
|
70
|
+
type: "\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" /* DouyinDataType.用户主页视频列表数据 */,
|
|
71
|
+
cookie: this.douyin
|
|
72
|
+
}, { sec_uid: request.query.sec_uid }))
|
|
73
|
+
})
|
|
64
74
|
client.get('/api/douyin/suggestwords', async (request, reply) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
reply.type('application/json').send(await DouyinResult({
|
|
76
|
+
type: "\u70ED\u70B9\u8BCD\u6570\u636E" /* DouyinDataType.热点词数据 */,
|
|
77
|
+
cookie: this.douyin
|
|
78
|
+
}, { query: request.query.query }))
|
|
79
|
+
})
|
|
68
80
|
client.get('/api/douyin/search', async (request, reply) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
reply.type('application/json').send(await DouyinResult({
|
|
82
|
+
type: "\u641C\u7D22\u6570\u636E" /* DouyinDataType.搜索数据 */,
|
|
83
|
+
cookie: this.douyin
|
|
84
|
+
}, { query: request.query.query }))
|
|
85
|
+
})
|
|
72
86
|
client.get('/api/douyin/emoji', async (_request, reply) => {
|
|
73
|
-
reply.type('application/json').send(await
|
|
74
|
-
|
|
87
|
+
reply.type('application/json').send(await DouyinResult({
|
|
88
|
+
type: "\u5B98\u65B9emoji\u6570\u636E" /* DouyinDataType.官方emoji数据 */,
|
|
89
|
+
cookie: this.douyin
|
|
90
|
+
}))
|
|
91
|
+
})
|
|
75
92
|
client.get('/api/douyin/expressionplus', async (_request, reply) => {
|
|
76
|
-
reply.type('application/json').send(await
|
|
77
|
-
|
|
93
|
+
reply.type('application/json').send(await DouyinResult({
|
|
94
|
+
type: "\u52A8\u6001\u8868\u60C5\u6570\u636E" /* DouyinDataType.动态表情数据 */,
|
|
95
|
+
cookie: this.douyin
|
|
96
|
+
}))
|
|
97
|
+
})
|
|
78
98
|
client.get('/api/douyin/music', async (request, reply) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
99
|
+
reply.type('application/json').send(await DouyinResult({
|
|
100
|
+
type: "\u97F3\u4E50\u6570\u636E" /* DouyinDataType.音乐数据 */,
|
|
101
|
+
cookie: this.douyin
|
|
102
|
+
}, { music_id: request.query.music_id }))
|
|
103
|
+
})
|
|
82
104
|
client.get('/api/douyin/liveimages', async (request, reply) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
105
|
+
reply.type('application/json').send(await DouyinResult({
|
|
106
|
+
type: "\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */,
|
|
107
|
+
cookie: this.douyin
|
|
108
|
+
}, { url: request.query.url }))
|
|
109
|
+
})
|
|
86
110
|
client.get('/api/bilibili/work', async (request, reply) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
111
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
112
|
+
type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* BilibiliDataType.单个视频作品数据 */,
|
|
113
|
+
cookie: this.bilibili
|
|
114
|
+
}, { url: request.query.url }))
|
|
115
|
+
})
|
|
90
116
|
client.get('/api/bilibili/comment', async (request, reply) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
117
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
118
|
+
type: "\u8BC4\u8BBA\u6570\u636E" /* BilibiliDataType.评论数据 */,
|
|
119
|
+
cookie: this.bilibili
|
|
120
|
+
}, { bvid: request.query.bvid }))
|
|
121
|
+
})
|
|
94
122
|
client.get('/api/bilibili/emoji', async (_request, reply) => {
|
|
95
|
-
reply.type('application/json').send(await
|
|
96
|
-
|
|
123
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
124
|
+
type: "emoji\u6570\u636E" /* BilibiliDataType.emoji数据 */,
|
|
125
|
+
cookie: this.bilibili
|
|
126
|
+
}, {}))
|
|
127
|
+
})
|
|
97
128
|
client.get('/api/bilibili/bangumivideoinfo', async (request, reply) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
129
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
130
|
+
type: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.番剧基本信息数据 */,
|
|
131
|
+
cookie: this.bilibili
|
|
132
|
+
}, { url: request.query.url }))
|
|
133
|
+
})
|
|
101
134
|
client.get('/api/bilibili/bangumivideodownloadlink', async (request, reply) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
135
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
136
|
+
type: "\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.番剧下载信息数据 */,
|
|
137
|
+
cookie: this.bilibili
|
|
138
|
+
}, { cid: request.query.cid, ep_id: request.query.ep_id }))
|
|
139
|
+
})
|
|
105
140
|
client.get('/api/bilibili/dynamiclist', async (request, reply) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
141
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
142
|
+
type: "\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E" /* BilibiliDataType.用户主页动态列表数据 */,
|
|
143
|
+
cookie: this.bilibili
|
|
144
|
+
}, { host_mid: request.query.host_mid }))
|
|
145
|
+
})
|
|
109
146
|
client.get('/api/bilibili/dynamicinfo', async (request, reply) => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
147
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
148
|
+
type: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" /* BilibiliDataType.动态详情数据 */,
|
|
149
|
+
cookie: this.bilibili
|
|
150
|
+
}, { dynamic_id: request.query.dynamic_id }))
|
|
151
|
+
})
|
|
113
152
|
client.get('/api/bilibili/dynamicdard', async (request, reply) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
153
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
154
|
+
type: "\u52A8\u6001\u5361\u7247\u6570\u636E" /* BilibiliDataType.动态卡片数据 */,
|
|
155
|
+
cookie: this.bilibili
|
|
156
|
+
}, { dynamic_id: request.query.dynamic_id }))
|
|
157
|
+
})
|
|
117
158
|
client.get('/api/bilibili/userinfo', async (request, reply) => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
159
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
160
|
+
type: "\u7528\u6237\u4E3B\u9875\u6570\u636E" /* BilibiliDataType.用户主页数据 */,
|
|
161
|
+
cookie: this.bilibili
|
|
162
|
+
}, { host_mid: request.query.host_mid }))
|
|
163
|
+
})
|
|
121
164
|
client.get('/api/bilibili/liveroominfo', async (request, reply) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
165
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
166
|
+
type: "\u76F4\u64AD\u95F4\u4FE1\u606F" /* BilibiliDataType.直播间信息 */,
|
|
167
|
+
cookie: this.bilibili
|
|
168
|
+
}, { room_id: request.query.room_id }))
|
|
169
|
+
})
|
|
125
170
|
client.get('/api/bilibili/liveroominit', async (request, reply) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
171
|
+
reply.type('application/json').send(await BilibiliResult({
|
|
172
|
+
type: "\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" /* BilibiliDataType.直播间初始化信息 */,
|
|
173
|
+
cookie: this.bilibili
|
|
174
|
+
}, { room_id: request.query.room_id }))
|
|
175
|
+
})
|
|
129
176
|
return {
|
|
130
177
|
Instance: client,
|
|
131
178
|
GetDouyinData: this.GetDouyinData,
|
|
132
179
|
GetBilibiliData: this.GetBilibiliData
|
|
133
|
-
}
|
|
180
|
+
}
|
|
134
181
|
}
|
|
135
182
|
GetDouyinData = (data) => {
|
|
136
|
-
return
|
|
137
|
-
|
|
183
|
+
return {
|
|
184
|
+
result: () => {
|
|
185
|
+
throw new Error('该方法已废弃!请直接导入 GetBilibiliData 方法使用')
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
138
189
|
GetBilibiliData = (data) => {
|
|
139
|
-
return
|
|
140
|
-
|
|
190
|
+
return {
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated
|
|
193
|
+
*/
|
|
194
|
+
result: async () => {
|
|
195
|
+
throw new Error('该方法已废弃!请直接导入 GetBilibiliData 方法使用')
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
141
199
|
}
|
package/lib/server/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './client.js'
|
|
2
|
-
export * from './listen.js'
|
|
1
|
+
export * from './client.js'
|
|
2
|
+
export * from './listen.js'
|
package/lib/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './client.js'
|
|
2
|
-
export * from './listen.js'
|
|
1
|
+
export * from './client.js'
|
|
2
|
+
export * from './listen.js'
|
package/lib/server/listen.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FastifyInstance } from 'fastify'
|
|
1
|
+
import { FastifyInstance } from 'fastify'
|
|
2
2
|
/**
|
|
3
3
|
* 启动本地 http 服务
|
|
4
4
|
* @param client Fastify 实例
|
|
5
5
|
* @param port 监听端口
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const StartClient: (client: FastifyInstance, port: 4567) => Promise<void
|
|
8
|
+
export declare const StartClient: (client: FastifyInstance, port: 4567) => Promise<void>
|
package/lib/server/listen.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export const StartClient = async (client, port) => {
|
|
8
8
|
return client.listen({ port: port, host: '::' }, (_err, _address) => {
|
|
9
9
|
if (_err)
|
|
10
|
-
client.log.error(_err)
|
|
11
|
-
console.log(`amagi server listening on ${port} port. API docs: https://amagi.apifox.cn`)
|
|
12
|
-
})
|
|
13
|
-
}
|
|
10
|
+
client.log.error(_err)
|
|
11
|
+
console.log(`amagi server listening on ${port} port. API docs: https://amagi.apifox.cn`)
|
|
12
|
+
})
|
|
13
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
package/lib/types/ConfigType.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
package/lib/types/DataType.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|