@ikenxuan/amagi 4.2.6-pr90.bbf3add → 4.2.6-pr90.cfc768c
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 +15 -52
- package/lib/cli/pr.d.ts +2 -0
- package/lib/cli/pr.js +93 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +9 -0
- package/lib/model/DataFetchers.d.ts +47 -0
- package/lib/model/DataFetchers.js +56 -0
- package/lib/model/index.d.ts +4 -0
- package/lib/model/index.js +4 -0
- package/lib/model/logger.d.ts +17 -0
- package/lib/model/logger.js +55 -0
- package/lib/model/networks.d.ts +32 -0
- package/lib/model/networks.js +141 -0
- package/lib/model/tools.d.ts +9 -0
- package/lib/model/tools.js +20 -0
- package/lib/platform/bilibili/API.d.ts +28 -0
- package/lib/platform/bilibili/API.js +64 -0
- package/lib/platform/bilibili/getdata.d.ts +2 -0
- package/lib/platform/bilibili/getdata.js +344 -0
- package/lib/platform/bilibili/index.d.ts +7 -0
- package/lib/platform/bilibili/index.js +7 -0
- package/lib/platform/bilibili/qtparam.d.ts +13 -0
- package/lib/platform/bilibili/qtparam.js +16 -0
- package/lib/platform/bilibili/routes.d.ts +7 -0
- package/lib/platform/bilibili/routes.js +120 -0
- package/lib/platform/bilibili/sign/CorrespondPath.d.ts +1 -0
- package/lib/platform/bilibili/sign/CorrespondPath.js +11 -0
- package/lib/platform/bilibili/sign/bv2av.d.ts +2 -0
- package/lib/platform/bilibili/sign/bv2av.js +26 -0
- package/lib/platform/bilibili/sign/wbi.d.ts +1 -0
- package/lib/platform/bilibili/sign/wbi.js +55 -0
- package/lib/platform/douyin/API.d.ts +22 -0
- package/lib/platform/douyin/API.js +45 -0
- package/lib/platform/douyin/getdata.d.ts +2 -0
- package/lib/platform/douyin/getdata.js +257 -0
- package/lib/platform/douyin/index.d.ts +5 -0
- package/lib/platform/douyin/index.js +5 -0
- package/lib/platform/douyin/routes.d.ts +7 -0
- package/lib/platform/douyin/routes.js +83 -0
- package/lib/platform/douyin/sign/a_bogus.d.ts +2 -0
- package/lib/platform/douyin/sign/a_bogus.js +464 -0
- package/lib/platform/douyin/sign/index.d.ts +8 -0
- package/lib/platform/douyin/sign/index.js +36 -0
- package/lib/platform/index.d.ts +3 -0
- package/lib/platform/index.js +3 -0
- package/lib/platform/kuaishou/API.d.ts +47 -0
- package/lib/platform/kuaishou/API.js +47 -0
- package/lib/platform/kuaishou/getdata.d.ts +2 -0
- package/lib/platform/kuaishou/getdata.js +63 -0
- package/lib/platform/kuaishou/index.d.ts +4 -0
- package/lib/platform/kuaishou/index.js +4 -0
- package/lib/platform/kuaishou/routes.d.ts +7 -0
- package/lib/platform/kuaishou/routes.js +28 -0
- package/lib/server/client.d.ts +90 -0
- package/lib/server/client.js +126 -0
- package/lib/server/index.d.ts +2 -0
- package/lib/server/index.js +2 -0
- package/lib/server/listen.d.ts +8 -0
- package/lib/server/listen.js +14 -0
- package/lib/test.d.ts +1 -0
- package/lib/test.js +18 -0
- package/lib/types/BilibiliAPIParams.d.ts +160 -0
- package/lib/types/BilibiliAPIParams.js +1 -0
- package/lib/types/DouyinAPIParams.d.ts +160 -0
- package/lib/types/DouyinAPIParams.js +1 -0
- package/lib/types/KuaishouAPIParams.d.ts +31 -0
- package/lib/types/KuaishouAPIParams.js +1 -0
- package/lib/types/NetworksConfigType.d.ts +34 -0
- package/lib/types/NetworksConfigType.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/AV2BV.d.ts +11 -0
- package/lib/types/ReturnDataType/Bilibili/AV2BV.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/BV2AV.d.ts +11 -0
- package/lib/types/ReturnDataType/Bilibili/BV2AV.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/BangumiVideoInfo.d.ts +421 -0
- package/lib/types/ReturnDataType/Bilibili/BangumiVideoInfo.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/BangumiVideoPlayurl.d.ts +67 -0
- package/lib/types/ReturnDataType/Bilibili/BangumiVideoPlayurl.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/DynamicCard.d.ts +130 -0
- package/lib/types/ReturnDataType/Bilibili/DynamicCard.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/DynamicInfo.d.ts +440 -0
- package/lib/types/ReturnDataType/Bilibili/DynamicInfo.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/EmojiList.d.ts +72 -0
- package/lib/types/ReturnDataType/Bilibili/EmojiList.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/LiveRoomDef.d.ts +27 -0
- package/lib/types/ReturnDataType/Bilibili/LiveRoomDef.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/LiveRoomDetail.d.ts +91 -0
- package/lib/types/ReturnDataType/Bilibili/LiveRoomDetail.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/Login/CheckQrcode.d.ts +36 -0
- package/lib/types/ReturnDataType/Bilibili/Login/CheckQrcode.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/Login/NewLoginQrcode.d.ts +13 -0
- package/lib/types/ReturnDataType/Bilibili/Login/NewLoginQrcode.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/Login/index.d.ts +2 -0
- package/lib/types/ReturnDataType/Bilibili/Login/index.js +2 -0
- package/lib/types/ReturnDataType/Bilibili/OneWork.d.ts +144 -0
- package/lib/types/ReturnDataType/Bilibili/OneWork.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/UserDynamic.d.ts +878 -0
- package/lib/types/ReturnDataType/Bilibili/UserDynamic.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/UserFullView.d.ts +24 -0
- package/lib/types/ReturnDataType/Bilibili/UserFullView.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/UserProfile.d.ts +136 -0
- package/lib/types/ReturnDataType/Bilibili/UserProfile.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/VideoPlayurl.d.ts +117 -0
- package/lib/types/ReturnDataType/Bilibili/VideoPlayurl.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/WorkComments.d.ts +1535 -0
- package/lib/types/ReturnDataType/Bilibili/WorkComments.js +1 -0
- package/lib/types/ReturnDataType/Bilibili/index.d.ts +16 -0
- package/lib/types/ReturnDataType/Bilibili/index.js +16 -0
- package/lib/types/ReturnDataType/Douyin/EmojiList.d.ts +19 -0
- package/lib/types/ReturnDataType/Douyin/EmojiList.js +1 -0
- package/lib/types/ReturnDataType/Douyin/EmojiProList.d.ts +542 -0
- package/lib/types/ReturnDataType/Douyin/EmojiProList.js +1 -0
- package/lib/types/ReturnDataType/Douyin/ImageAlbumWork.d.ts +688 -0
- package/lib/types/ReturnDataType/Douyin/ImageAlbumWork.js +1 -0
- package/lib/types/ReturnDataType/Douyin/MusicWork.d.ts +229 -0
- package/lib/types/ReturnDataType/Douyin/MusicWork.js +1 -0
- package/lib/types/ReturnDataType/Douyin/SearchInfo.d.ts +828 -0
- package/lib/types/ReturnDataType/Douyin/SearchInfo.js +1 -0
- package/lib/types/ReturnDataType/Douyin/SlidesWork.d.ts +773 -0
- package/lib/types/ReturnDataType/Douyin/SlidesWork.js +1 -0
- package/lib/types/ReturnDataType/Douyin/SuggestWords.d.ts +68 -0
- package/lib/types/ReturnDataType/Douyin/SuggestWords.js +1 -0
- package/lib/types/ReturnDataType/Douyin/UserInfo.d.ts +325 -0
- package/lib/types/ReturnDataType/Douyin/UserInfo.js +1 -0
- package/lib/types/ReturnDataType/Douyin/UserLiveVideos.d.ts +2084 -0
- package/lib/types/ReturnDataType/Douyin/UserLiveVideos.js +1 -0
- package/lib/types/ReturnDataType/Douyin/UserPostVideos.d.ts +915 -0
- package/lib/types/ReturnDataType/Douyin/UserPostVideos.js +1 -0
- package/lib/types/ReturnDataType/Douyin/VideoWork.d.ts +744 -0
- package/lib/types/ReturnDataType/Douyin/VideoWork.js +1 -0
- package/lib/types/ReturnDataType/Douyin/WorkComments.d.ts +647 -0
- package/lib/types/ReturnDataType/Douyin/WorkComments.js +1 -0
- package/lib/types/ReturnDataType/Douyin/index.d.ts +12 -0
- package/lib/types/ReturnDataType/Douyin/index.js +12 -0
- package/lib/types/ReturnDataType/Kuaishou/EmojiList.d.ts +601 -0
- package/lib/types/ReturnDataType/Kuaishou/EmojiList.js +1 -0
- package/lib/types/ReturnDataType/Kuaishou/OneWork.d.ts +298 -0
- package/lib/types/ReturnDataType/Kuaishou/OneWork.js +1 -0
- package/lib/types/ReturnDataType/Kuaishou/WorkComments.d.ts +51 -0
- package/lib/types/ReturnDataType/Kuaishou/WorkComments.js +1 -0
- package/lib/types/ReturnDataType/Kuaishou/index.d.ts +3 -0
- package/lib/types/ReturnDataType/Kuaishou/index.js +3 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.js +1 -0
- package/package.json +9 -21
- package/dist/cjs/index.cjs +0 -2059
- package/dist/cjs/index.d.cts +0 -13717
- package/dist/esm/index.d.ts +0 -13717
- package/dist/esm/index.mjs +0 -2021
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# amagi
|
|
1
|
+
# amagi(泥干嘛哈哈
|
|
2
2
|
|
|
3
|
-
* 抖音、B站的 web 端相关数据接口基于 Node.js 的实现,支持最低node版本为
|
|
3
|
+
* 抖音、B站的 web 端相关数据接口基于 Node.js 的实现,支持最低node版本为 v18
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
## 使用
|
|
8
|
+
## 使用
|
|
9
9
|
```
|
|
10
10
|
pnpm add @ikenxuan/amagi
|
|
11
11
|
```
|
|
12
|
-
## 快速上手
|
|
12
|
+
## 快速上手
|
|
13
13
|
|
|
14
14
|
**_直接获取相关数据_**
|
|
15
15
|
```js
|
|
@@ -19,27 +19,21 @@ const douyinck = '你的抖音ck'
|
|
|
19
19
|
const bilibilick = '你的B站ck'
|
|
20
20
|
|
|
21
21
|
// 方法1
|
|
22
|
-
getDouyinData('单个视频作品数据', douyinck, { aweme_id: '7403311630219578660' })
|
|
23
|
-
|
|
24
|
-
.catch(err => console.error(err))
|
|
25
|
-
|
|
26
|
-
getBilibiliData('单个视频作品数据', bilibilick, { bvid: 'BV1Nx4y147n3' })
|
|
27
|
-
.then(data => console.log('B站' + data))
|
|
28
|
-
.catch(err => console.error(err))
|
|
22
|
+
const Douyin = await getDouyinData('单个视频作品数据', douyinck, { aweme_id: '7403311630219578660' })
|
|
23
|
+
const Bilibili = await getBilibiliData('单个视频作品数据', bilibilick, { bvid: 'BV1Nx4y147n3' })
|
|
29
24
|
|
|
30
25
|
// 方法2
|
|
31
26
|
const amagi = new Client({
|
|
32
27
|
douyin: douyinck,
|
|
33
28
|
bilibili: bilibilick
|
|
34
29
|
})
|
|
35
|
-
amagi.getDouyinData('评论数据', { aweme_id: '7403311630219578660', number: 25 })
|
|
36
|
-
|
|
37
|
-
.catch(err => console.error(err))
|
|
30
|
+
const dydt1 = await amagi.getDouyinData('评论数据', { aweme_id: '7403311630219578660', number: 25 })
|
|
31
|
+
|
|
38
32
|
```
|
|
39
33
|
|
|
40
|
-
* 参数一详见 [
|
|
34
|
+
* 参数一详见 [**API数据类型枚举**](./src/types/DataType.ts)
|
|
41
35
|
|
|
42
|
-
*
|
|
36
|
+
* 传递对象的参数详见 [**抖音接口请求参数类型**](./src/types/DouyinAPIParams.ts)、[**B站接口请求参数类型**](./src/types/BilibiliAPIParams.ts) 或参照 [**API 文档**](https://amagi.apifox.cn)
|
|
43
37
|
|
|
44
38
|
---
|
|
45
39
|
|
|
@@ -57,59 +51,28 @@ const Client = new amagi({
|
|
|
57
51
|
Client.startClient(4567) // 监听端口
|
|
58
52
|
```
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
```js
|
|
62
|
-
const Client = require('@ikenxuan/amagi').default
|
|
63
|
-
const { getBilibiliData } = require('@ikenxuan/amagi')
|
|
64
|
-
|
|
65
|
-
const douyinck = '你的抖音ck'
|
|
66
|
-
const bilibilick = '你的B站ck'
|
|
67
|
-
|
|
68
|
-
// 初始化
|
|
69
|
-
const amagi = new Client({
|
|
70
|
-
douyin: douyinck,
|
|
71
|
-
bilibili: bilibilick
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
// 启动http服务
|
|
75
|
-
amagi.startClient(6666)
|
|
76
|
-
|
|
77
|
-
// 获取抖音评论数据
|
|
78
|
-
amagi.getDouyinData('评论数据', { aweme_id: '7403311630219578660', number: 25 })
|
|
79
|
-
.then(data => console.log('抖音:' + data))
|
|
80
|
-
.catch(err => console.error(err))
|
|
81
|
-
|
|
82
|
-
// 获取B站视频信息
|
|
83
|
-
getBilibiliData('单个视频作品数据', bilibilick, { bvid: 'BV1Nx4y147n3' })
|
|
84
|
-
.then(data => console.log('B站' + data))
|
|
85
|
-
.catch(err => console.error(err))
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## 开发构建 🛠️
|
|
89
|
-
|
|
90
|
-
> [!IMPORTANT]
|
|
54
|
+
## 开发构建
|
|
91
55
|
> **开发环境下,支持最低node版本为 v18**
|
|
92
56
|
|
|
93
|
-
* [**fork**](https://github.com/ikenxuan/amagi/fork) 项目到自己的仓库并克隆到本地
|
|
94
57
|
* 安装依赖
|
|
95
58
|
```
|
|
96
59
|
pnpm install
|
|
97
60
|
```
|
|
98
|
-
*
|
|
61
|
+
* 构建
|
|
99
62
|
```
|
|
100
63
|
pnpm build
|
|
101
64
|
```
|
|
102
65
|
|
|
103
|
-
## License
|
|
66
|
+
## License
|
|
104
67
|
[GPL-3.0](https://github.com/ikenxuan/amagi/blob/main/LICENSE)
|
|
105
68
|
|
|
106
|
-
## 声明
|
|
69
|
+
## 声明
|
|
107
70
|
本库没有后门,本库不会上传有关你的任何信息到第三方。
|
|
108
71
|
所配置的ck只会用于请求官方API接口
|
|
109
72
|
|
|
110
73
|
<h2>未经同意,禁止将本项目的开源代码用于任何商业目的。因使用本项目产生的一切问题与后果由使用者自行承担,项目开发者不承担任何责任</h2>
|
|
111
74
|
|
|
112
|
-
## amagi
|
|
75
|
+
## amagi 的诞生参考了以下开源项目:
|
|
113
76
|
- [SocialSisterYi/bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect)
|
|
114
77
|
- [NearHuiwen/TiktokDouyinCrawler](https://github.com/NearHuiwen/TiktokDouyinCrawler)
|
|
115
78
|
- [Evil0ctal/Douyin_TikTok_Download_API](https://github.com/Evil0ctal/Douyin_TikTok_Download_API)
|
package/lib/cli/pr.d.ts
ADDED
package/lib/cli/pr.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
/**
|
|
4
|
+
* @description 获取package.json路径
|
|
5
|
+
*/
|
|
6
|
+
const getPkgPath = () => process.cwd() + '/package.json';
|
|
7
|
+
/**
|
|
8
|
+
* @description 读取package.json
|
|
9
|
+
*/
|
|
10
|
+
const readPkg = () => JSON.parse(fs.readFileSync(getPkgPath(), 'utf-8'));
|
|
11
|
+
/**
|
|
12
|
+
* @description 写入package.json
|
|
13
|
+
* @param pkg package.json
|
|
14
|
+
*/
|
|
15
|
+
const writePkg = (pkg) => fs.writeFileSync(getPkgPath(), JSON.stringify(pkg, null, 2));
|
|
16
|
+
/**
|
|
17
|
+
* @description 构建pr版本号 <主版本号>.<次版本号>.<修订号>.<PR标识>.<PR编号>.<当前提交唯一短哈希>
|
|
18
|
+
* @example 1.0.0.pr.184.a1b2c3d
|
|
19
|
+
* @param pkg package.json
|
|
20
|
+
*/
|
|
21
|
+
const updateVersion = (pkg) => {
|
|
22
|
+
const list = pkg.version.split('.');
|
|
23
|
+
const shortHash = process.env.GITHUB_SHA?.substring(0, 7) ?? 'unknown';
|
|
24
|
+
list[2] = `${Number(list[2]) + 1}`;
|
|
25
|
+
pkg.version = `${list.join('.')}-pr${process.env.PR_NUMBER}.${shortHash}`;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 设置环境变量
|
|
29
|
+
* @param pkg - package.json
|
|
30
|
+
*/
|
|
31
|
+
const setEnvVariables = (pkg) => {
|
|
32
|
+
const githubEnvPath = process.env.GITHUB_ENV;
|
|
33
|
+
if (!githubEnvPath) {
|
|
34
|
+
throw new Error('GITHUB_ENV 环境变量未定义');
|
|
35
|
+
}
|
|
36
|
+
fs.appendFileSync(githubEnvPath, `PKG_NAME=${pkg.name}\nPKG_VERSION=${pkg.version}\n`);
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 更新版本号并设置环境变量
|
|
40
|
+
*/
|
|
41
|
+
const version = () => {
|
|
42
|
+
console.log('开始执行版本更新...');
|
|
43
|
+
const pkg = readPkg();
|
|
44
|
+
console.log(`当前版本: ${pkg.version}`);
|
|
45
|
+
updateVersion(pkg);
|
|
46
|
+
console.log(`更新后版本: ${pkg.version}`);
|
|
47
|
+
writePkg(pkg);
|
|
48
|
+
console.log('package.json 写入成功');
|
|
49
|
+
setEnvVariables(pkg);
|
|
50
|
+
console.log('环境变量设置完成');
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @description 删除devDependencies和peerDependencies
|
|
54
|
+
*/
|
|
55
|
+
const clean = () => {
|
|
56
|
+
console.log('开始清理依赖...');
|
|
57
|
+
const pkg = readPkg();
|
|
58
|
+
console.log('正在删除 devDependencies');
|
|
59
|
+
delete pkg.devDependencies;
|
|
60
|
+
writePkg(pkg);
|
|
61
|
+
console.log('依赖清理完成');
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* @description 执行所有操作
|
|
65
|
+
*/
|
|
66
|
+
const all = () => {
|
|
67
|
+
console.log('开始执行所有操作...');
|
|
68
|
+
const pkg = readPkg();
|
|
69
|
+
console.log(`当前版本: ${pkg.version}`);
|
|
70
|
+
updateVersion(pkg);
|
|
71
|
+
console.log(`更新后版本: ${pkg.version}`);
|
|
72
|
+
console.log('正在删除 devDependencies');
|
|
73
|
+
delete pkg.devDependencies;
|
|
74
|
+
writePkg(pkg);
|
|
75
|
+
console.log('package.json 写入成功');
|
|
76
|
+
setEnvVariables(pkg);
|
|
77
|
+
console.log('环境变量设置完成');
|
|
78
|
+
console.log('所有操作执行完毕');
|
|
79
|
+
};
|
|
80
|
+
const cmd = process.argv[2];
|
|
81
|
+
console.log(`执行命令: ${cmd}`);
|
|
82
|
+
if (cmd.includes('version')) {
|
|
83
|
+
version();
|
|
84
|
+
}
|
|
85
|
+
else if (cmd.includes('clean')) {
|
|
86
|
+
clean();
|
|
87
|
+
}
|
|
88
|
+
else if (cmd.includes('all')) {
|
|
89
|
+
all();
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log('未知命令,可用命令: version, clean, all');
|
|
93
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './model/index.js';
|
|
2
|
+
export * from './platform/index.js';
|
|
3
|
+
export * from './server/index.js';
|
|
4
|
+
export * from './types/index.js';
|
|
5
|
+
import { amagi as AmagiClient, ckParams } from './server/index.js';
|
|
6
|
+
export default AmagiClient;
|
|
7
|
+
export declare function Amagi(options: ckParams): AmagiClient;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './model/index.js';
|
|
2
|
+
export * from './platform/index.js';
|
|
3
|
+
export * from './server/index.js';
|
|
4
|
+
export * from './types/index.js';
|
|
5
|
+
import { amagi as AmagiClient } from './server/index.js';
|
|
6
|
+
export default AmagiClient;
|
|
7
|
+
export function Amagi(options) {
|
|
8
|
+
return new AmagiClient(options);
|
|
9
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BilibiliDataOptions, BilibiliDataOptionsMap, DouyinDataOptions, DouyinDataOptionsMap, KuaishouDataOptions, KuaishouDataOptionsMap } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* 获取抖音数据
|
|
4
|
+
* @param type - 请求数据类型
|
|
5
|
+
* @param cookie - 有效的用户Cookie
|
|
6
|
+
* @param options - 请求参数,是一个对象
|
|
7
|
+
* @returns 返回接口的原始数据
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const data = await getDouyinData('搜索数据', 'User Cookies', {
|
|
11
|
+
* query: '114514',
|
|
12
|
+
* number: 10
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const getDouyinData: <T extends keyof DouyinDataOptionsMap>(type: T, cookie?: string, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
|
|
17
|
+
/**
|
|
18
|
+
* 获取B站数据
|
|
19
|
+
* @param type - 请求数据类型
|
|
20
|
+
* @param cookie - 有效的用户Cookie
|
|
21
|
+
* @param options - 请求参数,是一个对象
|
|
22
|
+
* @returns 返回接口的原始数据
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const data = await getBilibiliData('单个视频作品数据', 'User Cookies', {
|
|
26
|
+
* bvid: 'BV1fK4y1q79u'
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap>(methodType: T, cookie?: string, options?: BilibiliDataOptions<T>): Promise<BilibiliDataOptionsMap[T]['data']>;
|
|
31
|
+
/**
|
|
32
|
+
* 获取快手数据
|
|
33
|
+
* @param type - 请求数据类型
|
|
34
|
+
* @param cookie - 有效的用户Cookie
|
|
35
|
+
* @param options - 请求参数,是一个对象
|
|
36
|
+
* @returns 返回接口的原始数据
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const data = await getKuaishouData('单个视频作品数据', 'User Cookies', {
|
|
40
|
+
* photoId: '3xdpv6sfi8yjsqy'
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const getKuaishouData: <T extends keyof KuaishouDataOptionsMap>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
|
|
45
|
+
export declare const fetchDouyinData: <T extends keyof DouyinDataOptionsMap>(type: T, cookie?: string, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
|
|
46
|
+
export declare const fetchBilibiliData: typeof getBilibiliData;
|
|
47
|
+
export declare const fetchKuaishouData: <T extends keyof KuaishouDataOptionsMap>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BilibiliData, DouyinData, KuaishouData } from '../platform/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* 获取抖音数据
|
|
4
|
+
* @param type - 请求数据类型
|
|
5
|
+
* @param cookie - 有效的用户Cookie
|
|
6
|
+
* @param options - 请求参数,是一个对象
|
|
7
|
+
* @returns 返回接口的原始数据
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const data = await getDouyinData('搜索数据', 'User Cookies', {
|
|
11
|
+
* query: '114514',
|
|
12
|
+
* number: 10
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export const getDouyinData = async (type, cookie, options) => {
|
|
17
|
+
const data = await DouyinData({ ...options, methodType: type }, cookie);
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 获取B站数据
|
|
22
|
+
* @param type - 请求数据类型
|
|
23
|
+
* @param cookie - 有效的用户Cookie
|
|
24
|
+
* @param options - 请求参数,是一个对象
|
|
25
|
+
* @returns 返回接口的原始数据
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const data = await getBilibiliData('单个视频作品数据', 'User Cookies', {
|
|
29
|
+
* bvid: 'BV1fK4y1q79u'
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export async function getBilibiliData(methodType, cookie, options) {
|
|
34
|
+
const data = await BilibiliData({ ...options, methodType }, cookie);
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 获取快手数据
|
|
39
|
+
* @param type - 请求数据类型
|
|
40
|
+
* @param cookie - 有效的用户Cookie
|
|
41
|
+
* @param options - 请求参数,是一个对象
|
|
42
|
+
* @returns 返回接口的原始数据
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const data = await getKuaishouData('单个视频作品数据', 'User Cookies', {
|
|
46
|
+
* photoId: '3xdpv6sfi8yjsqy'
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const getKuaishouData = async (methodType, cookie, options) => {
|
|
51
|
+
const data = await KuaishouData({ ...options, methodType }, cookie);
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
export const fetchDouyinData = getDouyinData;
|
|
55
|
+
export const fetchBilibiliData = getBilibiliData;
|
|
56
|
+
export const fetchKuaishouData = getKuaishouData;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import log4js from 'log4js';
|
|
2
|
+
declare const chalk: import("chalk").ChalkInstance;
|
|
3
|
+
declare module 'log4js' {
|
|
4
|
+
interface Logger {
|
|
5
|
+
chalk?: typeof chalk;
|
|
6
|
+
red: typeof chalk.red;
|
|
7
|
+
green: typeof chalk.green;
|
|
8
|
+
yellow: typeof chalk.yellow;
|
|
9
|
+
blue: typeof chalk.blue;
|
|
10
|
+
magenta: typeof chalk.magenta;
|
|
11
|
+
cyan: typeof chalk.cyan;
|
|
12
|
+
white: typeof chalk.white;
|
|
13
|
+
gray: typeof chalk.gray;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
declare const logger: log4js.Logger;
|
|
17
|
+
export { logger };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Chalk } from 'chalk';
|
|
2
|
+
import log4js from 'log4js';
|
|
3
|
+
log4js.configure({
|
|
4
|
+
appenders: {
|
|
5
|
+
console: {
|
|
6
|
+
type: 'stdout',
|
|
7
|
+
layout: {
|
|
8
|
+
type: 'pattern',
|
|
9
|
+
pattern: '%[[amagi][%d{hh:mm:ss.SSS}][%4.4p]%] %m'
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
command: {
|
|
13
|
+
type: 'dateFile',
|
|
14
|
+
filename: 'logs/command',
|
|
15
|
+
pattern: 'yyyy-MM-dd.log',
|
|
16
|
+
numBackups: 15,
|
|
17
|
+
alwaysIncludePattern: true,
|
|
18
|
+
layout: {
|
|
19
|
+
type: 'pattern',
|
|
20
|
+
pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
pluginConsole: {
|
|
24
|
+
type: 'stdout',
|
|
25
|
+
layout: {
|
|
26
|
+
type: 'pattern',
|
|
27
|
+
pattern: '%[[%d{hh:mm:ss.SSS}][%4.4p][plugin]%] %m'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
pluginCommand: {
|
|
31
|
+
type: 'dateFile',
|
|
32
|
+
filename: 'logs/pluginCommand',
|
|
33
|
+
pattern: 'yyyy-MM-dd.log',
|
|
34
|
+
numBackups: 15,
|
|
35
|
+
alwaysIncludePattern: true,
|
|
36
|
+
layout: { type: 'pattern', pattern: '[%d{hh:mm:ss.SSS}][%4.4p] %m' }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
categories: {
|
|
40
|
+
default: { appenders: ['console', 'command'], level: 'info' } // 添加default类别
|
|
41
|
+
},
|
|
42
|
+
pm2: true
|
|
43
|
+
});
|
|
44
|
+
const chalk = new Chalk({ level: 3 });
|
|
45
|
+
const logger = log4js.getLogger('default');
|
|
46
|
+
logger.chalk = chalk;
|
|
47
|
+
logger.red = chalk.red;
|
|
48
|
+
logger.green = chalk.green;
|
|
49
|
+
logger.yellow = chalk.yellow;
|
|
50
|
+
logger.blue = chalk.blue;
|
|
51
|
+
logger.magenta = chalk.magenta;
|
|
52
|
+
logger.cyan = chalk.cyan;
|
|
53
|
+
logger.white = chalk.white;
|
|
54
|
+
logger.gray = chalk.gray;
|
|
55
|
+
export { logger };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
import { NetworksConfigType } from '../types/index.js';
|
|
3
|
+
interface HeadersObject {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class Networks {
|
|
7
|
+
url: string;
|
|
8
|
+
method: string;
|
|
9
|
+
headers: HeadersObject;
|
|
10
|
+
type: string;
|
|
11
|
+
body?: any;
|
|
12
|
+
axiosInstance: any;
|
|
13
|
+
isGetResult: boolean;
|
|
14
|
+
timeout: number;
|
|
15
|
+
timer: NodeJS.Timeout | undefined;
|
|
16
|
+
data: object;
|
|
17
|
+
constructor(data: NetworksConfigType);
|
|
18
|
+
get config(): AxiosRequestConfig;
|
|
19
|
+
getfetch(): Promise<AxiosResponse | boolean>;
|
|
20
|
+
returnResult(): Promise<AxiosResponse>;
|
|
21
|
+
/** 最终地址(跟随重定向) */
|
|
22
|
+
getLongLink(): Promise<string>;
|
|
23
|
+
/** 获取首个302 */
|
|
24
|
+
getLocation(): Promise<string>;
|
|
25
|
+
/** 获取数据并处理数据的格式化,默认json */
|
|
26
|
+
getData(new_fetch?: string): Promise<any | boolean>;
|
|
27
|
+
getHeadersAndData(): Promise<{
|
|
28
|
+
headers: any;
|
|
29
|
+
data: any;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import axios, { AxiosError } from 'axios';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
|
+
export class Networks {
|
|
4
|
+
url;
|
|
5
|
+
method;
|
|
6
|
+
headers;
|
|
7
|
+
type;
|
|
8
|
+
body;
|
|
9
|
+
axiosInstance;
|
|
10
|
+
isGetResult;
|
|
11
|
+
timeout;
|
|
12
|
+
timer;
|
|
13
|
+
data;
|
|
14
|
+
constructor(data) {
|
|
15
|
+
this.headers = data.headers ?? {};
|
|
16
|
+
this.url = data.url ?? '';
|
|
17
|
+
this.type = data.responseType ?? 'json';
|
|
18
|
+
this.method = data.method ?? 'GET';
|
|
19
|
+
this.body = data.body ?? null;
|
|
20
|
+
this.data = {};
|
|
21
|
+
this.timeout = data.timeout ?? 15000;
|
|
22
|
+
this.isGetResult = false;
|
|
23
|
+
this.timer = undefined;
|
|
24
|
+
// 创建axios实例
|
|
25
|
+
this.axiosInstance = axios.create({
|
|
26
|
+
timeout: this.timeout,
|
|
27
|
+
headers: this.headers,
|
|
28
|
+
maxRedirects: 5,
|
|
29
|
+
validateStatus: (status) => {
|
|
30
|
+
// 接受200-299,400-499,以及500及以上的状态码
|
|
31
|
+
return (status >= 200 && status < 600);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
get config() {
|
|
36
|
+
let config = {
|
|
37
|
+
url: this.url,
|
|
38
|
+
method: this.method,
|
|
39
|
+
headers: this.headers
|
|
40
|
+
};
|
|
41
|
+
if (this.method === 'POST' && this.body) {
|
|
42
|
+
config.data = this.body;
|
|
43
|
+
}
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
async getfetch() {
|
|
47
|
+
try {
|
|
48
|
+
const result = await this.returnResult();
|
|
49
|
+
if (result.status === 504) {
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
this.isGetResult = true;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
logger.info(error);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async returnResult() {
|
|
61
|
+
return await this.axiosInstance(this.config);
|
|
62
|
+
}
|
|
63
|
+
/** 最终地址(跟随重定向) */
|
|
64
|
+
async getLongLink() {
|
|
65
|
+
try {
|
|
66
|
+
const response = await this.axiosInstance({
|
|
67
|
+
method: 'GET',
|
|
68
|
+
url: this.url
|
|
69
|
+
});
|
|
70
|
+
return response.request.res.responseUrl; // axios中获取最终的请求URL
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error instanceof AxiosError) {
|
|
74
|
+
throw new Error(error.stack);
|
|
75
|
+
}
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** 获取首个302 */
|
|
80
|
+
async getLocation() {
|
|
81
|
+
try {
|
|
82
|
+
const response = await this.axiosInstance({
|
|
83
|
+
method: 'GET',
|
|
84
|
+
url: this.url,
|
|
85
|
+
maxRedirects: 0, // 禁止跟随重定向
|
|
86
|
+
validateStatus: (status) => status >= 300 && status < 400 // 仅处理3xx响应
|
|
87
|
+
});
|
|
88
|
+
return response.headers['location'];
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (error instanceof AxiosError) {
|
|
92
|
+
throw new Error(error.stack);
|
|
93
|
+
}
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** 获取数据并处理数据的格式化,默认json */
|
|
98
|
+
async getData(new_fetch = '') {
|
|
99
|
+
try {
|
|
100
|
+
if (!new_fetch) {
|
|
101
|
+
const result = await this.returnResult();
|
|
102
|
+
if (result.status === 504) {
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
if (result.status === 429) {
|
|
106
|
+
logger.error('HTTP 响应状态码: 429');
|
|
107
|
+
throw new Error('ratelimit triggered, 触发 https://www.douyin.com/ 的速率限制!!!');
|
|
108
|
+
}
|
|
109
|
+
this.axiosInstance = result;
|
|
110
|
+
this.isGetResult = true;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
this.axiosInstance = new_fetch;
|
|
114
|
+
}
|
|
115
|
+
return this.axiosInstance.data;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof AxiosError) {
|
|
119
|
+
throw new Error(error.stack);
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async getHeadersAndData() {
|
|
125
|
+
try {
|
|
126
|
+
// 发起网络请求获取响应对象
|
|
127
|
+
const result = await this.axiosInstance(this.config);
|
|
128
|
+
// 初始化响应头和响应数据
|
|
129
|
+
let headers = {};
|
|
130
|
+
const fetchHeaders = result.headers;
|
|
131
|
+
for (const [key, value] of Object.entries(fetchHeaders)) {
|
|
132
|
+
headers[key] = value;
|
|
133
|
+
}
|
|
134
|
+
return { headers, data: result.data };
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
console.error('获取响应头和数据失败:', error);
|
|
138
|
+
return { headers: null, data: null };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 参数检查
|
|
3
|
+
* @param data - 参数对象
|
|
4
|
+
* @param fields - 要对data进行检查的字段
|
|
5
|
+
* @param atLeastOne - 是否至少有一个字段存在即可通过检查,默认为false
|
|
6
|
+
*/
|
|
7
|
+
export declare const validateData: (data: {
|
|
8
|
+
methodType: string;
|
|
9
|
+
} & Record<string, any>, fields: string[], atLeastOne?: boolean) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { logger } from './logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* 参数检查
|
|
4
|
+
* @param data - 参数对象
|
|
5
|
+
* @param fields - 要对data进行检查的字段
|
|
6
|
+
* @param atLeastOne - 是否至少有一个字段存在即可通过检查,默认为false
|
|
7
|
+
*/
|
|
8
|
+
export const validateData = (data, fields, atLeastOne = false) => {
|
|
9
|
+
const checkField = (field) => Object.prototype.hasOwnProperty.call(data, field);
|
|
10
|
+
const isValid = atLeastOne
|
|
11
|
+
? fields.some(checkField) // 至少一个字段存在
|
|
12
|
+
: fields.every(checkField); // 所有字段都必须存在
|
|
13
|
+
if (isValid === false) {
|
|
14
|
+
const missingFields = atLeastOne
|
|
15
|
+
? fields // 如果是至少一个,则提示所有字段
|
|
16
|
+
: fields.filter(field => !checkField(field)); // 否则只提示缺失的字段
|
|
17
|
+
const missingFieldsString = missingFields.map(field => `'${logger.green(field)}'`).join(', ');
|
|
18
|
+
throw new Error(`获取「${data.methodType}」${logger.red('缺少必要的参数')}: ${missingFieldsString}`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { OmitMethodType } from '../../types/index.js';
|
|
2
|
+
import { BilibiliMethodOptionsMap } from '../../types/index.js';
|
|
3
|
+
type BilibiliMethodOptionsWithoutMethodType = {
|
|
4
|
+
[K in keyof BilibiliMethodOptionsMap]: OmitMethodType<BilibiliMethodOptionsMap[K]>;
|
|
5
|
+
};
|
|
6
|
+
declare class BiLiBiLiAPI {
|
|
7
|
+
登录基本信息(): string;
|
|
8
|
+
视频详细信息(data: BilibiliMethodOptionsWithoutMethodType['VideoInfoParams']): string;
|
|
9
|
+
视频流信息(data: BilibiliMethodOptionsWithoutMethodType['VideoStreamParams']): string;
|
|
10
|
+
/** 评论区类型,type参数详见 [评论区类型代码](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码) */
|
|
11
|
+
评论区明细(data: BilibiliMethodOptionsWithoutMethodType['CommentParams']): string;
|
|
12
|
+
评论区状态(data: BilibiliMethodOptionsWithoutMethodType['CommentParams']): string;
|
|
13
|
+
表情列表(): string;
|
|
14
|
+
番剧明细(data: BilibiliMethodOptionsWithoutMethodType['BangumiInfoParams']): string;
|
|
15
|
+
番剧视频流信息(data: BilibiliMethodOptionsWithoutMethodType['BangumiStreamParams']): string;
|
|
16
|
+
用户空间动态(data: BilibiliMethodOptionsWithoutMethodType['UserParams']): string;
|
|
17
|
+
动态详情(data: BilibiliMethodOptionsWithoutMethodType['DynamicParams']): string;
|
|
18
|
+
动态卡片信息(data: BilibiliMethodOptionsWithoutMethodType['DynamicParams']): string;
|
|
19
|
+
用户名片信息(data: BilibiliMethodOptionsWithoutMethodType['UserParams']): string;
|
|
20
|
+
直播间信息(data: BilibiliMethodOptionsWithoutMethodType['LiveRoomParams']): string;
|
|
21
|
+
直播间初始化信息(data: BilibiliMethodOptionsWithoutMethodType['LiveRoomParams']): string;
|
|
22
|
+
申请二维码(): string;
|
|
23
|
+
二维码状态(data: BilibiliMethodOptionsWithoutMethodType['QrcodeParams']): string;
|
|
24
|
+
获取UP主总播放量(data: BilibiliMethodOptionsWithoutMethodType['UserParams']): string;
|
|
25
|
+
}
|
|
26
|
+
/** 该类下的所有方法只会返回拼接好参数后的 Url 地址,需要手动请求该地址以获取数据 */
|
|
27
|
+
export declare const bilibiliAPI: BiLiBiLiAPI;
|
|
28
|
+
export {};
|