@ikenxuan/amagi 4.4.16 → 4.4.17
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 +35 -42
- package/dist/default/cjs/index.cjs +130 -61
- package/dist/default/esm/index.mjs +130 -62
- package/dist/default/index.d.ts +164 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## 我是真爱粉 🧩
|
|
6
6
|
|
|
7
|
-
"amagi" /ˈæmədʒi/
|
|
7
|
+
"amagi" /ˈæmədʒi/ 名称灵感来源于网络谐音梗,在网络上 [BV1St41137jm](https://www.bilibili.com/video/BV1St41137jm) 上广泛传播。🎤💃
|
|
8
8
|
|
|
9
9
|
此生必看 [BV1DL411X7jE](https://www.bilibili.com/video/BV1DL411X7jE)
|
|
10
10
|
|
|
@@ -16,53 +16,54 @@ amagi 将作为一个独立的上游模块,提供给下游 [karin-plugin-kkk](
|
|
|
16
16
|
|
|
17
17
|
当然,如果你的下游有新的业务需求,欢迎提 issue 或 pr。(其实作者本人很菜,issue 不一定能解决)
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 安装/更新 📦
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
pnpm add @ikenxuan/amagi@latest
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## 快速开始 🚀
|
|
26
26
|
|
|
27
27
|
### 基本用法 ✨
|
|
28
|
+
主要就两个方法,`getDouyinData` 和 `getBilibiliData`。
|
|
29
|
+
它接收三个参数,第一个参数是 API 名称,第二个参数是 API 所需的参数,第三个参数是用户的 cookies。
|
|
30
|
+
若通过构造器创建实例,就不需要传入 cookies 参数了。
|
|
28
31
|
|
|
29
32
|
```javascript
|
|
30
33
|
import Client from '@ikenxuan/amagi'
|
|
34
|
+
// or
|
|
35
|
+
// import { getDouyinData, getBilibiliData } from '@ikenxuan/amagi'
|
|
31
36
|
|
|
32
|
-
//
|
|
33
|
-
const amagi =
|
|
34
|
-
|
|
35
|
-
bilibili: '', // B站 cookie(可选)
|
|
36
|
-
})
|
|
37
|
+
// you can use it as a class/function/object
|
|
38
|
+
const amagi = Client({...options})
|
|
39
|
+
const amagi = new Client({...options})
|
|
37
40
|
|
|
38
41
|
// 使用示例
|
|
39
42
|
async function example() {
|
|
40
43
|
// 获取抖音搜索数据
|
|
41
|
-
const searchData = await amagi.getDouyinData(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const searchData = await amagi.getDouyinData(
|
|
45
|
+
'搜索数据',
|
|
46
|
+
{ ...opt }
|
|
47
|
+
)
|
|
45
48
|
|
|
46
49
|
// 获取B站视频数据
|
|
47
|
-
const videoData = await amagi.getBilibiliData(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
const videoData = await amagi.getBilibiliData(
|
|
51
|
+
'单个视频作品数据',
|
|
52
|
+
{ ...opt }
|
|
53
|
+
)
|
|
50
54
|
|
|
51
55
|
console.log(searchData)
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
example()
|
|
55
59
|
```
|
|
56
|
-
|
|
60
|
+
## Advanced
|
|
57
61
|
### 启动本地 HTTP 服务 🌐
|
|
58
62
|
|
|
59
63
|
```javascript
|
|
60
64
|
import Client from '@ikenxuan/amagi'
|
|
61
65
|
|
|
62
|
-
const amagi = new Client({
|
|
63
|
-
douyin: '你的抖音cookie',
|
|
64
|
-
bilibili: '你的B站cookie',
|
|
65
|
-
})
|
|
66
|
+
const amagi = new Client({...options})
|
|
66
67
|
|
|
67
68
|
// 启动本地服务,默认端口 4567
|
|
68
69
|
const app = amagi.startClient()
|
|
@@ -95,24 +96,20 @@ const abSign = douyinUtils.sign.AB('需要签名的地址')
|
|
|
95
96
|
|
|
96
97
|
// 使用 API 接口
|
|
97
98
|
const videoData = await douyinUtils.api.getWorkInfo(
|
|
98
|
-
{
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
'有效的用户 Cookie'
|
|
99
|
+
{ ...opt },
|
|
100
|
+
'cookies'
|
|
102
101
|
)
|
|
103
102
|
|
|
104
103
|
const userInfo = await douyinUtils.api.getUserProfile(
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
'有效的用户 Cookie'
|
|
104
|
+
{ ...opt },
|
|
105
|
+
'cookies'
|
|
109
106
|
)
|
|
110
107
|
|
|
111
108
|
// 直接获取数据
|
|
112
|
-
const searchResult = await douyinUtils.getDouyinData(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
const searchResult = await douyinUtils.getDouyinData(
|
|
110
|
+
'搜索数据',
|
|
111
|
+
{ ...opt }
|
|
112
|
+
)
|
|
116
113
|
```
|
|
117
114
|
|
|
118
115
|
主要功能:
|
|
@@ -133,20 +130,16 @@ bilibili 相关功能模块提供了获取 bilibili 平台数据的工具和 API
|
|
|
133
130
|
import { bilibiliUtils } from '@ikenxuan/amagi'
|
|
134
131
|
|
|
135
132
|
// 获取视频信息
|
|
136
|
-
const videoInfo = await bilibiliUtils.api.getVideoInfo({
|
|
137
|
-
bvid: 'BV1fK4y1q79u',
|
|
138
|
-
})
|
|
133
|
+
const videoInfo = await bilibiliUtils.api.getVideoInfo({ ...opt })
|
|
139
134
|
|
|
140
135
|
// 获取评论数据
|
|
141
|
-
const comments = await bilibiliUtils.api.getComments({
|
|
142
|
-
oid: 111111, // 稿件ID,也就是AV号去除前缀后的内容
|
|
143
|
-
type: 1,
|
|
144
|
-
})
|
|
136
|
+
const comments = await bilibiliUtils.api.getComments({ ...opt })
|
|
145
137
|
|
|
146
138
|
// 直接获取数据
|
|
147
|
-
const userInfo = await bilibiliUtils.getBilibiliData(
|
|
148
|
-
|
|
149
|
-
}
|
|
139
|
+
const userInfo = await bilibiliUtils.getBilibiliData(
|
|
140
|
+
'用户主页数据',
|
|
141
|
+
{ ...opt }
|
|
142
|
+
)
|
|
150
143
|
```
|
|
151
144
|
|
|
152
145
|
主要功能:
|
|
@@ -474,7 +474,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
474
474
|
}, req.headers.cookie || cookie);
|
|
475
475
|
res.json(data2);
|
|
476
476
|
});
|
|
477
|
-
router.get("/
|
|
477
|
+
router.get("/fetch_emoji_list", async (req, res) => {
|
|
478
478
|
const data2 = await fetchBilibili({
|
|
479
479
|
methodType: "Emoji\u6570\u636E"
|
|
480
480
|
}, req.headers.cookie || cookie);
|
|
@@ -547,7 +547,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
547
547
|
router.get("/av_to_bv", async (req, res) => {
|
|
548
548
|
const data2 = await fetchBilibili({
|
|
549
549
|
methodType: "AV\u8F6CBV",
|
|
550
|
-
avid:
|
|
550
|
+
avid: req.query.avid
|
|
551
551
|
}, req.headers.cookie || cookie);
|
|
552
552
|
res.json(data2);
|
|
553
553
|
});
|
|
@@ -835,44 +835,66 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
835
835
|
}
|
|
836
836
|
};
|
|
837
837
|
var GlobalGetData = async (options) => {
|
|
838
|
+
let warningMessage = "";
|
|
838
839
|
try {
|
|
839
840
|
const result = await new Networks(options).getData();
|
|
840
|
-
if (result
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
\
|
|
841
|
+
if (!result || result === "") {
|
|
842
|
+
const Err = {
|
|
843
|
+
errorDescription: "\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684B\u7AD9ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01",
|
|
844
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
845
|
+
requestUrl: options.url
|
|
846
|
+
};
|
|
847
|
+
warningMessage = `
|
|
848
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684B\u7AD9ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
|
|
849
|
+
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
850
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
851
|
+
`;
|
|
848
852
|
logger.warn(warningMessage);
|
|
849
853
|
throw {
|
|
850
|
-
|
|
851
|
-
|
|
854
|
+
code: "-352" /* RISK_CONTROL_FAILED */,
|
|
855
|
+
data: result,
|
|
856
|
+
amagiError: Err
|
|
852
857
|
};
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
\
|
|
858
|
-
\
|
|
859
|
-
|
|
858
|
+
}
|
|
859
|
+
if (result.code !== 0) {
|
|
860
|
+
const errorMessage = bilibiliErrorCodeMap[result.code] || result.message || "\u672A\u77E5\u9519\u8BEF";
|
|
861
|
+
const Err = {
|
|
862
|
+
errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${errorMessage}\uFF01`,
|
|
863
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
864
|
+
requestUrl: options.url
|
|
865
|
+
};
|
|
866
|
+
warningMessage = `
|
|
867
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow(errorMessage)}
|
|
868
|
+
\u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}
|
|
869
|
+
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
870
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
871
|
+
`;
|
|
860
872
|
logger.warn(warningMessage);
|
|
861
873
|
throw {
|
|
862
|
-
|
|
863
|
-
|
|
874
|
+
code: result.code,
|
|
875
|
+
data: result,
|
|
876
|
+
amagiError: Err
|
|
864
877
|
};
|
|
865
878
|
}
|
|
879
|
+
return result;
|
|
866
880
|
} catch (error) {
|
|
867
881
|
if (error && typeof error === "object") {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
warning: error.warning || "\u672A\u77E5\u9519\u8BEF"
|
|
871
|
-
};
|
|
882
|
+
const err = error;
|
|
883
|
+
return { ...err, amagiMessage: warningMessage };
|
|
872
884
|
}
|
|
885
|
+
return {
|
|
886
|
+
code: "UNKNOWN_ERROR" /* UNKNOWN */,
|
|
887
|
+
data: error.data,
|
|
888
|
+
amagiError: {
|
|
889
|
+
errorDescription: "\u672A\u77E5\u9519\u8BEF",
|
|
890
|
+
requestType: options.methodType,
|
|
891
|
+
requestUrl: options.url
|
|
892
|
+
},
|
|
893
|
+
amagiMessage: warningMessage
|
|
894
|
+
};
|
|
873
895
|
}
|
|
874
896
|
};
|
|
875
|
-
var
|
|
897
|
+
var bilibiliErrorCodeMap = {
|
|
876
898
|
"-1": "\u5E94\u7528\u7A0B\u5E8F\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5C01\u7981",
|
|
877
899
|
"-2": "Access Key \u9519\u8BEF",
|
|
878
900
|
"-3": "API \u6821\u9A8C\u5BC6\u5319\u9519\u8BEF",
|
|
@@ -1668,6 +1690,7 @@ var defheaders2 = {
|
|
|
1668
1690
|
connection: "keep-alive"
|
|
1669
1691
|
};
|
|
1670
1692
|
var DouyinData = async (data2, cookie) => {
|
|
1693
|
+
var _a, _b;
|
|
1671
1694
|
const headers2 = {
|
|
1672
1695
|
...defheaders2,
|
|
1673
1696
|
cookie: cookie ? cookie.replace(/\s+/g, "") : ""
|
|
@@ -1814,15 +1837,29 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1814
1837
|
case "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": {
|
|
1815
1838
|
DouyinValidateData(data2, ["sec_uid"]);
|
|
1816
1839
|
let url = douyinApiUrls.\u7528\u6237\u4E3B\u9875\u4FE1\u606F({ sec_uid: data2.sec_uid });
|
|
1840
|
+
const fetchUrl = `${url}&a_bogus=${douyinSign.AB(url)}`;
|
|
1817
1841
|
const UserInfoData = await GlobalGetData2({
|
|
1818
|
-
url:
|
|
1842
|
+
url: fetchUrl,
|
|
1819
1843
|
headers: {
|
|
1820
1844
|
...headers2,
|
|
1821
1845
|
Referer: `https://www.douyin.com/user/${data2.sec_uid}`
|
|
1822
1846
|
},
|
|
1823
1847
|
...data2
|
|
1824
1848
|
});
|
|
1825
|
-
if (UserInfoData.user.live_status
|
|
1849
|
+
if (!((_a = UserInfoData == null ? void 0 : UserInfoData.user) == null ? void 0 : _a.live_status) || UserInfoData.user.live_status !== 1) {
|
|
1850
|
+
logger.error((((_b = UserInfoData == null ? void 0 : UserInfoData.user) == null ? void 0 : _b.nickname) || "\u7528\u6237") + "\u5F53\u524D\u672A\u5728\u76F4\u64AD");
|
|
1851
|
+
const Err = {
|
|
1852
|
+
errorDescription: "\u68C0\u67E5\u5931\u8D25\uFF01\u8BE5\u7528\u6237\u5F53\u524D\u672A\u5728\u76F4\u64AD\uFF01 TypeError: Cannot read properties of undefined (reading 'live_status')",
|
|
1853
|
+
requestType: data2.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
1854
|
+
requestUrl: fetchUrl
|
|
1855
|
+
};
|
|
1856
|
+
return {
|
|
1857
|
+
code: "USER_NOT_LIVE" /* NOT_LIVE */,
|
|
1858
|
+
data: UserInfoData,
|
|
1859
|
+
amagiError: Err,
|
|
1860
|
+
amagiMessage: Err.errorDescription
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1826
1863
|
if (!UserInfoData.user.room_data) {
|
|
1827
1864
|
logger.error("\u672A\u83B7\u53D6\u5230\u76F4\u64AD\u95F4\u4FE1\u606F\uFF01");
|
|
1828
1865
|
return {
|
|
@@ -1889,45 +1926,62 @@ var fetchPaginatedData = async (apiUrlGenerator, params, maxPageSize, headers2)
|
|
|
1889
1926
|
return finalResponse;
|
|
1890
1927
|
};
|
|
1891
1928
|
async function GlobalGetData2(options) {
|
|
1929
|
+
let warningMessage = "";
|
|
1892
1930
|
try {
|
|
1893
1931
|
const result = await new Networks(options).getData();
|
|
1894
|
-
if (result === ""
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1897
|
-
|
|
1932
|
+
if (!result || result === "") {
|
|
1933
|
+
const Err = {
|
|
1934
|
+
errorDescription: "\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01",
|
|
1935
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
1936
|
+
requestUrl: options.url
|
|
1937
|
+
};
|
|
1938
|
+
warningMessage = `
|
|
1939
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
|
|
1898
1940
|
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
1899
|
-
\u8BF7\u6C42URL\uFF1A
|
|
1941
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
1900
1942
|
`;
|
|
1901
1943
|
logger.warn(warningMessage);
|
|
1902
1944
|
throw {
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1945
|
+
code: "INVALID_COOKIE" /* COOKIE */,
|
|
1946
|
+
data: result,
|
|
1947
|
+
amagiError: Err
|
|
1906
1948
|
};
|
|
1907
1949
|
}
|
|
1908
1950
|
if (result.filter_detail && result.filter_detail.filter_reason) {
|
|
1909
1951
|
const filterReason = result.filter_detail.filter_reason;
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1952
|
+
const Err = {
|
|
1953
|
+
errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${filterReason}\uFF01`,
|
|
1954
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
1955
|
+
requestUrl: options.url
|
|
1956
|
+
};
|
|
1957
|
+
warningMessage = `
|
|
1958
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow(filterReason)}
|
|
1912
1959
|
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
1913
|
-
\u8BF7\u6C42URL\uFF1A
|
|
1960
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
1914
1961
|
`;
|
|
1915
1962
|
logger.warn(warningMessage);
|
|
1916
1963
|
throw {
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1964
|
+
code: "CONTENT_FILTERED" /* FILTER */,
|
|
1965
|
+
data: result,
|
|
1966
|
+
amagiError: Err
|
|
1920
1967
|
};
|
|
1921
1968
|
}
|
|
1922
1969
|
return result;
|
|
1923
1970
|
} catch (error) {
|
|
1924
1971
|
if (error && typeof error === "object") {
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
code: error.status_code || 500,
|
|
1928
|
-
warning: error.warning || "\u672A\u77E5\u9519\u8BEF"
|
|
1929
|
-
};
|
|
1972
|
+
const err = error;
|
|
1973
|
+
return { ...err, amagiMessage: warningMessage };
|
|
1930
1974
|
}
|
|
1975
|
+
return {
|
|
1976
|
+
code: "UNKNOWN_ERROR" /* UNKNOWN */,
|
|
1977
|
+
data: null,
|
|
1978
|
+
amagiError: {
|
|
1979
|
+
errorDescription: "\u672A\u77E5\u9519\u8BEF",
|
|
1980
|
+
requestType: options.methodType,
|
|
1981
|
+
requestUrl: options.url
|
|
1982
|
+
},
|
|
1983
|
+
amagiMessage: warningMessage
|
|
1984
|
+
};
|
|
1931
1985
|
}
|
|
1932
1986
|
}
|
|
1933
1987
|
|
|
@@ -2103,31 +2157,45 @@ var KuaishouData = async (data2, cookie) => {
|
|
|
2103
2157
|
}
|
|
2104
2158
|
};
|
|
2105
2159
|
async function GlobalGetData3(options) {
|
|
2160
|
+
let warningMessage = "";
|
|
2106
2161
|
try {
|
|
2107
2162
|
const result = await new Networks(options).getData();
|
|
2108
2163
|
if (result === "" || !result || result.result === 2) {
|
|
2109
|
-
const
|
|
2110
|
-
\
|
|
2111
|
-
\u8BF7\u6C42\u7C7B\u578B
|
|
2112
|
-
|
|
2113
|
-
|
|
2164
|
+
const Err = {
|
|
2165
|
+
errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF01`,
|
|
2166
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
2167
|
+
requestUrl: options.url,
|
|
2168
|
+
requestBody: JSON.stringify(options.body)
|
|
2169
|
+
};
|
|
2170
|
+
warningMessage = `
|
|
2171
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u5FEB\u624Bck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
|
|
2172
|
+
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
2173
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
2174
|
+
\u8BF7\u6C42\u53C2\u6570\uFF1A${JSON.stringify(options.body, null, 2)}
|
|
2175
|
+
`;
|
|
2114
2176
|
logger.warn(warningMessage);
|
|
2115
2177
|
throw {
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2178
|
+
code: "INVALID_COOKIE" /* COOKIE */,
|
|
2179
|
+
data: result,
|
|
2180
|
+
amagiError: Err
|
|
2119
2181
|
};
|
|
2120
2182
|
}
|
|
2121
2183
|
return result;
|
|
2122
2184
|
} catch (error) {
|
|
2123
2185
|
if (error && typeof error === "object") {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
code: error.result || 500,
|
|
2127
|
-
message: error.error_msg,
|
|
2128
|
-
warning: error.warning || "\u672A\u77E5\u9519\u8BEF"
|
|
2129
|
-
};
|
|
2186
|
+
const err = error;
|
|
2187
|
+
return { ...err, amagiMessage: warningMessage };
|
|
2130
2188
|
}
|
|
2189
|
+
return {
|
|
2190
|
+
code: "UNKNOWN_ERROR" /* UNKNOWN */,
|
|
2191
|
+
data: null,
|
|
2192
|
+
amagiError: {
|
|
2193
|
+
errorDescription: "\u672A\u77E5\u9519\u8BEF",
|
|
2194
|
+
requestType: options.methodType,
|
|
2195
|
+
requestUrl: options.url
|
|
2196
|
+
},
|
|
2197
|
+
amagiMessage: warningMessage
|
|
2198
|
+
};
|
|
2131
2199
|
}
|
|
2132
2200
|
}
|
|
2133
2201
|
|
|
@@ -2536,6 +2604,7 @@ exports.av2bv = av2bv;
|
|
|
2536
2604
|
exports.bilibili = bilibili;
|
|
2537
2605
|
exports.bilibiliAPI = bilibiliAPI;
|
|
2538
2606
|
exports.bilibiliApiUrls = bilibiliApiUrls;
|
|
2607
|
+
exports.bilibiliErrorCodeMap = bilibiliErrorCodeMap;
|
|
2539
2608
|
exports.bilibiliUtils = bilibiliUtils;
|
|
2540
2609
|
exports.bv2av = bv2av;
|
|
2541
2610
|
exports.default = Client;
|
|
@@ -462,7 +462,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
462
462
|
}, req.headers.cookie || cookie);
|
|
463
463
|
res.json(data2);
|
|
464
464
|
});
|
|
465
|
-
router.get("/
|
|
465
|
+
router.get("/fetch_emoji_list", async (req, res) => {
|
|
466
466
|
const data2 = await fetchBilibili({
|
|
467
467
|
methodType: "Emoji\u6570\u636E"
|
|
468
468
|
}, req.headers.cookie || cookie);
|
|
@@ -535,7 +535,7 @@ var registerBilibiliRoutes = (cookie) => {
|
|
|
535
535
|
router.get("/av_to_bv", async (req, res) => {
|
|
536
536
|
const data2 = await fetchBilibili({
|
|
537
537
|
methodType: "AV\u8F6CBV",
|
|
538
|
-
avid:
|
|
538
|
+
avid: req.query.avid
|
|
539
539
|
}, req.headers.cookie || cookie);
|
|
540
540
|
res.json(data2);
|
|
541
541
|
});
|
|
@@ -823,44 +823,66 @@ var fetchBilibili = async (data2, cookie) => {
|
|
|
823
823
|
}
|
|
824
824
|
};
|
|
825
825
|
var GlobalGetData = async (options) => {
|
|
826
|
+
let warningMessage = "";
|
|
826
827
|
try {
|
|
827
828
|
const result = await new Networks(options).getData();
|
|
828
|
-
if (result
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
\
|
|
829
|
+
if (!result || result === "") {
|
|
830
|
+
const Err = {
|
|
831
|
+
errorDescription: "\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684B\u7AD9ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01",
|
|
832
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
833
|
+
requestUrl: options.url
|
|
834
|
+
};
|
|
835
|
+
warningMessage = `
|
|
836
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684B\u7AD9ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
|
|
837
|
+
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
838
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
839
|
+
`;
|
|
836
840
|
logger.warn(warningMessage);
|
|
837
841
|
throw {
|
|
838
|
-
|
|
839
|
-
|
|
842
|
+
code: "-352" /* RISK_CONTROL_FAILED */,
|
|
843
|
+
data: result,
|
|
844
|
+
amagiError: Err
|
|
840
845
|
};
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
\
|
|
846
|
-
\
|
|
847
|
-
|
|
846
|
+
}
|
|
847
|
+
if (result.code !== 0) {
|
|
848
|
+
const errorMessage = bilibiliErrorCodeMap[result.code] || result.message || "\u672A\u77E5\u9519\u8BEF";
|
|
849
|
+
const Err = {
|
|
850
|
+
errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${errorMessage}\uFF01`,
|
|
851
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
852
|
+
requestUrl: options.url
|
|
853
|
+
};
|
|
854
|
+
warningMessage = `
|
|
855
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow(errorMessage)}
|
|
856
|
+
\u9519\u8BEF\u4EE3\u7801\uFF1A${result.code}
|
|
857
|
+
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
858
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
859
|
+
`;
|
|
848
860
|
logger.warn(warningMessage);
|
|
849
861
|
throw {
|
|
850
|
-
|
|
851
|
-
|
|
862
|
+
code: result.code,
|
|
863
|
+
data: result,
|
|
864
|
+
amagiError: Err
|
|
852
865
|
};
|
|
853
866
|
}
|
|
867
|
+
return result;
|
|
854
868
|
} catch (error) {
|
|
855
869
|
if (error && typeof error === "object") {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
warning: error.warning || "\u672A\u77E5\u9519\u8BEF"
|
|
859
|
-
};
|
|
870
|
+
const err = error;
|
|
871
|
+
return { ...err, amagiMessage: warningMessage };
|
|
860
872
|
}
|
|
873
|
+
return {
|
|
874
|
+
code: "UNKNOWN_ERROR" /* UNKNOWN */,
|
|
875
|
+
data: error.data,
|
|
876
|
+
amagiError: {
|
|
877
|
+
errorDescription: "\u672A\u77E5\u9519\u8BEF",
|
|
878
|
+
requestType: options.methodType,
|
|
879
|
+
requestUrl: options.url
|
|
880
|
+
},
|
|
881
|
+
amagiMessage: warningMessage
|
|
882
|
+
};
|
|
861
883
|
}
|
|
862
884
|
};
|
|
863
|
-
var
|
|
885
|
+
var bilibiliErrorCodeMap = {
|
|
864
886
|
"-1": "\u5E94\u7528\u7A0B\u5E8F\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5C01\u7981",
|
|
865
887
|
"-2": "Access Key \u9519\u8BEF",
|
|
866
888
|
"-3": "API \u6821\u9A8C\u5BC6\u5319\u9519\u8BEF",
|
|
@@ -1656,6 +1678,7 @@ var defheaders2 = {
|
|
|
1656
1678
|
connection: "keep-alive"
|
|
1657
1679
|
};
|
|
1658
1680
|
var DouyinData = async (data2, cookie) => {
|
|
1681
|
+
var _a, _b;
|
|
1659
1682
|
const headers2 = {
|
|
1660
1683
|
...defheaders2,
|
|
1661
1684
|
cookie: cookie ? cookie.replace(/\s+/g, "") : ""
|
|
@@ -1802,15 +1825,29 @@ var DouyinData = async (data2, cookie) => {
|
|
|
1802
1825
|
case "\u76F4\u64AD\u95F4\u4FE1\u606F\u6570\u636E": {
|
|
1803
1826
|
DouyinValidateData(data2, ["sec_uid"]);
|
|
1804
1827
|
let url = douyinApiUrls.\u7528\u6237\u4E3B\u9875\u4FE1\u606F({ sec_uid: data2.sec_uid });
|
|
1828
|
+
const fetchUrl = `${url}&a_bogus=${douyinSign.AB(url)}`;
|
|
1805
1829
|
const UserInfoData = await GlobalGetData2({
|
|
1806
|
-
url:
|
|
1830
|
+
url: fetchUrl,
|
|
1807
1831
|
headers: {
|
|
1808
1832
|
...headers2,
|
|
1809
1833
|
Referer: `https://www.douyin.com/user/${data2.sec_uid}`
|
|
1810
1834
|
},
|
|
1811
1835
|
...data2
|
|
1812
1836
|
});
|
|
1813
|
-
if (UserInfoData.user.live_status
|
|
1837
|
+
if (!((_a = UserInfoData == null ? void 0 : UserInfoData.user) == null ? void 0 : _a.live_status) || UserInfoData.user.live_status !== 1) {
|
|
1838
|
+
logger.error((((_b = UserInfoData == null ? void 0 : UserInfoData.user) == null ? void 0 : _b.nickname) || "\u7528\u6237") + "\u5F53\u524D\u672A\u5728\u76F4\u64AD");
|
|
1839
|
+
const Err = {
|
|
1840
|
+
errorDescription: "\u68C0\u67E5\u5931\u8D25\uFF01\u8BE5\u7528\u6237\u5F53\u524D\u672A\u5728\u76F4\u64AD\uFF01 TypeError: Cannot read properties of undefined (reading 'live_status')",
|
|
1841
|
+
requestType: data2.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
1842
|
+
requestUrl: fetchUrl
|
|
1843
|
+
};
|
|
1844
|
+
return {
|
|
1845
|
+
code: "USER_NOT_LIVE" /* NOT_LIVE */,
|
|
1846
|
+
data: UserInfoData,
|
|
1847
|
+
amagiError: Err,
|
|
1848
|
+
amagiMessage: Err.errorDescription
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1814
1851
|
if (!UserInfoData.user.room_data) {
|
|
1815
1852
|
logger.error("\u672A\u83B7\u53D6\u5230\u76F4\u64AD\u95F4\u4FE1\u606F\uFF01");
|
|
1816
1853
|
return {
|
|
@@ -1877,45 +1914,62 @@ var fetchPaginatedData = async (apiUrlGenerator, params, maxPageSize, headers2)
|
|
|
1877
1914
|
return finalResponse;
|
|
1878
1915
|
};
|
|
1879
1916
|
async function GlobalGetData2(options) {
|
|
1917
|
+
let warningMessage = "";
|
|
1880
1918
|
try {
|
|
1881
1919
|
const result = await new Networks(options).getData();
|
|
1882
|
-
if (result === ""
|
|
1883
|
-
const
|
|
1884
|
-
|
|
1885
|
-
|
|
1920
|
+
if (!result || result === "") {
|
|
1921
|
+
const Err = {
|
|
1922
|
+
errorDescription: "\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01",
|
|
1923
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
1924
|
+
requestUrl: options.url
|
|
1925
|
+
};
|
|
1926
|
+
warningMessage = `
|
|
1927
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u6296\u97F3ck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
|
|
1886
1928
|
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
1887
|
-
\u8BF7\u6C42URL\uFF1A
|
|
1929
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
1888
1930
|
`;
|
|
1889
1931
|
logger.warn(warningMessage);
|
|
1890
1932
|
throw {
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1933
|
+
code: "INVALID_COOKIE" /* COOKIE */,
|
|
1934
|
+
data: result,
|
|
1935
|
+
amagiError: Err
|
|
1894
1936
|
};
|
|
1895
1937
|
}
|
|
1896
1938
|
if (result.filter_detail && result.filter_detail.filter_reason) {
|
|
1897
1939
|
const filterReason = result.filter_detail.filter_reason;
|
|
1898
|
-
const
|
|
1899
|
-
|
|
1940
|
+
const Err = {
|
|
1941
|
+
errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${filterReason}\uFF01`,
|
|
1942
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
1943
|
+
requestUrl: options.url
|
|
1944
|
+
};
|
|
1945
|
+
warningMessage = `
|
|
1946
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow(filterReason)}
|
|
1900
1947
|
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
1901
|
-
\u8BF7\u6C42URL\uFF1A
|
|
1948
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
1902
1949
|
`;
|
|
1903
1950
|
logger.warn(warningMessage);
|
|
1904
1951
|
throw {
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1952
|
+
code: "CONTENT_FILTERED" /* FILTER */,
|
|
1953
|
+
data: result,
|
|
1954
|
+
amagiError: Err
|
|
1908
1955
|
};
|
|
1909
1956
|
}
|
|
1910
1957
|
return result;
|
|
1911
1958
|
} catch (error) {
|
|
1912
1959
|
if (error && typeof error === "object") {
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
code: error.status_code || 500,
|
|
1916
|
-
warning: error.warning || "\u672A\u77E5\u9519\u8BEF"
|
|
1917
|
-
};
|
|
1960
|
+
const err = error;
|
|
1961
|
+
return { ...err, amagiMessage: warningMessage };
|
|
1918
1962
|
}
|
|
1963
|
+
return {
|
|
1964
|
+
code: "UNKNOWN_ERROR" /* UNKNOWN */,
|
|
1965
|
+
data: null,
|
|
1966
|
+
amagiError: {
|
|
1967
|
+
errorDescription: "\u672A\u77E5\u9519\u8BEF",
|
|
1968
|
+
requestType: options.methodType,
|
|
1969
|
+
requestUrl: options.url
|
|
1970
|
+
},
|
|
1971
|
+
amagiMessage: warningMessage
|
|
1972
|
+
};
|
|
1919
1973
|
}
|
|
1920
1974
|
}
|
|
1921
1975
|
|
|
@@ -2091,31 +2145,45 @@ var KuaishouData = async (data2, cookie) => {
|
|
|
2091
2145
|
}
|
|
2092
2146
|
};
|
|
2093
2147
|
async function GlobalGetData3(options) {
|
|
2148
|
+
let warningMessage = "";
|
|
2094
2149
|
try {
|
|
2095
2150
|
const result = await new Networks(options).getData();
|
|
2096
2151
|
if (result === "" || !result || result.result === 2) {
|
|
2097
|
-
const
|
|
2098
|
-
\
|
|
2099
|
-
\u8BF7\u6C42\u7C7B\u578B
|
|
2100
|
-
|
|
2101
|
-
|
|
2152
|
+
const Err = {
|
|
2153
|
+
errorDescription: `\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF01`,
|
|
2154
|
+
requestType: options.methodType ?? "\u672A\u77E5\u8BF7\u6C42\u7C7B\u578B",
|
|
2155
|
+
requestUrl: options.url,
|
|
2156
|
+
requestBody: JSON.stringify(options.body)
|
|
2157
|
+
};
|
|
2158
|
+
warningMessage = `
|
|
2159
|
+
\u83B7\u53D6\u54CD\u5E94\u6570\u636E\u5931\u8D25\uFF01\u539F\u56E0\uFF1A${logger.yellow("\u63A5\u53E3\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u4F60\u7684\u5FEB\u624Bck\u53EF\u80FD\u5DF2\u7ECF\u5931\u6548\uFF01")}
|
|
2160
|
+
\u8BF7\u6C42\u7C7B\u578B\uFF1A\u300C${options.methodType}\u300D
|
|
2161
|
+
\u8BF7\u6C42URL\uFF1A${options.url}
|
|
2162
|
+
\u8BF7\u6C42\u53C2\u6570\uFF1A${JSON.stringify(options.body, null, 2)}
|
|
2163
|
+
`;
|
|
2102
2164
|
logger.warn(warningMessage);
|
|
2103
2165
|
throw {
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2166
|
+
code: "INVALID_COOKIE" /* COOKIE */,
|
|
2167
|
+
data: result,
|
|
2168
|
+
amagiError: Err
|
|
2107
2169
|
};
|
|
2108
2170
|
}
|
|
2109
2171
|
return result;
|
|
2110
2172
|
} catch (error) {
|
|
2111
2173
|
if (error && typeof error === "object") {
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
code: error.result || 500,
|
|
2115
|
-
message: error.error_msg,
|
|
2116
|
-
warning: error.warning || "\u672A\u77E5\u9519\u8BEF"
|
|
2117
|
-
};
|
|
2174
|
+
const err = error;
|
|
2175
|
+
return { ...err, amagiMessage: warningMessage };
|
|
2118
2176
|
}
|
|
2177
|
+
return {
|
|
2178
|
+
code: "UNKNOWN_ERROR" /* UNKNOWN */,
|
|
2179
|
+
data: null,
|
|
2180
|
+
amagiError: {
|
|
2181
|
+
errorDescription: "\u672A\u77E5\u9519\u8BEF",
|
|
2182
|
+
requestType: options.methodType,
|
|
2183
|
+
requestUrl: options.url
|
|
2184
|
+
},
|
|
2185
|
+
amagiMessage: warningMessage
|
|
2186
|
+
};
|
|
2119
2187
|
}
|
|
2120
2188
|
}
|
|
2121
2189
|
|
|
@@ -2512,4 +2580,4 @@ var CreateApp = createAmagiClient;
|
|
|
2512
2580
|
var Client = CreateApp;
|
|
2513
2581
|
var amagi = Client;
|
|
2514
2582
|
|
|
2515
|
-
export { BilibiliValidateData, CreateApp, DouyinValidateData, KuaishouAPI, KusiahouValidateData, Networks, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliUtils, bv2av, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
|
2583
|
+
export { BilibiliValidateData, CreateApp, DouyinValidateData, KuaishouAPI, KusiahouValidateData, Networks, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
package/dist/default/index.d.ts
CHANGED
|
@@ -387,6 +387,147 @@ type NetworksConfigType = {
|
|
|
387
387
|
*/
|
|
388
388
|
methodType?: string;
|
|
389
389
|
};
|
|
390
|
+
/** API标准化HTTP请求错误类型 */
|
|
391
|
+
type ErrorDetail = {
|
|
392
|
+
/**
|
|
393
|
+
* 错误描述信息
|
|
394
|
+
*/
|
|
395
|
+
errorDescription: string;
|
|
396
|
+
/**
|
|
397
|
+
* 请求类型
|
|
398
|
+
*/
|
|
399
|
+
requestType: string;
|
|
400
|
+
/**
|
|
401
|
+
* 请求URL地址
|
|
402
|
+
*/
|
|
403
|
+
requestUrl: string;
|
|
404
|
+
};
|
|
405
|
+
/** 未知错误 */
|
|
406
|
+
declare enum amagiAPIErrorCode {
|
|
407
|
+
/** 未知错误 */
|
|
408
|
+
UNKNOWN = "UNKNOWN_ERROR"
|
|
409
|
+
}
|
|
410
|
+
/** 抖音平台API错误码 */
|
|
411
|
+
declare enum douoyinAPIErrorCode {
|
|
412
|
+
/** Cookie无效或已过期 */
|
|
413
|
+
COOKIE = "INVALID_COOKIE",
|
|
414
|
+
/** 内容被隐藏或下架 */
|
|
415
|
+
FILTER = "CONTENT_FILTERED",
|
|
416
|
+
/** 当前用户未开播 */
|
|
417
|
+
NOT_LIVE = "USER_NOT_LIVE",
|
|
418
|
+
/** 未知错误 */
|
|
419
|
+
UNKNOWN = "UNKNOWN_ERROR"
|
|
420
|
+
}
|
|
421
|
+
/** B站平台API错误码 */
|
|
422
|
+
declare enum bilibiliAPIErrorCode {
|
|
423
|
+
/** 应用程序不存在或已被封禁 */
|
|
424
|
+
APP_NOT_FOUND = "-1",
|
|
425
|
+
/** Access Key 错误 */
|
|
426
|
+
ACCESS_KEY_ERROR = "-2",
|
|
427
|
+
/** API 校验密匙错误 */
|
|
428
|
+
API_KEY_ERROR = "-3",
|
|
429
|
+
/** 调用方对该Method没有权限 */
|
|
430
|
+
METHOD_NOT_PERMITTED = "-4",
|
|
431
|
+
/** 账号未登录 */
|
|
432
|
+
NOT_LOGGED_IN = "-101",
|
|
433
|
+
/** 账号被封停 */
|
|
434
|
+
ACCOUNT_BANNED = "-102",
|
|
435
|
+
/** 积分不足 */
|
|
436
|
+
POINTS_INSUFFICIENT = "-103",
|
|
437
|
+
/** 硬币不足 */
|
|
438
|
+
COINS_INSUFFICIENT = "-104",
|
|
439
|
+
/** 验证码错误 */
|
|
440
|
+
CAPTCHA_ERROR = "-105",
|
|
441
|
+
/** 账号非正式会员或在适应期 */
|
|
442
|
+
MEMBERSHIP_LIMITED = "-106",
|
|
443
|
+
/** 应用不存在或者被封禁 */
|
|
444
|
+
APP_BANNED = "-107",
|
|
445
|
+
/** 未绑定手机 */
|
|
446
|
+
PHONE_NOT_BOUND = "-108",
|
|
447
|
+
/** 未绑定手机 */
|
|
448
|
+
PHONE_NOT_BOUND_2 = "-110",
|
|
449
|
+
/** csrf 校验失败 */
|
|
450
|
+
CSRF_ERROR = "-111",
|
|
451
|
+
/** 系统升级中 */
|
|
452
|
+
SYSTEM_UPDATING = "-112",
|
|
453
|
+
/** 账号尚未实名认证 */
|
|
454
|
+
NOT_REAL_NAME_VERIFIED = "-113",
|
|
455
|
+
/** 请先绑定手机 */
|
|
456
|
+
NEED_BIND_PHONE = "-114",
|
|
457
|
+
/** 请先完成实名认证 */
|
|
458
|
+
NEED_REAL_NAME_VERIFICATION = "-115",
|
|
459
|
+
/** 木有改动 */
|
|
460
|
+
NO_CHANGE = "-304",
|
|
461
|
+
/** 撞车跳转 */
|
|
462
|
+
CONFLICT_REDIRECT = "-307",
|
|
463
|
+
/** 风控校验失败 (UA 或 wbi 参数不合法) */
|
|
464
|
+
RISK_CONTROL_FAILED = "-352",
|
|
465
|
+
/** 请求错误 */
|
|
466
|
+
BAD_REQUEST = "-400",
|
|
467
|
+
/** 未认证 (或非法请求) */
|
|
468
|
+
UNAUTHORIZED = "-401",
|
|
469
|
+
/** 访问权限不足 */
|
|
470
|
+
FORBIDDEN = "-403",
|
|
471
|
+
/** 啥都木有 */
|
|
472
|
+
NOT_FOUND = "-404",
|
|
473
|
+
/** 不支持该方法 */
|
|
474
|
+
METHOD_NOT_ALLOWED = "-405",
|
|
475
|
+
/** 冲突 */
|
|
476
|
+
CONFLICT = "-409",
|
|
477
|
+
/** 请求被拦截 (客户端 ip 被服务端风控) */
|
|
478
|
+
IP_BLOCKED = "-412",
|
|
479
|
+
/** 服务器错误 */
|
|
480
|
+
SERVER_ERROR = "-500",
|
|
481
|
+
/** 过载保护,服务暂不可用 */
|
|
482
|
+
SERVICE_UNAVAILABLE = "-503",
|
|
483
|
+
/** 服务调用超时 */
|
|
484
|
+
GATEWAY_TIMEOUT = "-504",
|
|
485
|
+
/** 超出限制 */
|
|
486
|
+
RATE_LIMITED = "-509",
|
|
487
|
+
/** 上传文件不存在 */
|
|
488
|
+
FILE_NOT_FOUND = "-616",
|
|
489
|
+
/** 上传文件太大 */
|
|
490
|
+
FILE_TOO_LARGE = "-617",
|
|
491
|
+
/** 登录失败次数太多 */
|
|
492
|
+
LOGIN_ATTEMPTS_EXCEEDED = "-625",
|
|
493
|
+
/** 用户不存在 */
|
|
494
|
+
USER_NOT_FOUND = "-626",
|
|
495
|
+
/** 密码太弱 */
|
|
496
|
+
WEAK_PASSWORD = "-628",
|
|
497
|
+
/** 用户名或密码错误 */
|
|
498
|
+
INVALID_CREDENTIALS = "-629",
|
|
499
|
+
/** 操作对象数量限制 */
|
|
500
|
+
OBJECT_LIMIT_EXCEEDED = "-632",
|
|
501
|
+
/** 被锁定 */
|
|
502
|
+
ACCOUNT_LOCKED = "-643",
|
|
503
|
+
/** 用户等级太低 */
|
|
504
|
+
USER_LEVEL_TOO_LOW = "-650",
|
|
505
|
+
/** 重复的用户 */
|
|
506
|
+
DUPLICATE_USER = "-652",
|
|
507
|
+
/** Token 过期 */
|
|
508
|
+
TOKEN_EXPIRED = "-658",
|
|
509
|
+
/** 密码时间戳过期 */
|
|
510
|
+
PASSWORD_TIMESTAMP_EXPIRED = "-662",
|
|
511
|
+
/** 地理区域限制 */
|
|
512
|
+
GEO_RESTRICTED = "-688",
|
|
513
|
+
/** 版权限制 */
|
|
514
|
+
COPYRIGHT_RESTRICTED = "-689",
|
|
515
|
+
/** 扣节操失败 */
|
|
516
|
+
REPUTATION_DEDUCTION_FAILED = "-701",
|
|
517
|
+
/** 请求过于频繁,请稍后再试 */
|
|
518
|
+
TOO_MANY_REQUESTS = "-799",
|
|
519
|
+
/** 服务器开小差了 */
|
|
520
|
+
SERVER_TEMPORARILY_UNAVAILABLE = "-8888",
|
|
521
|
+
/** 未知错误 */
|
|
522
|
+
UNKNOWN = "UNKNOWN"
|
|
523
|
+
}
|
|
524
|
+
/** 快手平台API错误码 */
|
|
525
|
+
declare enum kuaishouAPIErrorCode {
|
|
526
|
+
/** Cookie无效或已过期 */
|
|
527
|
+
COOKIE = "INVALID_COOKIE",
|
|
528
|
+
/** 未知错误 */
|
|
529
|
+
UNKNOWN = "UNKNOWN_ERROR"
|
|
530
|
+
}
|
|
390
531
|
|
|
391
532
|
type DyEmojiList = {
|
|
392
533
|
emoji_list: EmojiListElement[];
|
|
@@ -13243,6 +13384,21 @@ type TypeControl = {
|
|
|
13243
13384
|
typeMode?: 'strict' | 'loose';
|
|
13244
13385
|
};
|
|
13245
13386
|
|
|
13387
|
+
/**
|
|
13388
|
+
* API请求错误类型
|
|
13389
|
+
* 该类型是方法 `getXXXData` 封装后请求遇到错误时的返回类型
|
|
13390
|
+
*/
|
|
13391
|
+
type APIErrorType<T extends 'douyin' | 'bilibili' | 'kuaishou' | 'default' = 'default'> = {
|
|
13392
|
+
/** 错误码 */
|
|
13393
|
+
code: T extends 'douyin' ? douoyinAPIErrorCode : T extends 'bilibili' ? bilibiliAPIErrorCode : T extends 'kuaishou' ? kuaishouAPIErrorCode : amagiAPIErrorCode;
|
|
13394
|
+
/** 错误时的响应数据 */
|
|
13395
|
+
data: any;
|
|
13396
|
+
/** amagi 错误详情 */
|
|
13397
|
+
amagiError: ErrorDetail;
|
|
13398
|
+
/** 错误信息 */
|
|
13399
|
+
amagiMessage: string;
|
|
13400
|
+
};
|
|
13401
|
+
|
|
13246
13402
|
/**
|
|
13247
13403
|
* 快捷获取抖音数据
|
|
13248
13404
|
* @param type - 请求数据类型
|
|
@@ -13589,6 +13745,13 @@ declare function bv2av(bvid: string): number;
|
|
|
13589
13745
|
*/
|
|
13590
13746
|
declare function wbi_sign(BASEURL: string | URL, cookie: string): Promise<string>;
|
|
13591
13747
|
|
|
13748
|
+
/**
|
|
13749
|
+
* 哔哩哔哩API官方HTTP请求错误码
|
|
13750
|
+
*/
|
|
13751
|
+
declare const bilibiliErrorCodeMap: {
|
|
13752
|
+
[key: string]: string;
|
|
13753
|
+
};
|
|
13754
|
+
|
|
13592
13755
|
declare function qtparam(BASEURL: string, cookie: string): Promise<{
|
|
13593
13756
|
QUERY: string;
|
|
13594
13757
|
STATUS: string;
|
|
@@ -14092,4 +14255,4 @@ declare const CreateApp: AmagiConstructor;
|
|
|
14092
14255
|
declare const Client: AmagiConstructor;
|
|
14093
14256
|
declare const amagi: AmagiConstructor;
|
|
14094
14257
|
|
|
14095
|
-
export { type BiliAv2Bv, type BiliBangumiVideoInfo, type BiliBangumiVideoPlayurlIsLogin, type BiliBangumiVideoPlayurlNoLogin, type BiliBiliVideoPlayurlNoLogin, type BiliBv2AV, type BiliCheckQrcode, type BiliDynamicCard, type BiliDynamicInfo, type BiliEmojiList, type BiliLiveRoomDef, type BiliLiveRoomDetail, type BiliNewLoginQrcode, type BiliOneWork, type BiliUserDynamic, type BiliUserFullView, type BiliUserProfile, type BiliVideoPlayurlIsLogin, type BiliWorkComments, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, type BilibiliRequest, BilibiliValidateData, CreateApp, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, type DouyinRequest, DouyinValidateData, type DyEmojiList, type DyEmojiProList, type DyImageAlbumWork, type DyMusicWork, type DySearchInfo, type DySlidesWork, type DySuggestWords, type DyUserInfo, type DyUserLiveVideos, type DyUserPostVideos, type DyVideoWork, type DyWorkComments, type KsEmojiList, type KsOneWork, type KsWorkComments, KuaishouAPI, type KuaishouDataOptions, type KuaishouDataOptionsMap, type KuaishouMethodOptionsMap, type KusiahouRequest, KusiahouValidateData, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliUtils, bv2av, type cookiesOptions, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
|
14258
|
+
export { type APIErrorType, type BiliAv2Bv, type BiliBangumiVideoInfo, type BiliBangumiVideoPlayurlIsLogin, type BiliBangumiVideoPlayurlNoLogin, type BiliBiliVideoPlayurlNoLogin, type BiliBv2AV, type BiliCheckQrcode, type BiliDynamicCard, type BiliDynamicInfo, type BiliEmojiList, type BiliLiveRoomDef, type BiliLiveRoomDetail, type BiliNewLoginQrcode, type BiliOneWork, type BiliUserDynamic, type BiliUserFullView, type BiliUserProfile, type BiliVideoPlayurlIsLogin, type BiliWorkComments, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, type BilibiliRequest, BilibiliValidateData, CreateApp, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, type DouyinRequest, DouyinValidateData, type DyEmojiList, type DyEmojiProList, type DyImageAlbumWork, type DyMusicWork, type DySearchInfo, type DySlidesWork, type DySuggestWords, type DyUserInfo, type DyUserLiveVideos, type DyUserPostVideos, type DyVideoWork, type DyWorkComments, type KsEmojiList, type KsOneWork, type KsWorkComments, KuaishouAPI, type KuaishouDataOptions, type KuaishouDataOptionsMap, type KuaishouMethodOptionsMap, type KusiahouRequest, KusiahouValidateData, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, amagiClient, av2bv, bilibili, bilibiliAPI, bilibiliApiUrls, bilibiliErrorCodeMap, bilibiliUtils, bv2av, type cookiesOptions, Client as default, douyin, douyinAPI, douyinApiUrls, douyinSign, douyinUtils, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, kuaishou, kuaishouAPI, kuaishouApiUrls, kuaishouUtils, logMiddleware, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, wbi_sign };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikenxuan/amagi",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.17",
|
|
4
4
|
"description": "抖音、B站的 web 端相关数据接口基于 Node.js 的实现",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"douyin",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"sort": "npx sort-package-json"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"axios": "npm:@karinjs/axios@^1.
|
|
63
|
+
"axios": "npm:@karinjs/axios@^1.2.0",
|
|
64
64
|
"chalk": "4.1.2",
|
|
65
65
|
"express": "npm:@karinjs/express@^1.0.3",
|
|
66
66
|
"log4js": "npm:@karinjs/log4js@1.1.4",
|