@ikenxuan/amagi 2.1.1 → 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 +38 -9
- package/lib/business/bilibili/getid.js +5 -4
- package/lib/business/bilibili/result.d.ts +2 -2
- package/lib/business/bilibili/result.js +12 -2
- package/lib/business/douyin/API.js +1 -1
- package/lib/business/douyin/getdata.js +8 -2
- package/lib/business/douyin/getid.js +2 -1
- package/lib/business/douyin/result.d.ts +3 -3
- package/lib/business/douyin/result.js +9 -3
- package/lib/index.js +2 -2
- package/lib/model/index.d.ts +2 -1
- package/lib/model/index.js +2 -1
- package/lib/model/logger.d.ts +3 -0
- package/lib/model/logger.js +44 -0
- package/lib/model/networks.d.ts +4 -0
- package/lib/model/networks.js +20 -2
- package/lib/server/client.js +24 -0
- package/lib/server/listen.js +2 -1
- 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 +2 -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
|
}
|
|
@@ -102,8 +132,7 @@ export default class BilibiliData {
|
|
|
102
132
|
const result = await new Networks(options).getData();
|
|
103
133
|
if (result && result.code !== 0) {
|
|
104
134
|
const errorMessage = errorMap[result.code] || '未知错误';
|
|
105
|
-
|
|
106
|
-
return null;
|
|
135
|
+
throw new Error(`响应数据失败!\n请求接口类型:${this.type}\n请求URL:${options.url}\n错误代码:${result.code},\n含义:${errorMessage}`);
|
|
107
136
|
}
|
|
108
137
|
else {
|
|
109
138
|
return result;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Networks } from '../../model/index.js';
|
|
1
|
+
import { Networks, logger } from '../../model/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* return aweme_id
|
|
4
4
|
* @param {string} url 分享连接
|
|
@@ -11,7 +11,7 @@ export default async function GetBilibiliID(url) {
|
|
|
11
11
|
case /video\/([A-Za-z0-9]+)/.test(longLink): {
|
|
12
12
|
const bvideoMatch = longLink.match(/video\/([A-Za-z0-9]+)/);
|
|
13
13
|
result = {
|
|
14
|
-
type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* BilibiliDataType
|
|
14
|
+
type: "\u5355\u4E2A\u89C6\u9891\u4F5C\u54C1\u6570\u636E" /* BilibiliDataType.单个视频作品数据 */,
|
|
15
15
|
id: bvideoMatch ? bvideoMatch[1] : ''
|
|
16
16
|
};
|
|
17
17
|
break;
|
|
@@ -19,7 +19,7 @@ export default async function GetBilibiliID(url) {
|
|
|
19
19
|
case /play\/(\S+?)\??/.test(longLink): {
|
|
20
20
|
const playMatch = longLink.match(/play\/(\w+)/);
|
|
21
21
|
result = {
|
|
22
|
-
type: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" /* BilibiliDataType
|
|
22
|
+
type: "\u756A\u5267\u57FA\u672C\u4FE1\u606F\u6570\u636E" /* BilibiliDataType.番剧基本信息数据 */,
|
|
23
23
|
id: playMatch ? playMatch[1] : ''
|
|
24
24
|
};
|
|
25
25
|
break;
|
|
@@ -29,7 +29,7 @@ export default async function GetBilibiliID(url) {
|
|
|
29
29
|
const opusMatch = longLink.match(/^https:\/\/www\.bilibili\.com\/opus\/(\d+)/);
|
|
30
30
|
const dynamic_id = tMatch || opusMatch;
|
|
31
31
|
result = {
|
|
32
|
-
type: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" /* BilibiliDataType
|
|
32
|
+
type: "\u52A8\u6001\u8BE6\u60C5\u6570\u636E" /* BilibiliDataType.动态详情数据 */,
|
|
33
33
|
dynamic_id: dynamic_id ? dynamic_id[1] : ''
|
|
34
34
|
};
|
|
35
35
|
break;
|
|
@@ -37,5 +37,6 @@ export default async function GetBilibiliID(url) {
|
|
|
37
37
|
default:
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
|
+
logger.mark(result);
|
|
40
41
|
return result;
|
|
41
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BilibiliDataType, BilibiliOptionsType, GetDataResponseType } from '../../types/index.js';
|
|
2
|
-
interface
|
|
2
|
+
interface configParams {
|
|
3
3
|
/** 请求数据的类型 */
|
|
4
4
|
type: keyof typeof BilibiliDataType;
|
|
5
5
|
/** B站用户ck */
|
|
@@ -11,5 +11,5 @@ interface resultParams {
|
|
|
11
11
|
* @param config
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
export default function BilibiliResult(config:
|
|
14
|
+
export default function BilibiliResult(config: configParams | undefined, options: BilibiliOptionsType): Promise<GetDataResponseType | any>;
|
|
15
15
|
export {};
|
|
@@ -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
|
}
|
|
@@ -125,6 +128,9 @@ export default class DouyinData {
|
|
|
125
128
|
}
|
|
126
129
|
async GlobalGetData(options) {
|
|
127
130
|
const ResponseData = await new Networks(options).getData();
|
|
131
|
+
if (ResponseData === '') {
|
|
132
|
+
throw new Error('获取响应数据失败!抖音ck可能已经失效!\n请求类型:' + this.type + '\n请求URL:' + options.url);
|
|
133
|
+
}
|
|
128
134
|
return ResponseData;
|
|
129
135
|
}
|
|
130
136
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Networks } from '../../model/index.js';
|
|
1
|
+
import { logger, Networks } from '../../model/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* return aweme_id
|
|
4
4
|
* @param {string} url 视频分享连接
|
|
@@ -32,5 +32,6 @@ export default async function GetDouyinID(url) {
|
|
|
32
32
|
default:
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
|
+
logger.mark(result);
|
|
35
36
|
return result;
|
|
36
37
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DouyinDataType, DouyinOptionsType, GetDataResponseType } from '../../types/index.js';
|
|
2
|
-
interface
|
|
2
|
+
interface configParams {
|
|
3
3
|
/** 请求数据的类型 */
|
|
4
4
|
type: keyof typeof DouyinDataType;
|
|
5
|
-
/**
|
|
5
|
+
/** 抖音用户ck */
|
|
6
6
|
cookie: string;
|
|
7
7
|
}
|
|
8
|
-
export default function DouyinResult(config?:
|
|
8
|
+
export default function DouyinResult(config?: configParams, options?: DouyinOptionsType): Promise<GetDataResponseType>;
|
|
9
9
|
export {};
|
|
@@ -16,9 +16,15 @@ export default async function DouyinResult(config = { cookie: '' }, options = {}
|
|
|
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.评论数据 */: {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const hasaweme_id = options.aweme_id || null;
|
|
20
|
+
if (hasaweme_id) {
|
|
21
|
+
result = await new DouyinData(config.type, config.cookie).GetData({ aweme_id: options.aweme_id, number: options.number });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const defurl = options.url?.toString().match(/(http|https):\/\/.*\.(douyin|iesdouyin)\.com\/[^ ]+/g);
|
|
25
|
+
const iddata = await GetDouyinID(String(defurl));
|
|
26
|
+
result = await new DouyinData(config.type, config.cookie).GetData(iddata);
|
|
27
|
+
}
|
|
22
28
|
break;
|
|
23
29
|
}
|
|
24
30
|
default:
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const amagi = client;
|
|
|
15
15
|
*/
|
|
16
16
|
export const GetDouyinData = async (type, cookie = '', options = {}) => {
|
|
17
17
|
const data = await DouyinResult({ type, cookie }, options);
|
|
18
|
-
return data;
|
|
18
|
+
return data.data;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
@@ -26,5 +26,5 @@ export const GetDouyinData = async (type, cookie = '', options = {}) => {
|
|
|
26
26
|
*/
|
|
27
27
|
export const GetBilibiliData = async (type, cookie = '', options = {}) => {
|
|
28
28
|
const data = await BilibiliResult({ type, cookie }, options);
|
|
29
|
-
return data;
|
|
29
|
+
return data.data;
|
|
30
30
|
};
|
package/lib/model/index.d.ts
CHANGED
package/lib/model/index.js
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import log4js from 'log4js'
|
|
2
|
+
log4js.configure({
|
|
3
|
+
appenders: {
|
|
4
|
+
console: {
|
|
5
|
+
type: 'stdout',
|
|
6
|
+
layout: {
|
|
7
|
+
type: 'pattern',
|
|
8
|
+
pattern: '%[[amagi][%d{hh:mm:ss.SSS}][%4.4p]%] %m'
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
command: {
|
|
12
|
+
type: 'dateFile',
|
|
13
|
+
filename: 'logs/command',
|
|
14
|
+
pattern: 'yyyy-MM-dd.log',
|
|
15
|
+
numBackups: 15,
|
|
16
|
+
alwaysIncludePattern: true,
|
|
17
|
+
layout: {
|
|
18
|
+
type: 'pattern',
|
|
19
|
+
pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
pluginConsole: {
|
|
23
|
+
type: 'stdout',
|
|
24
|
+
layout: {
|
|
25
|
+
type: 'pattern',
|
|
26
|
+
pattern: '%[[%d{hh:mm:ss.SSS}][%4.4p][plugin]%] %m'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
pluginCommand: {
|
|
30
|
+
type: 'dateFile',
|
|
31
|
+
filename: 'logs/pluginCommand',
|
|
32
|
+
pattern: 'yyyy-MM-dd.log',
|
|
33
|
+
numBackups: 15,
|
|
34
|
+
alwaysIncludePattern: true,
|
|
35
|
+
layout: { type: 'pattern', pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m' }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
categories: {
|
|
39
|
+
default: { appenders: [ 'console', 'command' ], level: 'info' } // 添加default类别
|
|
40
|
+
},
|
|
41
|
+
pm2: true
|
|
42
|
+
})
|
|
43
|
+
const logger = log4js.getLogger()
|
|
44
|
+
export default logger
|
package/lib/model/networks.d.ts
CHANGED
package/lib/model/networks.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosError } from 'axios'
|
|
2
|
+
import logger from './logger.js'
|
|
2
3
|
export default class Networks {
|
|
3
4
|
url
|
|
4
5
|
method
|
|
@@ -47,7 +48,7 @@ export default class Networks {
|
|
|
47
48
|
return result
|
|
48
49
|
}
|
|
49
50
|
catch (error) {
|
|
50
|
-
|
|
51
|
+
logger.info(error)
|
|
51
52
|
return false
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -94,7 +95,7 @@ export default class Networks {
|
|
|
94
95
|
return result
|
|
95
96
|
}
|
|
96
97
|
if (result.status === 429) {
|
|
97
|
-
|
|
98
|
+
logger.error('HTTP 响应状态码: 429')
|
|
98
99
|
throw new Error('ratelimit triggered, 触发 https://www.douyin.com/ 的速率限制!!!')
|
|
99
100
|
}
|
|
100
101
|
this.axiosInstance = result
|
|
@@ -112,4 +113,21 @@ export default class Networks {
|
|
|
112
113
|
return false
|
|
113
114
|
}
|
|
114
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
|
+
}
|
|
115
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.评论数据 */,
|
package/lib/server/listen.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from '../model/index.js'
|
|
1
2
|
/**
|
|
2
3
|
* 启动本地 http 服务
|
|
3
4
|
* @param client Fastify 实例
|
|
@@ -8,6 +9,6 @@ export const StartClient = async (client, port) => {
|
|
|
8
9
|
return client.listen({ port: port, host: '::' }, (_err, _address) => {
|
|
9
10
|
if (_err)
|
|
10
11
|
client.log.error(_err)
|
|
11
|
-
|
|
12
|
+
logger.mark(`amagi server listening on ${port} port. API docs: https://amagi.apifox.cn`)
|
|
12
13
|
})
|
|
13
14
|
}
|
|
@@ -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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikenxuan/amagi",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"axios": "^1.7.3",
|
|
33
33
|
"fastify": "^4.28.1",
|
|
34
|
+
"log4js": "6.9.0",
|
|
34
35
|
"md5": "^2.3.0",
|
|
35
36
|
"pino-pretty": "^11.2.2"
|
|
36
37
|
},
|