@ikenxuan/amagi 1.4.3 → 1.4.5
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 -56
- package/lib/business/bilibili/API.d.ts +16 -34
- package/lib/business/bilibili/API.js +20 -8
- package/lib/business/bilibili/getdata.d.ts +1 -1
- package/lib/business/bilibili/getdata.js +15 -15
- package/lib/business/bilibili/qtparam.d.ts +1 -1
- package/lib/business/bilibili/qtparam.js +5 -5
- package/lib/business/bilibili/result.d.ts +2 -1
- package/lib/business/bilibili/result.js +7 -3
- package/lib/business/bilibili/sign/wbi.d.ts +1 -1
- package/lib/business/bilibili/sign/wbi.js +4 -5
- package/lib/business/douyin/API.d.ts +11 -31
- package/lib/business/douyin/API.js +1 -2
- package/lib/business/douyin/getdata.d.ts +1 -1
- package/lib/business/douyin/getdata.js +3 -3
- package/lib/business/douyin/result.d.ts +2 -1
- package/lib/business/douyin/result.js +5 -3
- package/lib/business/douyin/sign/a_bougs.d.ts +3 -0
- package/lib/business/douyin/sign/a_bougs.js +1 -1
- package/lib/business/douyin/sign/index.js +2 -2
- package/lib/business/index.d.ts +2 -0
- package/lib/business/index.js +2 -0
- package/lib/index.d.ts +7 -30
- package/lib/index.js +7 -113
- package/lib/model/index.d.ts +1 -2
- package/lib/model/index.js +1 -2
- package/lib/server/client.d.ts +15 -0
- package/lib/server/client.js +105 -0
- package/lib/server/index.d.ts +2 -0
- package/lib/server/index.js +2 -0
- package/lib/server/listen.d.ts +14 -0
- package/lib/server/listen.js +11 -0
- package/lib/types/BilibiliAPIParams.d.ts +59 -0
- package/lib/types/DataType.d.ts +3 -1
- package/lib/types/DouyinAPIParams.d.ts +37 -0
- package/lib/types/DouyinAPIParams.js +1 -0
- package/lib/types/OptionsType.d.ts +4 -0
- package/lib/types/Request.d.ts +8 -0
- package/lib/types/Request.js +1 -0
- package/lib/types/index.d.ts +4 -1
- package/package.json +14 -12
- package/config/config.yaml +0 -5
- package/config/default_config.yaml +0 -5
- package/lib/app.js +0 -2
- package/lib/model/config.d.ts +0 -70
- package/lib/model/config.js +0 -173
- /package/lib/{app.d.ts → types/BilibiliAPIParams.js} +0 -0
package/README.md
CHANGED
|
@@ -1,64 +1,23 @@
|
|
|
1
|
-
# amagi
|
|
1
|
+
# amagi(泥干嘛哈哈
|
|
2
2
|
* 热门平台视频解析 API 基于 Node.js 的实现,支持最低node版本为 v16
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
## 环境
|
|
6
|
-
> [Node.js](https://nodejs.org) **必要**
|
|
7
|
-
|
|
8
|
-
> [git](https://git-scm.com) _可选_
|
|
9
|
-
|
|
10
|
-
> [pnpm](https://pnpm.io) _可选_
|
|
3
|
+
* 抖音、B站
|
|
11
4
|
|
|
12
5
|
## 使用
|
|
13
|
-
> Node.js版本约定:
|
|
14
|
-
> Node.js => v16.20.2
|
|
15
|
-
|
|
16
|
-
### 直接使用
|
|
17
|
-
前往 [releases 页面](https://github.com/ikenxuan/amagi/releases) 找到最新版本的压缩文件(zip格式)下载
|
|
18
|
-
|
|
19
|
-
解压后打开 `config/config.yaml` 根据提示填写cookies
|
|
20
|
-
|
|
21
|
-
**根目录打开终端运行**
|
|
22
|
-
|
|
23
|
-
* 安装pnpm,已安装可跳过
|
|
24
6
|
```
|
|
25
|
-
npm install
|
|
7
|
+
npm install @ikenxuan/amagi
|
|
26
8
|
```
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
pnpm install
|
|
30
|
-
```
|
|
31
|
-
* 启动
|
|
32
|
-
```
|
|
33
|
-
pnpm app
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### 外部调用
|
|
37
|
-
**快速上手:**
|
|
9
|
+
## 快速上手
|
|
38
10
|
```js
|
|
39
|
-
import { StartClient
|
|
11
|
+
import amagi, { StartClient } from '@ikenxuan/amagi'
|
|
40
12
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
reply.type('application/json').send({ hello: 'hello, world!', url });
|
|
47
|
-
};
|
|
48
|
-
const routeArray = [
|
|
49
|
-
// http://ip:port/1
|
|
50
|
-
{ method: 'GET', url: '/1', handler, },
|
|
51
|
-
{ method: 'GET', url: '/2', handler, },
|
|
52
|
-
{ method: 'GET', url: '/3', handler, },
|
|
53
|
-
{ method: 'GET', url: '/4', handler }
|
|
54
|
-
];
|
|
55
|
-
// 继承 amagi 路由规则
|
|
56
|
-
client = AddRoute(client, routeArray, true);
|
|
57
|
-
// 监听4567端口
|
|
58
|
-
return await StartClient(client, { port: 4567 });
|
|
59
|
-
};
|
|
13
|
+
// 初始化
|
|
14
|
+
const client = await new amagi({
|
|
15
|
+
douyin: '抖音ck',
|
|
16
|
+
bilibili: 'B站ck'
|
|
17
|
+
}).initServer(true)
|
|
60
18
|
|
|
61
|
-
|
|
19
|
+
// 启动监听
|
|
20
|
+
await StartClient(client, { port: 4567 })
|
|
62
21
|
```
|
|
63
22
|
## 开发构建
|
|
64
23
|
> Node.js版本约定:
|
|
@@ -71,12 +30,12 @@ git clone git@github.com:ikenxuan/amagi.git
|
|
|
71
30
|
```
|
|
72
31
|
pnpm install
|
|
73
32
|
```
|
|
74
|
-
*
|
|
33
|
+
* 构建
|
|
75
34
|
```
|
|
76
|
-
pnpm
|
|
35
|
+
pnpm build
|
|
77
36
|
```
|
|
78
37
|
|
|
79
|
-
##
|
|
38
|
+
## 声明
|
|
80
39
|
该项目代码从 [kkkkkk-10086](https://github.com/ikenxuan/kkkkkk-10086) 提取修改并发布
|
|
81
40
|
|
|
82
41
|
<h2>未经同意,禁止将本项目的开源代码用于任何商业目的。因使用本项目产生的一切问题与后果由使用者自行承担,项目开发者不承担任何责任</h2>
|
|
@@ -1,39 +1,21 @@
|
|
|
1
|
+
import { BilibiliAPIParams } from '../../types/index.js';
|
|
1
2
|
declare class BiLiBiLiAPI {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id: string;
|
|
6
|
-
}): string;
|
|
7
|
-
VIDEO(data: {
|
|
8
|
-
avid: string;
|
|
9
|
-
cid: string;
|
|
10
|
-
}): string;
|
|
3
|
+
登录基本信息(): string;
|
|
4
|
+
视频详细信息(data: BilibiliAPIParams['VideoInfoParams']): string;
|
|
5
|
+
视频流信息(data: BilibiliAPIParams['VideoStreamParams']): string;
|
|
11
6
|
/** type参数详见https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码 */
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}): string;
|
|
25
|
-
获取用户空间动态(data: {
|
|
26
|
-
host_mid: string;
|
|
27
|
-
}): string;
|
|
28
|
-
动态详情(data: {
|
|
29
|
-
dynamic_id: string;
|
|
30
|
-
}): string;
|
|
31
|
-
动态卡片信息(data: {
|
|
32
|
-
dynamic_id: string;
|
|
33
|
-
}): string;
|
|
34
|
-
用户名片信息(data: {
|
|
35
|
-
host_mid: string;
|
|
36
|
-
}): string;
|
|
7
|
+
评论区明细(data: BilibiliAPIParams['CommentParams']): string;
|
|
8
|
+
表情列表(): string;
|
|
9
|
+
番剧明细(data: BilibiliAPIParams['BangumiInfoParams']): string;
|
|
10
|
+
番剧视频流信息(data: BilibiliAPIParams['BangumiStreamParams']): string;
|
|
11
|
+
用户空间动态(data: BilibiliAPIParams['UserParams']): string;
|
|
12
|
+
动态详情(data: BilibiliAPIParams['DynamicParams']): string;
|
|
13
|
+
动态卡片信息(data: BilibiliAPIParams['DynamicParams']): string;
|
|
14
|
+
用户名片信息(data: BilibiliAPIParams['UserParams']): string;
|
|
15
|
+
直播间信息(data: BilibiliAPIParams['LiveRoomParams']): string;
|
|
16
|
+
房间页初始化信息(data: BilibiliAPIParams['LiveRoomParams']): string;
|
|
17
|
+
申请二维码(): string;
|
|
18
|
+
二维码状态(data: BilibiliAPIParams['QrcodeParams']): string;
|
|
37
19
|
}
|
|
38
20
|
declare const _default: BiLiBiLiAPI;
|
|
39
21
|
export default _default;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
class BiLiBiLiAPI {
|
|
2
|
-
|
|
2
|
+
登录基本信息() {
|
|
3
3
|
return 'https://api.bilibili.com/x/web-interface/nav';
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
视频详细信息(data) {
|
|
6
6
|
return `https://api.bilibili.com/x/web-interface/view?${data.id_type === 'bvid' ? 'bvid=' + data.id : 'aid=' + data.id}`;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
视频流信息(data) {
|
|
9
9
|
return `https://api.bilibili.com/x/player/playurl?avid=${data.avid}&cid=${data.cid}`;
|
|
10
10
|
}
|
|
11
11
|
/** type参数详见https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/readme.md#评论区类型代码 */
|
|
12
|
-
|
|
12
|
+
评论区明细(data) {
|
|
13
13
|
return `https://api.bilibili.com/x/v2/reply?sort=1&ps=20&type=${data.type}&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';
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
番剧明细(data) {
|
|
19
19
|
return `https://api.bilibili.com/pgc/view/web/season?${data.isep ? 'ep_id' : 'season_id'}=${data.id}`;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
番剧视频流信息(data) {
|
|
22
22
|
return `https://api.bilibili.com/pgc/player/web/playurl?cid=${data.cid}&ep_id=${data.ep_id}`;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
用户空间动态(data) {
|
|
25
25
|
return `https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?host_mid=${data.host_mid}`;
|
|
26
26
|
}
|
|
27
27
|
动态详情(data) {
|
|
@@ -33,5 +33,17 @@ class BiLiBiLiAPI {
|
|
|
33
33
|
用户名片信息(data) {
|
|
34
34
|
return `https://api.bilibili.com/x/web-interface/card?mid=${data.host_mid}&photo=true`;
|
|
35
35
|
}
|
|
36
|
+
直播间信息(data) {
|
|
37
|
+
return `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${data.room_id}`;
|
|
38
|
+
}
|
|
39
|
+
房间页初始化信息(data) {
|
|
40
|
+
return `https://api.live.bilibili.com/room/v1/Room/room_init?id=${data.room_id}`;
|
|
41
|
+
}
|
|
42
|
+
申请二维码() {
|
|
43
|
+
return 'https://passport.bilibili.com/x/passport-login/web/qrcode/generate';
|
|
44
|
+
}
|
|
45
|
+
二维码状态(data) {
|
|
46
|
+
return `https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=${data.qrcode_key}`;
|
|
47
|
+
}
|
|
36
48
|
}
|
|
37
49
|
export default new BiLiBiLiAPI();
|
|
@@ -3,7 +3,7 @@ export default class BilibiliData {
|
|
|
3
3
|
type: BilibiliDataType;
|
|
4
4
|
headers: any;
|
|
5
5
|
URL: string | undefined;
|
|
6
|
-
constructor(type: BilibiliDataType);
|
|
6
|
+
constructor(type: BilibiliDataType, cookie: string);
|
|
7
7
|
GetData(data?: BilibiliOptionsType): Promise<any>;
|
|
8
8
|
GlobalGetData(options: NetworksConfigType): Promise<any>;
|
|
9
9
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { BiLiBiLiAPI, qtparam, wbi_sign } from '../../business/bilibili/index.js';
|
|
2
|
-
import { Networks,
|
|
2
|
+
import { Networks, logger } from '../../model/index.js';
|
|
3
3
|
export default class BilibiliData {
|
|
4
4
|
type;
|
|
5
5
|
headers;
|
|
6
6
|
URL;
|
|
7
|
-
constructor(type) {
|
|
7
|
+
constructor(type, cookie) {
|
|
8
8
|
this.type = type;
|
|
9
9
|
this.headers = {};
|
|
10
10
|
this.headers.Referer = 'https://api.bilibili.com/';
|
|
11
|
-
this.headers.Cookie =
|
|
11
|
+
this.headers.Cookie = cookie;
|
|
12
12
|
}
|
|
13
13
|
async GetData(data = {}) {
|
|
14
14
|
let result;
|
|
15
15
|
switch (this.type) {
|
|
16
16
|
case 'VideoData': {
|
|
17
|
-
const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI
|
|
18
|
-
const BASEURL = BiLiBiLiAPI
|
|
19
|
-
const SIGN = await qtparam(BASEURL);
|
|
17
|
+
const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI.视频详细信息({ id_type: 'bvid', id: data.id }) });
|
|
18
|
+
const BASEURL = BiLiBiLiAPI.视频流信息({ avid: INFODATA.data.aid, cid: INFODATA.data.cid });
|
|
19
|
+
const SIGN = await qtparam(BASEURL, this.headers.cookie);
|
|
20
20
|
const DATA = await this.GlobalGetData({
|
|
21
|
-
url: BiLiBiLiAPI
|
|
21
|
+
url: BiLiBiLiAPI.视频流信息({ avid: INFODATA.data.aid, cid: INFODATA.data.cid }) + SIGN.QUERY,
|
|
22
22
|
headers: this.headers
|
|
23
23
|
});
|
|
24
24
|
return { INFODATA, DATA, };
|
|
25
25
|
}
|
|
26
26
|
case 'CommentData': {
|
|
27
|
-
const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI
|
|
28
|
-
const PARAM = await wbi_sign(BiLiBiLiAPI
|
|
29
|
-
const COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI
|
|
27
|
+
const INFODATA = await this.GlobalGetData({ url: BiLiBiLiAPI.视频详细信息({ id_type: 'bvid', id: data.bvid }) });
|
|
28
|
+
const PARAM = await wbi_sign(BiLiBiLiAPI.评论区明细({ type: 1, oid: INFODATA.data.aid }), this.headers.cookie);
|
|
29
|
+
const COMMENTSDATA = await this.GlobalGetData({ url: BiLiBiLiAPI.评论区明细({ type: 1, oid: INFODATA.data.aid }) + PARAM, headers: this.headers });
|
|
30
30
|
return COMMENTSDATA;
|
|
31
31
|
}
|
|
32
32
|
case 'EmojiData':
|
|
33
|
-
return await this.GlobalGetData({ url: BiLiBiLiAPI
|
|
33
|
+
return await this.GlobalGetData({ url: BiLiBiLiAPI.表情列表() });
|
|
34
34
|
case 'BangumiVideoData': {
|
|
35
35
|
let isep;
|
|
36
36
|
if (data?.id?.startsWith('ss')) {
|
|
@@ -42,17 +42,17 @@ export default class BilibiliData {
|
|
|
42
42
|
isep = true;
|
|
43
43
|
}
|
|
44
44
|
const INFO = await this.GlobalGetData({
|
|
45
|
-
url: BiLiBiLiAPI
|
|
45
|
+
url: BiLiBiLiAPI.番剧明细({ id: data.id, isep }),
|
|
46
46
|
headers: this.headers
|
|
47
47
|
});
|
|
48
48
|
return INFO;
|
|
49
49
|
}
|
|
50
50
|
case 'BangumiVideoDownloadLinkData':
|
|
51
|
-
return await this.GlobalGetData({ url: BiLiBiLiAPI
|
|
51
|
+
return await this.GlobalGetData({ url: BiLiBiLiAPI.番剧视频流信息({ cid: data.cid, ep_id: data.ep_id }) });
|
|
52
52
|
case 'UserDynamicListData':
|
|
53
53
|
delete this.headers.Referer;
|
|
54
54
|
result = await this.GlobalGetData({
|
|
55
|
-
url: BiLiBiLiAPI
|
|
55
|
+
url: BiLiBiLiAPI.用户空间动态({ host_mid: data.host_mid }),
|
|
56
56
|
headers: this.headers
|
|
57
57
|
});
|
|
58
58
|
return result;
|
|
@@ -84,7 +84,7 @@ export default class BilibiliData {
|
|
|
84
84
|
const result = await new Networks(options).getData();
|
|
85
85
|
if (result && result.code !== 0) {
|
|
86
86
|
const errorMessage = errorMap[result.code] || '未知错误';
|
|
87
|
-
logger.error(
|
|
87
|
+
logger.error(`响应数据失败!\n请求接口类型:${this.type}\n请求URL:${options.url}\n错误代码:${result.code},\n含义:${errorMessage}`);
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Networks } from '../../model/index.js';
|
|
2
2
|
import { BiLiBiLiAPI, wbi_sign } from '../../business/bilibili/index.js';
|
|
3
|
-
export default async function qtparam(BASEURL) {
|
|
4
|
-
if (
|
|
3
|
+
export default async function qtparam(BASEURL, cookie) {
|
|
4
|
+
if (cookie == '')
|
|
5
5
|
return { QUERY: '&platform=html5', STATUS: '!isLogin' };
|
|
6
|
-
const logininfo = await new Networks({ url: BiLiBiLiAPI
|
|
7
|
-
const sign = await wbi_sign(BASEURL);
|
|
6
|
+
const logininfo = await new Networks({ url: BiLiBiLiAPI.登录基本信息(), headers: { Cookie: cookie } }).getData();
|
|
7
|
+
const sign = await wbi_sign(BASEURL, cookie);
|
|
8
8
|
const qn = [6, 16, 32, 64, 74, 80, 112, 116, 120, 125, 126, 127];
|
|
9
9
|
let isvip;
|
|
10
10
|
logininfo.data.vipStatus === 1 ? (isvip = true) : (isvip = false);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BilibiliDataType, GetDataResponseType, BilibiliOptionsType } from '../../types/index.js';
|
|
2
2
|
export default class BilibiliResult {
|
|
3
3
|
type: BilibiliDataType;
|
|
4
|
-
|
|
4
|
+
cookie: string;
|
|
5
|
+
constructor(type: BilibiliDataType, cookie: string);
|
|
5
6
|
result(options?: BilibiliOptionsType): Promise<GetDataResponseType>;
|
|
6
7
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { BilibiliData, GetBilibiliID } from '../../business/bilibili/index.js';
|
|
2
2
|
export default class BilibiliResult {
|
|
3
3
|
type;
|
|
4
|
-
|
|
4
|
+
cookie;
|
|
5
|
+
constructor(type, cookie) {
|
|
5
6
|
this.type = type;
|
|
7
|
+
this.cookie = cookie;
|
|
6
8
|
}
|
|
7
9
|
async result(options = {}) {
|
|
8
10
|
let result;
|
|
@@ -15,12 +17,14 @@ export default class BilibiliResult {
|
|
|
15
17
|
case 'UserDynamicListData':
|
|
16
18
|
case 'DynamicInfoData':
|
|
17
19
|
case 'DynamicCardData':
|
|
18
|
-
|
|
20
|
+
case 'LiveRoomInfoData':
|
|
21
|
+
case 'LiveRoomInitData':
|
|
22
|
+
result = await new BilibiliData(this.type, this.cookie).GetData(options);
|
|
19
23
|
break;
|
|
20
24
|
case 'VideoData':
|
|
21
25
|
case 'BangumiVideoData': {
|
|
22
26
|
const iddata = await GetBilibiliID(options.url);
|
|
23
|
-
result = await new BilibiliData(this.type).GetData(iddata);
|
|
27
|
+
result = await new BilibiliData(this.type, this.cookie).GetData(iddata);
|
|
24
28
|
break;
|
|
25
29
|
}
|
|
26
30
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function wbi_sign(BASEURL: string | URL): Promise<string>;
|
|
1
|
+
export default function wbi_sign(BASEURL: string | URL, cookie: string): Promise<string>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Config } from '../../../model/index.js';
|
|
2
1
|
import md5 from 'md5';
|
|
3
2
|
import fetch from 'node-fetch';
|
|
4
3
|
const mixinKeyEncTab = [
|
|
@@ -29,10 +28,10 @@ function encWbi(params, img_key, sub_key) {
|
|
|
29
28
|
return `&wts=${curr_time}` + `&w_rid=${wbi_sign}`;
|
|
30
29
|
}
|
|
31
30
|
// 获取最新的 img_key 和 sub_key
|
|
32
|
-
async function getWbiKeys() {
|
|
31
|
+
async function getWbiKeys(cookie) {
|
|
33
32
|
const res = await fetch('https://api.bilibili.com/x/web-interface/nav', {
|
|
34
33
|
headers: {
|
|
35
|
-
Cookie:
|
|
34
|
+
Cookie: cookie,
|
|
36
35
|
},
|
|
37
36
|
});
|
|
38
37
|
const responseJson = await res.json();
|
|
@@ -44,8 +43,8 @@ async function getWbiKeys() {
|
|
|
44
43
|
sub_key: sub_url.slice(sub_url.lastIndexOf('/') + 1, sub_url.lastIndexOf('.')),
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
|
-
export default async function wbi_sign(BASEURL) {
|
|
48
|
-
const web_keys = await getWbiKeys();
|
|
46
|
+
export default async function wbi_sign(BASEURL, cookie) {
|
|
47
|
+
const web_keys = await getWbiKeys(cookie);
|
|
49
48
|
const url = new URL(BASEURL);
|
|
50
49
|
const params = {};
|
|
51
50
|
for (const [key, value] of url.searchParams.entries()) {
|
|
@@ -1,37 +1,17 @@
|
|
|
1
|
+
import { DouyinAPIParams } from '../../types/index.js';
|
|
1
2
|
declare class DouyinAPI {
|
|
2
|
-
视频或图集(data:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
aweme_id: string;
|
|
7
|
-
}): string;
|
|
8
|
-
二级评论(data: {
|
|
9
|
-
aweme_id: string;
|
|
10
|
-
comment_id: string;
|
|
11
|
-
}): string;
|
|
12
|
-
动图(data: {
|
|
13
|
-
aweme_id: string;
|
|
14
|
-
}): string;
|
|
3
|
+
视频或图集(data: DouyinAPIParams["WorkParams"]): string;
|
|
4
|
+
评论(data: DouyinAPIParams['WorkParams']): string;
|
|
5
|
+
二级评论(data: DouyinAPIParams['CommentParams']): string;
|
|
6
|
+
动图(data: DouyinAPIParams['WorkParams']): string;
|
|
15
7
|
表情(): string;
|
|
16
|
-
用户主页视频(data:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
sec_uid: string;
|
|
21
|
-
}): string;
|
|
22
|
-
热点词(data: {
|
|
23
|
-
query: string;
|
|
24
|
-
}): string;
|
|
25
|
-
搜索(data: {
|
|
26
|
-
query: string;
|
|
27
|
-
}): string;
|
|
8
|
+
用户主页视频(data: DouyinAPIParams['UserParams']): string;
|
|
9
|
+
用户主页信息(data: DouyinAPIParams['UserParams']): string;
|
|
10
|
+
热点词(data: DouyinAPIParams['SearchParams']): string;
|
|
11
|
+
搜索(data: DouyinAPIParams['SearchParams']): string;
|
|
28
12
|
互动表情(): string;
|
|
29
|
-
背景音乐(data:
|
|
30
|
-
|
|
31
|
-
}): string;
|
|
32
|
-
直播间信息(data: {
|
|
33
|
-
room_id: string;
|
|
34
|
-
}): string;
|
|
13
|
+
背景音乐(data: DouyinAPIParams['MusicParams']): string;
|
|
14
|
+
直播间信息(data: DouyinAPIParams['LiveRoomParams']): string;
|
|
35
15
|
}
|
|
36
16
|
declare const _default: DouyinAPI;
|
|
37
17
|
export default _default;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// 未初始化,必须这么导入
|
|
2
1
|
import Sign from './sign/index.js';
|
|
3
2
|
const fp = Sign.VerifyFpManager();
|
|
4
3
|
class DouyinAPI {
|
|
@@ -6,7 +5,7 @@ class DouyinAPI {
|
|
|
6
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}`;
|
|
7
6
|
}
|
|
8
7
|
评论(data) {
|
|
9
|
-
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
|
|
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}`;
|
|
10
9
|
}
|
|
11
10
|
二级评论(data) {
|
|
12
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}`;
|
|
@@ -3,7 +3,7 @@ export default class DouyinData {
|
|
|
3
3
|
type: DouyinDataType;
|
|
4
4
|
headers: any;
|
|
5
5
|
URL: string | undefined;
|
|
6
|
-
constructor(type: DouyinDataType);
|
|
6
|
+
constructor(type: DouyinDataType, cookie: string);
|
|
7
7
|
GetData(data?: DouyinOptionsType): Promise<any>;
|
|
8
8
|
GlobalGetData(options: NetworksConfigType): Promise<any>;
|
|
9
9
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Sign, DouyinAPI } from '../../business/douyin/index.js';
|
|
2
|
-
import { Networks
|
|
2
|
+
import { Networks } from '../../model/index.js';
|
|
3
3
|
export default class DouyinData {
|
|
4
4
|
type;
|
|
5
5
|
headers;
|
|
6
6
|
URL;
|
|
7
|
-
constructor(type) {
|
|
7
|
+
constructor(type, cookie) {
|
|
8
8
|
this.type = type;
|
|
9
9
|
this.headers = {
|
|
10
10
|
Accept: 'application/json, text/plain, */*',
|
|
@@ -20,7 +20,7 @@ export default class DouyinData {
|
|
|
20
20
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
|
|
21
21
|
'Content-Type': 'application/json',
|
|
22
22
|
Referer: 'https://www.douyin.com/?recommend=1',
|
|
23
|
-
Cookie:
|
|
23
|
+
Cookie: cookie
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
async GetData(data = {}) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DouyinDataType, GetDataResponseType, DouyinOptionsType } from '../../types/index.js';
|
|
2
2
|
export default class DouyinResult {
|
|
3
3
|
type: DouyinDataType;
|
|
4
|
-
|
|
4
|
+
cookie: string;
|
|
5
|
+
constructor(type: DouyinDataType, cookie: string);
|
|
5
6
|
result(options?: DouyinOptionsType): Promise<GetDataResponseType>;
|
|
6
7
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DouyinData, GetDouyinID } from '../../business/douyin/index.js';
|
|
2
2
|
export default class DouyinResult {
|
|
3
3
|
type;
|
|
4
|
-
|
|
4
|
+
cookie;
|
|
5
|
+
constructor(type, cookie) {
|
|
5
6
|
this.type = type;
|
|
7
|
+
this.cookie = cookie;
|
|
6
8
|
}
|
|
7
9
|
async result(options = {}) {
|
|
8
10
|
let result;
|
|
@@ -16,14 +18,14 @@ export default class DouyinResult {
|
|
|
16
18
|
case 'ExpressionPlusData':
|
|
17
19
|
case 'MusicData':
|
|
18
20
|
case 'LiveImageData':
|
|
19
|
-
result = await new DouyinData(this.type).GetData(options);
|
|
21
|
+
result = await new DouyinData(this.type, this.cookie).GetData(options);
|
|
20
22
|
break;
|
|
21
23
|
case 'VideoData':
|
|
22
24
|
case 'NoteData':
|
|
23
25
|
case 'CommentData': {
|
|
24
26
|
const defurl = options?.url?.toString().match(/(http|https):\/\/.*\.(douyin|iesdouyin)\.com\/[^ ]+/g);
|
|
25
27
|
const iddata = await GetDouyinID(String(defurl));
|
|
26
|
-
result = await new DouyinData(this.type).GetData(iddata);
|
|
28
|
+
result = await new DouyinData(this.type, this.cookie).GetData(iddata);
|
|
27
29
|
break;
|
|
28
30
|
}
|
|
29
31
|
default:
|
|
@@ -476,7 +476,7 @@ function generate_random_str () {
|
|
|
476
476
|
return String.fromCharCode.apply(null, random_str_list)
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
-
export function
|
|
479
|
+
export function signature (url_search_params, user_agent) {
|
|
480
480
|
/**
|
|
481
481
|
* url_search_params:"device_platform=webapp&aid=6383&channel=channel_pc_web&update_version_code=170400&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1536&screen_height=864&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=123.0.0.0&browser_online=true&engine_name=Blink&engine_version=123.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=50&webid=7362810250930783783&msToken=VkDUvz1y24CppXSl80iFPr6ez-3FiizcwD7fI1OqBt6IICq9RWG7nCvxKb8IVi55mFd-wnqoNkXGnxHrikQb4PuKob5Q-YhDp5Um215JzlBszkUyiEvR"
|
|
482
482
|
* user_agent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
|
-
import {
|
|
2
|
+
import { signature } from './a_bougs.js';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
const headers = {
|
|
5
5
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'
|
|
@@ -13,7 +13,7 @@ export default class sign {
|
|
|
13
13
|
}
|
|
14
14
|
/** a_bougs 签名算法 */
|
|
15
15
|
static AB(url) {
|
|
16
|
-
return
|
|
16
|
+
return signature(new URLSearchParams(new URL(url).search).toString(), headers['User-Agent']);
|
|
17
17
|
}
|
|
18
18
|
/** 生成一个唯一的验证字符串 */
|
|
19
19
|
static VerifyFpManager() {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* 是否启用日志
|
|
9
|
-
*/
|
|
10
|
-
log?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare const initServer: (client: FastifyInstance) => Promise<FastifyInstance>;
|
|
13
|
-
/**
|
|
14
|
-
* 添加路由
|
|
15
|
-
* @param client fastify实例
|
|
16
|
-
* @param routeOptions[] 路由参数,传递数组
|
|
17
|
-
* @param extend 是否继承 amagi 的默认路由
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
export declare const AddRoute: (client: FastifyInstance, routeOptions?: RouteOptions[], extend?: boolean) => any;
|
|
21
|
-
/** 创建一个新的 fastify 实例 */
|
|
22
|
-
export declare const CreateNewClient: (options: ServerOptions) => FastifyInstance;
|
|
23
|
-
/** 启动监听 */
|
|
24
|
-
export declare const StartClient: (client: FastifyInstance, options: ServerOptions) => Promise<void>;
|
|
25
|
-
interface RouteOptions {
|
|
26
|
-
method: HTTPMethods;
|
|
27
|
-
url: string;
|
|
28
|
-
handler: RouteHandler;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
1
|
+
export * from './model/index.js';
|
|
2
|
+
export * from './business/index.js';
|
|
3
|
+
export * from './types/index.js';
|
|
4
|
+
export * from './server/index.js';
|
|
5
|
+
import { client } from './server/index.js';
|
|
6
|
+
export declare const amagi: typeof client;
|
|
7
|
+
export { amagi as default };
|