@ikenxuan/amagi 2.0.1 → 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.
Files changed (40) hide show
  1. package/README.md +5 -10
  2. package/lib/business/bilibili/getdata.d.ts +2 -2
  3. package/lib/business/bilibili/getdata.js +1 -1
  4. package/lib/business/bilibili/result.d.ts +12 -5
  5. package/lib/business/bilibili/result.js +33 -40
  6. package/lib/business/douyin/getdata.d.ts +2 -2
  7. package/lib/business/douyin/getdata.js +24 -13
  8. package/lib/business/douyin/result.d.ts +6 -5
  9. package/lib/business/douyin/result.js +29 -42
  10. package/lib/business/douyin/sign/a_bogus.js +8 -8
  11. package/lib/business/index.d.ts +2 -2
  12. package/lib/business/index.js +2 -2
  13. package/lib/index.d.ts +17 -0
  14. package/lib/index.js +23 -0
  15. package/lib/model/dir.d.ts +3 -3
  16. package/lib/model/dir.js +6 -6
  17. package/lib/model/index.d.ts +3 -3
  18. package/lib/model/index.js +3 -3
  19. package/lib/model/networks.d.ts +13 -17
  20. package/lib/model/networks.js +49 -83
  21. package/lib/server/client.d.ts +22 -13
  22. package/lib/server/client.js +138 -80
  23. package/lib/server/index.d.ts +2 -2
  24. package/lib/server/index.js +2 -2
  25. package/lib/server/listen.d.ts +2 -2
  26. package/lib/server/listen.js +4 -4
  27. package/lib/types/BilibiliAPIParams.d.ts +1 -1
  28. package/lib/types/BilibiliAPIParams.js +1 -1
  29. package/lib/types/ConfigType.js +1 -1
  30. package/lib/types/DataType.js +1 -1
  31. package/lib/types/DouyinAPIParams.d.ts +1 -1
  32. package/lib/types/DouyinAPIParams.js +1 -1
  33. package/lib/types/GetDataResponseType.js +1 -1
  34. package/lib/types/NetworksConfigType.js +1 -1
  35. package/lib/types/OptionsType.js +1 -1
  36. package/lib/types/Request.d.ts +2 -2
  37. package/lib/types/Request.js +1 -1
  38. package/lib/types/index.d.ts +9 -9
  39. package/lib/types/index.js +1 -1
  40. package/package.json +1 -1
@@ -1,70 +1,70 @@
1
- import axios, { AxiosError } 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; // axios中获取最终的请求URL
60
+ const result = await this.returnResult()
61
+ return result.request.res.responseUrl // axios中获取最终的请求URL
62
62
  }
63
63
  catch (error) {
64
64
  if (error instanceof AxiosError) {
65
- throw new Error(error.stack);
65
+ throw new Error(error.stack)
66
66
  }
67
- return '';
67
+ return ''
68
68
  }
69
69
  }
70
70
  /** 获取首个302 */
@@ -75,75 +75,41 @@ export default class Networks {
75
75
  url: this.url,
76
76
  maxRedirects: 0, // 禁止跟随重定向
77
77
  validateStatus: (status) => status >= 300 && status < 400 // 仅处理3xx响应
78
- });
79
- return response.headers['location'];
78
+ })
79
+ return response.headers['location']
80
80
  }
81
81
  catch (error) {
82
82
  if (error instanceof AxiosError) {
83
- throw new Error(error.stack);
83
+ throw new Error(error.stack)
84
84
  }
85
- return '';
85
+ return ''
86
86
  }
87
87
  }
88
88
  /** 获取数据并处理数据的格式化,默认json */
89
89
  async getData (new_fetch = '') {
90
90
  try {
91
91
  if (!new_fetch) {
92
- const result = await this.returnResult();
92
+ const result = await this.returnResult()
93
93
  if (result.status === 504) {
94
- return result;
94
+ return result
95
95
  }
96
96
  if (result.status === 429) {
97
- console.warn('HTTP 响应状态码: 429');
98
- throw new Error('ratelimit triggered, 触发 https://www.douyin.com/ 的速率限制!!!');
97
+ console.warn('HTTP 响应状态码: 429')
98
+ throw new Error('ratelimit triggered, 触发 https://www.douyin.com/ 的速率限制!!!')
99
99
  }
100
- this.axiosInstance = result;
101
- this.isGetResult = true;
100
+ this.axiosInstance = result
101
+ this.isGetResult = true
102
102
  }
103
103
  else {
104
- this.axiosInstance = new_fetch;
105
- }
106
- switch (this.type) {
107
- case 'json':
108
- await this.Tojson();
109
- break;
110
- case 'text':
111
- await this.ToText();
112
- break;
113
- case 'arrayBuffer':
114
- await this.ToArrayBuffer();
115
- break;
116
- case 'blob':
117
- await this.ToBlob();
118
- break;
119
- default:
104
+ this.axiosInstance = new_fetch
120
105
  }
121
- return this.axiosInstance;
106
+ return this.axiosInstance.data
122
107
  }
123
108
  catch (error) {
124
109
  if (error instanceof AxiosError) {
125
- throw new Error(error.stack);
110
+ throw new Error(error.stack)
126
111
  }
127
- return false;
128
- }
129
- }
130
- async Tojson () {
131
- if (this.axiosInstance.headers['content-type'].includes('json')) {
132
- this.axiosInstance = this.axiosInstance.data;
112
+ return false
133
113
  }
134
- else {
135
- this.axiosInstance = this.axiosInstance.data;
136
- this.type = 'text';
137
- }
138
- }
139
- async ToText () {
140
- this.axiosInstance = this.axiosInstance.data;
141
- }
142
- async ToArrayBuffer () {
143
- this.axiosInstance = this.axiosInstance.data;
144
- }
145
- async ToBlob () {
146
- // axios 没有直接支持blob, 需要使用arraybuffer然后转换
147
- this.axiosInstance = new Blob([new Uint8Array(this.axiosInstance.data)]);
148
114
  }
149
115
  }
@@ -1,7 +1,5 @@
1
- import { BilibiliResult } from '../business/bilibili/index.js';
2
- import { DouyinResult } from '../business/douyin/index.js';
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
- }) => DouyinResult;
18
- /** 获取B站接口数据 */
18
+ }) => Error | any;
19
+ /**
20
+ * amagi.GetBilibiliData 已废弃!请直接导入 GetBilibiliData 方法使用
21
+ * @deprecated
22
+ */
19
23
  GetBilibiliData: (data: {
20
24
  type: keyof typeof BilibiliDataType;
21
- }) => BilibiliResult;
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
- }) => DouyinResult;
45
+ }) => Error | any
42
46
  GetBilibiliData: (data: {
43
47
  type: keyof typeof BilibiliDataType;
44
- }) => BilibiliResult;
48
+ }) => {
49
+ /**
50
+ * @deprecated
51
+ */
52
+ result: () => Promise<never>;
53
+ }
45
54
  }
46
- export {};
55
+ export {}
@@ -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
- const url = request.query.url;
46
- reply.type('application/json').send(await new DouyinResult("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* DouyinDataType.单个视频作品数据 */, this.douyin).result({ url }));
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
- const url = request.query.url;
50
- reply.type('application/json').send(await new DouyinResult("\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.评论数据 */, this.douyin).result({ url }));
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
- const { aweme_id, comment_id } = request.query;
54
- reply.type('application/json').send(await new DouyinResult("\u4E8C\u7EA7\u8BC4\u8BBA\u6570\u636E" /* DouyinDataType.二级评论数据 */, this.douyin).result({ aweme_id, comment_id }));
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
- const sec_uid = request.query.sec_uid;
58
- reply.type('application/json').send(await new DouyinResult("\u7528\u6237\u4E3B\u9875\u6570\u636E" /* DouyinDataType.用户主页数据 */, this.douyin).result({ sec_uid }));
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
- const sec_uid = request.query.sec_uid;
62
- reply.type('application/json').send(await new DouyinResult("\u7528\u6237\u4E3B\u9875\u89C6\u9891\u5217\u8868\u6570\u636E" /* DouyinDataType.用户主页视频列表数据 */, this.douyin).result({ sec_uid }));
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
- const query = request.query.query;
66
- reply.type('application/json').send(await new DouyinResult("\u70ED\u70B9\u8BCD\u6570\u636E" /* DouyinDataType.热点词数据 */, this.douyin).result({ query }));
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
- const query = request.query.query;
70
- reply.type('application/json').send(await new DouyinResult("\u641C\u7D22\u6570\u636E" /* DouyinDataType.搜索数据 */, this.douyin).result({ query }));
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 new DouyinResult("\u5B98\u65B9emoji\u6570\u636E" /* DouyinDataType.官方emoji数据 */, this.douyin).result());
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 new DouyinResult("\u52A8\u6001\u8868\u60C5\u6570\u636E" /* DouyinDataType.动态表情数据 */, this.douyin).result());
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
- const music_id = request.query.music_id;
80
- reply.type('application/json').send(await new DouyinResult("\u97F3\u4E50\u6570\u636E" /* DouyinDataType.音乐数据 */, this.douyin).result({ music_id }));
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
- const music_id = request.query.music_id;
84
- reply.type('application/json').send(await new DouyinResult("\u5B9E\u51B5\u56FE\u7247\u56FE\u96C6\u6570\u636E" /* DouyinDataType.实况图片图集数据 */, this.douyin).result({ music_id }));
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
- const url = request.query.url;
88
- reply.type('application/json').send(await new BilibiliResult("\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* BilibiliDataType.单个视频作品数据 */, this.bilibili).result({ url }));
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
- const bvid = request.query.bvid;
92
- reply.type('application/json').send(await new BilibiliResult("\u8BC4\u8BBA\u6570\u636E" /* BilibiliDataType.评论数据 */, this.bilibili).result({ bvid }));
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 new BilibiliResult("emoji\u6570\u636E" /* BilibiliDataType.emoji数据 */, this.bilibili).result());
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
- const url = request.query.url;
99
- reply.type('application/json').send(await new BilibiliResult("\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.番剧基本信息数据 */, this.bilibili).result({ url }));
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
- const { cid, ep_id } = request.query;
103
- reply.type('application/json').send(await new BilibiliResult("\u756A\u5267\u4E0B\u8F7D\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.番剧下载信息数据 */, this.bilibili).result({ cid, ep_id }));
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
- const host_mid = request.query.host_mid;
107
- reply.type('application/json').send(await new BilibiliResult("\u7528\u6237\u4E3B\u9875\u52A8\u6001\u5217\u8868\u6570\u636E" /* BilibiliDataType.用户主页动态列表数据 */, this.bilibili).result({ host_mid }));
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
- const dynamic_id = request.query.dynamic_id;
111
- reply.type('application/json').send(await new BilibiliResult("\u52A8\u6001\u8BE6\u60C5\u6570\u636E" /* BilibiliDataType.动态详情数据 */, this.bilibili).result({ dynamic_id }));
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
- const dynamic_id = request.query.dynamic_id;
115
- reply.type('application/json').send(await new BilibiliResult("\u52A8\u6001\u5361\u7247\u6570\u636E" /* BilibiliDataType.动态卡片数据 */, this.bilibili).result({ dynamic_id }));
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
- const host_mid = request.query.host_mid;
119
- reply.type('application/json').send(await new BilibiliResult("\u7528\u6237\u4E3B\u9875\u6570\u636E" /* BilibiliDataType.用户主页数据 */, this.bilibili).result({ host_mid }));
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
- const room_id = request.query.room_id;
123
- reply.type('application/json').send(await new BilibiliResult("\u76F4\u64AD\u95F4\u4FE1\u606F" /* BilibiliDataType.直播间信息 */, this.bilibili).result({ room_id }));
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
- const room_id = request.query.room_id;
127
- reply.type('application/json').send(await new BilibiliResult("\u76F4\u64AD\u95F4\u521D\u59CB\u5316\u4FE1\u606F" /* BilibiliDataType.直播间初始化信息 */, this.bilibili).result({ room_id }));
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 new DouyinResult(data.type, this.douyin, true);
137
- };
183
+ return {
184
+ result: () => {
185
+ throw new Error('该方法已废弃!请直接导入 GetBilibiliData 方法使用')
186
+ }
187
+ }
188
+ }
138
189
  GetBilibiliData = (data) => {
139
- return new BilibiliResult(data.type, this.bilibili, true);
140
- };
190
+ return {
191
+ /**
192
+ * @deprecated
193
+ */
194
+ result: async () => {
195
+ throw new Error('该方法已废弃!请直接导入 GetBilibiliData 方法使用')
196
+ }
197
+ }
198
+ }
141
199
  }
@@ -1,2 +1,2 @@
1
- export * from './client.js';
2
- export * from './listen.js';
1
+ export * from './client.js'
2
+ export * from './listen.js'
@@ -1,2 +1,2 @@
1
- export * from './client.js';
2
- export * from './listen.js';
1
+ export * from './client.js'
2
+ export * from './listen.js'
@@ -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>
@@ -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
+ }
@@ -58,4 +58,4 @@ export type BilibiliAPIParams = {
58
58
  LiveRoomParams: LiveRoomParams;
59
59
  QrcodeParams: QrcodeParams;
60
60
  };
61
- export {};
61
+ export {}
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -35,4 +35,4 @@ export type DouyinAPIParams = {
35
35
  MusicParams: MusicParams;
36
36
  LiveRoomParams: LiveRoomParams;
37
37
  };
38
- export {};
38
+ export {}
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1,5 +1,5 @@
1
- import { FastifyRequest } from 'fastify';
2
- import { BilibiliOptionsType, DouyinOptionsType } from './OptionsType.js';
1
+ import { FastifyRequest } from 'fastify'
2
+ import { BilibiliOptionsType, DouyinOptionsType } from './OptionsType.js'
3
3
  export interface DouyinRequest extends FastifyRequest {
4
4
  Querystring: DouyinOptionsType;
5
5
  }
@@ -1 +1 @@
1
- export {};
1
+ export {}
@@ -1,9 +1,9 @@
1
- import { type BilibiliAPIParams } from './BilibiliAPIParams.js';
2
- import { type ConfigType } from './ConfigType.js';
3
- import { BilibiliDataType, DouyinDataType } from './DataType.js';
4
- import { type DouyinAPIParams } from './DouyinAPIParams.js';
5
- import { type GetDataResponseType } from './GetDataResponseType.js';
6
- import { type NetworksConfigType } from './NetworksConfigType.js';
7
- import { type BilibiliOptionsType, type DouyinOptionsType } from './OptionsType.js';
8
- export * from './Request.js';
9
- export { BilibiliAPIParams, BilibiliDataType, BilibiliOptionsType, ConfigType, DouyinAPIParams, DouyinDataType, DouyinOptionsType, GetDataResponseType, NetworksConfigType };
1
+ import { type BilibiliAPIParams } from './BilibiliAPIParams.js'
2
+ import { type ConfigType } from './ConfigType.js'
3
+ import { BilibiliDataType, DouyinDataType } from './DataType.js'
4
+ import { type DouyinAPIParams } from './DouyinAPIParams.js'
5
+ import { type GetDataResponseType } from './GetDataResponseType.js'
6
+ import { type NetworksConfigType } from './NetworksConfigType.js'
7
+ import { type BilibiliOptionsType, type DouyinOptionsType } from './OptionsType.js'
8
+ export * from './Request.js'
9
+ export { BilibiliAPIParams, BilibiliDataType, BilibiliOptionsType, ConfigType, DouyinAPIParams, DouyinDataType, DouyinOptionsType, GetDataResponseType, NetworksConfigType }
@@ -1 +1 @@
1
- export * from './Request.js';
1
+ export * from './Request.js'